Skip to content

Conversation

ivancea
Copy link
Contributor

@ivancea ivancea commented Feb 7, 2025

Don't be afraid of the amount of files: Most changes are trivial refactors along all aggregators/functions/tests.

To avoid having AggregateMapper find aggregators based on their names with reflection, I'm doing some changes:

  • Make the suppliers have methods returning the intermediate states
  • To allow this, the suppliers constructor won't receive the chanells as params. Instead, its methods will ask for them
    • Most changes in this PR are because of this
  • After those changes, I'm leaving AggregateMapper still there, as it still converts AggregateFunctions to its NamedExpressions

In general, I think the change fits very well:

  • Now aggregate functions supplier() methods are more straightforward: "Give me the supplier for the params/types you have". No other logics required
  • It simplified ToPartial and FromPartial code

Things in progress

@ivancea ivancea added >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.1.0 labels Feb 7, 2025

@Override
public AggregatorFunctionSupplier supplier(List<Integer> inputChannels) {
if (inputChannels.size() != 2 && inputChannels.size() != 3) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This assertion can't be done now, unless we manually change the autogenerated function suppliers.
I don't think it's "required" though

@ivancea ivancea marked this pull request as ready for review February 7, 2025 14:41
@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

That's a lot nicer.

Copy link
Contributor

@idegtiarenko idegtiarenko left a comment

Choose a reason for hiding this comment

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

Thanks for simplifying AggregateMapper!

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/AggregateMapper.java
@ivancea ivancea enabled auto-merge (squash) February 10, 2025 11:04
@ivancea ivancea merged commit 7bea3a5 into elastic:main Feb 10, 2025
17 checks passed
@ivancea ivancea deleted the esql-aggregate-mapper-to-supplier branch February 10, 2025 12:02
@ivancea
Copy link
Contributor Author

ivancea commented Feb 10, 2025

💚 All backports created successfully

Status Branch Result
9.0

Questions ?

Please refer to the Backport tool documentation

ivancea added a commit to ivancea/elasticsearch that referenced this pull request Feb 10, 2025
…ate to suppliers (elastic#122023)

To avoid having AggregateMapper find aggregators based on their names with reflection, I'm doing some changes:
- Make the suppliers have methods returning the intermediate states
- To allow this, the suppliers constructor won't receive the chanells as params. Instead, its methods will ask for them
  - Most changes in this PR are because of this
- After those changes, I'm leaving AggregateMapper still there, as it still converts AggregateFunctions to its NamedExpressions

(cherry picked from commit 7bea3a5)

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/AggregateMapper.java
@ivancea
Copy link
Contributor Author

ivancea commented Feb 10, 2025

8.x backport waiting for backport of #119889

ivancea added a commit that referenced this pull request Feb 11, 2025
…ate to suppliers (#122023) (#122183)

To avoid having AggregateMapper find aggregators based on their names with reflection, I'm doing some changes:
- Make the suppliers have methods returning the intermediate states
- To allow this, the suppliers constructor won't receive the chanells as params. Instead, its methods will ask for them
  - Most changes in this PR are because of this
- After those changes, I'm leaving AggregateMapper still there, as it still converts AggregateFunctions to its NamedExpressions

(cherry picked from commit 7bea3a5)

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/AggregateMapper.java
ivancea added a commit that referenced this pull request Feb 12, 2025
…ate to suppliers (#122023) (#122380)

Manual 8.x backport of #122023

To avoid having AggregateMapper find aggregators based on their names with reflection, I'm doing some changes:
- Make the suppliers have methods returning the intermediate states
- To allow this, the suppliers constructor won't receive the chanells as params. Instead, its methods will ask for them
  - Most changes in this PR are because of this
- After those changes, I'm leaving AggregateMapper still there, as it still converts AggregateFunctions to its NamedExpressions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants