Skip to content

ESQL: Simplify agg construction when reducing node-level#128980

Merged
alex-spies merged 3 commits intoelastic:mainfrom
alex-spies:refactor-node-level-reduction-of-aggs
Jun 6, 2025
Merged

ESQL: Simplify agg construction when reducing node-level#128980
alex-spies merged 3 commits intoelastic:mainfrom
alex-spies:refactor-node-level-reduction-of-aggs

Conversation

@alex-spies
Copy link
Copy Markdown
Contributor

@alex-spies alex-spies commented Jun 5, 2025

When we construct an intermediate Aggregate as the node-level reduction step on a data node, we weirdly set the aggregator mode to initial rather than intermediate. Then, later, in AbstractPhysicalOperationProviders#groupingPhysicalOperation, we do a little dance to detect intermediate aggs in node-level reduction only by checking if the agg's child is an exchange even though the agg mode is initial.

This is leaking implementation details of the construction of the node-level reduction agg and makes this hard to grasp. I think it's just a leftover from a time when the compute engine had an intermediate aggregation mode but the planner didn't.

Let's clean that up and just set the agg mode to intermediate right away when constructing the node-level reduction agg.

Copy link
Copy Markdown
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks Alex!

@alex-spies alex-spies added >refactoring auto-backport Automatically create backport pull requests when merged :Analytics/ES|QL AKA ESQL v8.19.0 labels Jun 6, 2025
@alex-spies alex-spies marked this pull request as ready for review June 6, 2025 09:56
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jun 6, 2025
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@alex-spies
Copy link
Copy Markdown
Contributor Author

All checks passing except for the Serverless checks, which fail due to a compilation error in an unrelated test class - fix already merged. I retried running the Serverless checks multiple times but this seems to take a while for the fix to be picked up.

Since this is blocking #128745, I'm going to go ahead with the merge; this is fine as there are no Serverless check failures related to this change, specifically.

@alex-spies alex-spies merged commit 110bbe8 into elastic:main Jun 6, 2025
17 of 18 checks passed
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 128980

@alex-spies
Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

Questions ?

Please refer to the Backport tool documentation

alex-spies added a commit to alex-spies/elasticsearch that referenced this pull request Jun 6, 2025
…128980)

(cherry picked from commit 110bbe8)

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/AbstractPhysicalOperationProviders.java
elasticsearchmachine pushed a commit that referenced this pull request Jun 6, 2025
…#129050)

(cherry picked from commit 110bbe8)

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/AbstractPhysicalOperationProviders.java
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jun 9, 2025
valeriy42 pushed a commit to valeriy42/elasticsearch that referenced this pull request Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged backport pending >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants