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: Improve agg verification #99827

Merged

Conversation

alex-spies
Copy link
Contributor

@alex-spies alex-spies commented Sep 22, 2023

Fixes #99751. Update: fix for #99751 is already contained in #99602. I'm keeping this PR open for additional verification improvements, though.

When verifying aggregation expressions like from employees | stats percentile(salary_change, 25*2), both arguments are treated the same way during verification. This is incorrect, as salary_change is the actual aggregation's field, while 25*2 is merely it's (first and only) parameter. This is overly restrictive.

Apply the current verification only to the aggregation's actual field, as the parameter is already verified during type resolution (it needs to be a constant expression).

@elasticsearchmachine elasticsearchmachine added the Team:QL (Deprecated) Meta label for query languages team label Sep 22, 2023
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

Hi @alex-spies, I've created a changelog YAML for you.

@elasticsearchmachine
Copy link
Collaborator

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

@alex-spies
Copy link
Contributor Author

This might need to be (adapted and) merged after #99602 since support for count(*) may need to be accounted for in the verifier that is updated in this PR.

@alex-spies alex-spies changed the title ESQL: Fix NPE when aggregating literals ESQL: Improve agg verification Oct 2, 2023
@alex-spies alex-spies requested a review from bpintea October 2, 2023 16:39
Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

LGTM, maybe add one more test with a different function than add.

@mattc58 mattc58 added v8.12.0 and removed v8.11.0 labels Oct 4, 2023
@alex-spies alex-spies requested a review from bpintea October 5, 2023 18:17
@alex-spies
Copy link
Contributor Author

@bpintea , I took care of the type resolution bug in count_distinct. Would you like to take another look?

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

@costin
Copy link
Member

costin commented Oct 6, 2023

Likely this has to go in 8.11 as well.

Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

LGTM

@elasticsearchmachine
Copy link
Collaborator

Hi @alex-spies, I've updated the changelog YAML for you.

@alex-spies
Copy link
Contributor Author

@elasticsearchmachine run elasticsearch-ci/part-1

@alex-spies alex-spies added the buildkite-opt-in Opts your PR into Buildkite instead of Jenkins label Oct 6, 2023
@alex-spies
Copy link
Contributor Author

@elasticsearchmachine run elasticsearch-ci/part-1

@elasticsearchmachine
Copy link
Collaborator

Hi @alex-spies, I've updated the changelog YAML for you.

@alex-spies alex-spies merged commit 3c12c31 into elastic:main Oct 6, 2023
@alex-spies alex-spies deleted the esql-npe-when-aggregating-literals branch October 6, 2023 13:46
alex-spies added a commit to alex-spies/elasticsearch that referenced this pull request Oct 6, 2023
When verifying aggregation expressions like
from employees | stats percentile(salary_change, 25*2)
, both arguments are treated the same way during verification. This is
incorrect, as salary_change is the actual aggregation's field, while
25*2 is merely it's (first and only) parameter. This is overly
restrictive.

Apply the current verification only to the aggregation's actual field,
as the parameter is already verified during type resolution (it needs to
be a constant expression).
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.11

alex-spies added a commit that referenced this pull request Oct 9, 2023
When verifying aggregation expressions like
from employees | stats percentile(salary_change, 25*2)
, both arguments are treated the same way during verification. This is
incorrect, as salary_change is the actual aggregation's field, while
25*2 is merely it's (first and only) parameter. This is overly
restrictive.

Apply the current verification only to the aggregation's actual field,
as the parameter is already verified during type resolution (it needs to
be a constant expression).
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 buildkite-opt-in Opts your PR into Buildkite instead of Jenkins Team:QL (Deprecated) Meta label for query languages team v8.11.0 v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESQL: NPE when aggregating on literals
5 participants