-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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: fix multi full-text functions usage with aggregate functions #47444
Conversation
aggregate functions with "stats" or "matrix_stats" aggregations.
Pinging @elastic/es-search (:Search/SQL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work with integration tests.
Could you please also add at least one unit test in OptimizerTests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
Please don't forget to add the appropriate labels.
Full-text functions (predicates) are simple expressions (vs. named expressions) and, thus, they don't have an associated Painless script to be used in queries, nor they have results to be returned to the user (function attributes). In the specific case of replacing multiple aggregate functions (avg, min, max, skewness, variance etc) with their simplified ES aggregation (
stats
ormatrix_stats
) any function to be replaced is searched for in the rest of the query to get replaced as well.During this search, a logical binary function - OR or AND - where full-text predicates are used is attempted to have a function attribute created for it which fails, as stated above.
The fix is to skip those functions that use full-text predicates, as they won't have a function attribute to check.
Fixes #47365.