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: AND and OR don't behave correctly with NULLS in SELECT clause #35240

Closed
matriv opened this issue Nov 4, 2018 · 1 comment
Closed

SQL: AND and OR don't behave correctly with NULLS in SELECT clause #35240

matriv opened this issue Nov 4, 2018 · 1 comment

Comments

@matriv
Copy link
Contributor

matriv commented Nov 4, 2018

SELECT languages = 2 OR null, languages = 2 AND null FROM test_emp
WHERE emp_no BETWEEN 10018 AND 10020 ORDER BY emp_no;

Returns:

null | null                                        
null | null                                        
null | null

instead of:

true | null
null | false
null | null

The issue is spotted in the BinaryLogicProcessor which doesn't override process() so the process() of BinaryProcessor is called which exits if either left or right evaluates to null.

@matriv matriv added >bug :Analytics/SQL SQL querying labels Nov 4, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@matriv matriv self-assigned this Nov 5, 2018
matriv added a commit to matriv/elasticsearch that referenced this issue Nov 5, 2018
Override `process()` in `BinaryLogicProcessor` which doesn't immediately
return null if left or right argument is null, which is the behaviour of
`process()` of the parent class `BinaryProcessor`.

Also, add more tests for `AND` and `OR` in SELECT clause with literal.

Fixes: elastic#35240
matriv pushed a commit that referenced this issue Nov 6, 2018
Override `process()` in `BinaryLogicProcessor` which doesn't immediately
return null if left or right argument is null, which is the behaviour of
`process()` of the parent class `BinaryProcessor`.

Also, add more tests for `AND` and `OR` in SELECT clause with literal.

Fixes: #35240
matriv pushed a commit that referenced this issue Nov 6, 2018
Override `process()` in `BinaryLogicProcessor` which doesn't immediately
return null if left or right argument is null, which is the behaviour of
`process()` of the parent class `BinaryProcessor`.

Also, add more tests for `AND` and `OR` in SELECT clause with literal.

Fixes: #35240
matriv pushed a commit that referenced this issue Nov 6, 2018
Override `process()` in `BinaryLogicProcessor` which doesn't immediately
return null if left or right argument is null, which is the behaviour of
`process()` of the parent class `BinaryProcessor`.

Also, add more tests for `AND` and `OR` in SELECT clause with literal.

Fixes: #35240
@colings86 colings86 added v6.5.0 and removed v6.5.1 labels Nov 9, 2018
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
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