-
Notifications
You must be signed in to change notification settings - Fork 25.2k
SQL: Simplify expression optimization #35270
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
Labels
Comments
Pinging @elastic/es-search-aggs |
relates #29853 |
matriv
added a commit
to matriv/elasticsearch
that referenced
this issue
Mar 3, 2020
Add a unit test to verify that the optimization of expression (e.g. COALESCE) is applied to all instances of the expression: SELECT, WHERE, GROUP BY. Relates to elastic#35270
The issue has been resolved with the refactoring of the NamedExpression: #49570. |
matriv
added a commit
that referenced
this issue
Mar 4, 2020
Add a unit test to verify that the optimization of expression (e.g. COALESCE) is applied to all instances of the expression: SELECT, WHERE, GROUP BY and HAVING. Relates to #35270
matriv
added a commit
that referenced
this issue
Mar 4, 2020
matriv
added a commit
that referenced
this issue
Mar 4, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A common case in the optimizer is improving predicate expressions which tend to be
Function
s. However when this is referred through its id and that id changes, the plan becomes inconsistent.For example
SELECT COALESCE(null, 1) AS c FROM ... HAVING c > 100
The optimizer will optimize the
Coalesce
definition butHAVING c > 100
will still use the old script definition (now residing in the scalar reference).This is a recurrent issue that affect all rules and proved to create bugs in the past due to old references lying around. In the above case it's even more problematic since the old id is not used (and thus the query does not blow up) but the old script is.
The text was updated successfully, but these errors were encountered: