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: Cannot use NOT in SELECT clause when table columns are used. #34558

Closed
matriv opened this issue Oct 17, 2018 · 2 comments
Closed

SQL: Cannot use NOT in SELECT clause when table columns are used. #34558

matriv opened this issue Oct 17, 2018 · 2 comments

Comments

@matriv
Copy link
Contributor

matriv commented Oct 17, 2018

SELECT NOT emp_no = 1 FROM test_emp throws:

java.sql.SQLException: Server encountered an error [Not supported yet]. [SqlIllegalArgumentException[Not supported yet]
	at org.elasticsearch.xpack.sql.expression.predicate.Not.asScript(Not.java:58)
	at org.elasticsearch.xpack.sql.expression.function.scalar.ScalarFunction.toAttribute(ScalarFunction.java:38)
	at org.elasticsearch.xpack.sql.planner.QueryFolder$FoldProject.rule(QueryFolder.java:140)
	at org.elasticsearch.xpack.sql.planner.QueryFolder$FoldProject.rule(QueryFolder.java:106)

but it works if everything is a literal: SELECT NOT 1 > 2

Need to implement asScript and makePipe in Not unary scalar function.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@matriv matriv self-assigned this Oct 21, 2018
@matriv matriv added the v6.5.0 label Oct 21, 2018
matriv added a commit to matriv/elasticsearch that referenced this issue Oct 21, 2018
For other logical operators adding `NOT` in front of the expression
results in negation of the binary operator, e.g.:
`NOT a > b` becomes `a <= b`
but this is not the case for `NOT a = b`.

This implements the negation of equals when encountered in the SELECT
clause or needs to be translated to a painless script (e.g.:
`HAVING NOT count(*) = 10`)

Previously, an `SqlIllegalArgumentException[Not supported yet]` was
thrown.

Fixes: elastic#34558
@colings86 colings86 added v6.6.0 and removed v6.5.0 labels Oct 25, 2018
@costin
Copy link
Member

costin commented Oct 29, 2018

This has been addressed by #34848

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

No branches or pull requests

4 participants