Skip to content

Conversation

@astefan
Copy link
Contributor

@astefan astefan commented Oct 2, 2019

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 or matrix_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.

@astefan astefan added >bug :Analytics/SQL SQL querying labels Oct 2, 2019
@astefan astefan requested review from costin and matriv October 2, 2019 14:13
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/SQL)

Copy link
Contributor

@matriv matriv left a 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?

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@astefan astefan requested a review from matriv October 3, 2019 10:29
Copy link
Contributor

@matriv matriv left a 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.

@astefan astefan merged commit bb14ba8 into elastic:master Oct 4, 2019
astefan added a commit that referenced this pull request Oct 4, 2019
…7444)

* Skip functions involving full-text predicates when replacing multiple
aggregate functions with "stats" or "matrix_stats" aggregations.

(cherry picked from commit bb14ba8)
astefan added a commit that referenced this pull request Oct 4, 2019
…7444)

* Skip functions involving full-text predicates when replacing multiple
aggregate functions with "stats" or "matrix_stats" aggregations.

(cherry picked from commit bb14ba8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL: error when an aggregate function is used in combination with two full-text search conditions

5 participants