SQL: Nicer failure message one EXISTS (elastic/x-pack-elasticsearch#3384)
We don't support the SQL `EXISTS` keyword. It looks like: ``` SELECT * FROM test WHERE EXISTS (SELECT * FROM foo WHERE test.id = foo.id) ``` It is basically a `JOIN` that doesn't return columns. Since we don't support `JOIN`, we don't support `EXISTS`. This PR improves the error message from "unresolved blah blah blah" to "EXISTS is not yet supported". relates elastic/x-pack-elasticsearch#3176 Original commit: elastic/x-pack-elasticsearch@548d57c8c1
This commit is contained in:
parent
d2df25072a
commit
42d1c62d03
|
@ -174,6 +174,13 @@ public abstract class RestSqlTestCase extends ESRestTestCase implements ErrorsTe
|
|||
containsString("line 1:32: GROUP BY ALL is not supported"));
|
||||
}
|
||||
|
||||
public void testSelectWhereExistsFails() throws Exception {
|
||||
index("{\"foo\":1}", "{\"foo\":2}");
|
||||
expectBadRequest(() -> runSql("SELECT foo FROM test WHERE EXISTS (SELECT * FROM test t WHERE t.foo = test.foo)"),
|
||||
containsString("line 1:28: EXISTS is not yet supported"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void testSelectInvalidSql() {
|
||||
expectBadRequest(() -> runSql("SELECT * FRO"), containsString("1:8: Cannot determine columns for *"));
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack.sql.analysis.analyzer;
|
|||
import org.elasticsearch.xpack.sql.capabilities.Unresolvable;
|
||||
import org.elasticsearch.xpack.sql.expression.Alias;
|
||||
import org.elasticsearch.xpack.sql.expression.Attribute;
|
||||
import org.elasticsearch.xpack.sql.expression.Exists;
|
||||
import org.elasticsearch.xpack.sql.expression.Expression;
|
||||
import org.elasticsearch.xpack.sql.expression.Expressions;
|
||||
import org.elasticsearch.xpack.sql.expression.Order;
|
||||
|
@ -146,6 +147,8 @@ abstract class Verifier {
|
|||
// type resolution
|
||||
if (ae.typeResolved().unresolved()) {
|
||||
localFailures.add(fail(ae, ae.typeResolved().message()));
|
||||
} else if (ae instanceof Exists) {
|
||||
localFailures.add(fail(ae, "EXISTS is not yet supported"));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue