Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: selecting a full-text function generates error #47446

Closed
astefan opened this issue Oct 2, 2019 · 2 comments · Fixed by #51568
Closed

SQL: selecting a full-text function generates error #47446

astefan opened this issue Oct 2, 2019 · 2 comments · Fixed by #51568
Labels

Comments

@astefan
Copy link
Contributor

astefan commented Oct 2, 2019

The desired behavior is a user friendly error message stating that full-text functions cannot be used as projections. Related to #47365.

sql> SELECT MATCH(gender, 'F') FROM test_emp;
Server error [Server encountered an error [Cannot cast org.elasticsearch.xpack.sql.expression.predicate.fulltext.MatchQueryPredicate to org.elasticsearch.xpack.sql.expression.NamedExpression]. [java.lang.ClassCastException: Cannot cast org.elasticsearch.xpack.sql.expression.predicate.fulltext.MatchQueryPredicate to org.elasticsearch.xpack.sql.expression.NamedExpression
        at java.base/java.lang.Class.cast(Class.java:3606)
        at org.elasticsearch.xpack.sql.parser.AbstractBuilder.visitList(AbstractBuilder.java:63)
        at org.elasticsearch.xpack.sql.parser.LogicalPlanBuilder.visitQuerySpecification(LogicalPlanBuilder.java:129)
        at org.elasticsearch.xpack.sql.parser.LogicalPlanBuilder.visitQuerySpecification(LogicalPlanBuilder.java:64)
        at org.elasticsearch.xpack.sql.parser.SqlBaseParser$QuerySpecificationContext.accept(SqlBaseParser.java:1722)
        at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:70)
        at org.elasticsearch.xpack.sql.parser.SqlBaseBaseVisitor.visitQueryPrimaryDefault(SqlBaseBaseVisitor.java:125)
        at org.elasticsearch.xpack.sql.parser.SqlBaseParser$QueryPrimaryDefaultContext.accept(SqlBaseParser.java:1552)
        at org.elasticsearch.xpack.sql.parser.AbstractBuilder.typedParsing(AbstractBuilder.java:42)
        at org.elasticsearch.xpack.sql.parser.AbstractBuilder.plan(AbstractBuilder.java:53)
        at org.elasticsearch.xpack.sql.parser.LogicalPlanBuilder.visitQueryNoWith(LogicalPlanBuilder.java:95)
        at org.elasticsearch.xpack.sql.parser.LogicalPlanBuilder.visitQueryNoWith(LogicalPlanBuilder.java:64)
        at org.elasticsearch.xpack.sql.parser.SqlBaseParser$QueryNoWithContext.accept(SqlBaseParser.java:1362)
        at org.elasticsearch.xpack.sql.parser.AbstractBuilder.typedParsing(AbstractBuilder.java:42)
        at org.elasticsearch.xpack.sql.parser.AbstractBuilder.plan(AbstractBuilder.java:53)
        at org.elasticsearch.xpack.sql.parser.LogicalPlanBuilder.visitQuery(LogicalPlanBuilder.java:72)
        at org.elasticsearch.xpack.sql.parser.LogicalPlanBuilder.visitQuery(LogicalPlanBuilder.java:64)
        at org.elasticsearch.xpack.sql.parser.SqlBaseParser$QueryContext.accept(SqlBaseParser.java:1279)
        at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:70)
        at org.elasticsearch.xpack.sql.parser.SqlBaseBaseVisitor.visitStatementDefault(SqlBaseBaseVisitor.java:34)
        at org.elasticsearch.xpack.sql.parser.SqlBaseParser$StatementDefaultContext.accept(SqlBaseParser.java:465)
        at org.elasticsearch.xpack.sql.parser.AbstractBuilder.typedParsing(AbstractBuilder.java:42)
        at org.elasticsearch.xpack.sql.parser.AbstractBuilder.plan(AbstractBuilder.java:53)
        at org.elasticsearch.xpack.sql.parser.AstBuilder.visitSingleStatement(AstBuilder.java:26)
        at org.elasticsearch.xpack.sql.parser.AstBuilder.visitSingleStatement(AstBuilder.java:15)
        at org.elasticsearch.xpack.sql.parser.SqlBaseParser$SingleStatementContext.accept(SqlBaseParser.java:185)
        at org.elasticsearch.xpack.sql.parser.AbstractBuilder.typedParsing(AbstractBuilder.java:42)
        at org.elasticsearch.xpack.sql.parser.AbstractBuilder.plan(AbstractBuilder.java:53)
        at org.elasticsearch.xpack.sql.parser.SqlParser.invokeParser(SqlParser.java:129)
        at org.elasticsearch.xpack.sql.parser.SqlParser.createStatement(SqlParser.java:66)
        at org.elasticsearch.xpack.sql.session.SqlSession.doParse(SqlSession.java:99)
@astefan astefan added >bug :Analytics/SQL SQL querying labels Oct 2, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/SQL)

matriv added a commit to matriv/elasticsearch that referenced this issue Jan 28, 2020
Add a verification that full-text search functions are not
allowed in the SELECT clause, so that a nice error message is
returned to the user early instead of an "ugly" exception.

Fixes: elastic#47446
matriv added a commit that referenced this issue Jan 30, 2020
Add a verification that full-text search functions `MATCH()` and `QUERY()`
are not allowed in the SELECT clause, so that a nice error message is
returned to the user early instead of an "ugly" exception.

Fixes: #47446
matriv added a commit that referenced this issue Jan 30, 2020
Add a verification that full-text search functions `MATCH()` and `QUERY()`
are not allowed in the SELECT clause, so that a nice error message is
returned to the user early instead of an "ugly" exception.

Fixes: #47446
matriv added a commit that referenced this issue Jan 30, 2020
Add a verification that full-text search functions `MATCH()` and `QUERY()`
are not allowed in the SELECT clause, so that a nice error message is
returned to the user early instead of an "ugly" exception.

Fixes: #47446
(cherry picked from commit 65ad269)
matriv added a commit that referenced this issue Jan 30, 2020
…#51673)

Add a verification that full-text search functions `MATCH()` and `QUERY()`
are not allowed in the SELECT clause, so that a nice error message is
returned to the user early instead of an "ugly" exception.

Fixes: #47446
(cherry picked from commit 65ad269)
@matriv
Copy link
Contributor

matriv commented Jan 30, 2020

master: 65ad269
7.x: 285a167
7.6: 3ba58c9
6.8: 52107ed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants