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

ESQL: Simplify IS NULL/IS NOT NULL evaluation #103097

Closed
costin opened this issue Dec 7, 2023 · 4 comments · Fixed by #103099
Closed

ESQL: Simplify IS NULL/IS NOT NULL evaluation #103097

costin opened this issue Dec 7, 2023 · 4 comments · Fixed by #103099
Labels
:Analytics/ES|QL AKA ESQL >bug Team:QL (Deprecated) Meta label for query languages team v8.12.0
Milestone

Comments

@costin
Copy link
Member

costin commented Dec 7, 2023

Description

The IS NULL/IS NOT NULL only care about the nullability not the value of an expression.
Given the expression x + 1 / 2, the actual result does not matter only if it's null or not - that is, it only matters if x is null or not.
So x + 1 / 2 IS NULL becomes x IS NULL - which can be opportunistically pushed down or evaluated.

@costin costin added this to the 8.12 milestone Dec 7, 2023
@elasticsearchmachine elasticsearchmachine added the Team:QL (Deprecated) Meta label for query languages team label Dec 7, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)

costin added a commit to costin/elasticsearch that referenced this issue Dec 7, 2023
The IS NULL, IS NOT NULL predicates only care about the nullability not
 the value of an expression. Given the expression x + 1 / 2, the actual
 result does not matter only if it's null or not - that is, it only
 matters if x is null or not.
 So x + 1 / 2 IS NULL becomes x IS NULL - which can be opportunistically
 pushed down or evaluated.

Fix elastic#103097
costin added a commit to costin/elasticsearch that referenced this issue Dec 7, 2023
The IS NULL, IS NOT NULL predicates only care about the nullability not
 the value of an expression. Given the expression x + 1 / 2, the actual
 result does not matter only if it's null or not - that is, it only
 matters if x is null or not.
 So x + 1 / 2 IS NULL becomes x IS NULL - which can be opportunistically
 pushed down or evaluated.

Fix elastic#103097
costin added a commit to costin/elasticsearch that referenced this issue Dec 7, 2023
The IS NULL, IS NOT NULL predicates only care about the nullability not
 the value of an expression. Given the expression x + 1 / 2, the actual
 result does not matter only if it's null or not - that is, it only
 matters if x is null or not.
 So x + 1 / 2 IS NULL becomes x IS NULL - which can be opportunistically
 pushed down or evaluated.

Fix elastic#103097
@luigidellaquila
Copy link
Contributor

Should we account for overflows as well?

@costin
Copy link
Member Author

costin commented Dec 8, 2023

We should, see #103099

costin added a commit that referenced this issue Dec 13, 2023
The IS NULL, IS NOT NULL predicates only care about the nullability not
 the value of an expression. Given the expression x + 1 / 2, the actual
 result does not matter only if it's null or not - that is, it only
 matters if x is null or not.
 So x + 1 / 2 IS NULL becomes x IS NULL - which can be opportunistically
 pushed down or evaluated.
Preserve the original expression to cope with under/overflow or mv
 fields

Fix #103097
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >bug Team:QL (Deprecated) Meta label for query languages team v8.12.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants