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: null literals not handled correctly in query translation #35088

Closed
matriv opened this issue Oct 30, 2018 · 1 comment

Comments

@matriv
Copy link
Contributor

commented Oct 30, 2018

When null literals are used in HAVING or WHERE clause an exception is thrown, e.g.:

SELECT gender, max(emp_no) FROM test_emp WHERE salary > 10 or null GROUP BY gender;

throws:

SqlIllegalArgumentException[Don't know how to translate Literal null
@elasticmachine

This comment has been minimized.

Copy link
Collaborator

commented Oct 30, 2018

Pinging @elastic/es-search-aggs

matriv added a commit to matriv/elasticsearch that referenced this issue Nov 4, 2018
SQL: Handle null literal for AND and OR in `WHERE`
Eliminate `null` literal in the `Optimizer` where we know that we
are in the WHERE clause so we can evaluate NULL to false. Now the
`null` literal is not reaching the `QueryTranslator`.

Fixes: elastic#35088

@matriv matriv removed the v7.0.0 label Nov 4, 2018

matriv added a commit to matriv/elasticsearch that referenced this issue Nov 4, 2018
SQL: Handle null literal for AND and OR in `WHERE`
Translate `null` to a null query and since we know that we
are in the WHERE clause so we can evaluate those nulls to false.

Fixes: elastic#35088

@matriv matriv self-assigned this Nov 5, 2018

@matriv matriv closed this in #35236 Nov 8, 2018

matriv added a commit that referenced this issue Nov 8, 2018
SQL: Handle null literal for AND and OR in `WHERE` (#35236)
Change `nullable()` logic of AND and OR to false since in the Optimizer
we cannot fold to null as we might be handling and expression in the
SELECT clause.

Introduce folding of null for AND and OR expressions in PruneFilter()
since we now know that we are in HAVING or WHERE clause and we
can fold `null` to `false`

Fixes: #35088

Co-authored-by: Costin Leau <costin.leau@gmail.com>
matriv added a commit that referenced this issue Nov 8, 2018
SQL: Handle null literal for AND and OR in `WHERE` (#35236)
Change `nullable()` logic of AND and OR to false since in the Optimizer
we cannot fold to null as we might be handling and expression in the
SELECT clause.

Introduce folding of null for AND and OR expressions in PruneFilter()
since we now know that we are in HAVING or WHERE clause and we
can fold `null` to `false`

Fixes: #35088

Co-authored-by: Costin Leau <costin.leau@gmail.com>
matriv added a commit that referenced this issue Nov 8, 2018
SQL: Handle null literal for AND and OR in `WHERE` (#35236)
Change `nullable()` logic of AND and OR to false since in the Optimizer
we cannot fold to null as we might be handling and expression in the
SELECT clause.

Introduce folding of null for AND and OR expressions in PruneFilter()
since we now know that we are in HAVING or WHERE clause and we
can fold `null` to `false`

Fixes: #35088

Co-authored-by: Costin Leau <costin.leau@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.