Skip to content

ESQL: Remove create methods in aggs#144098

Merged
nik9000 merged 3 commits intoelastic:mainfrom
nik9000:esql_less_agg_code
Mar 12, 2026
Merged

ESQL: Remove create methods in aggs#144098
nik9000 merged 3 commits intoelastic:mainfrom
nik9000:esql_less_agg_code

Conversation

@nik9000
Copy link
Copy Markdown
Member

@nik9000 nik9000 commented Mar 12, 2026

I'm not sure what purpose they serve other than making people ask
"why do we have these?" Now that AI is pretty good at writing this
code, lets use it for great justice and remove this question.

I've also made the ctors package private. That forces folks building
them to do so through the "providers". Having "one way in" will
make things easier in the work I plan to do soon. And it fits the
theme of this change somewhat.

The vast, vast, vast majority of the code changes here are generated
code. If you want a flavor of the change look at, say,
AnyDoubleAggregationFunctionSupplier and
AnyDoubleGroupingAggregatorFunction.

@nik9000 nik9000 requested a review from mouhc1ne March 12, 2026 11:28
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Mar 12, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

// or more contributor license agreements. Licensed under the Elastic License
// 2.0; you may not use this file except in compliance with the Elastic License
// 2.0.
package org.elasticsearch.compute.aggregation;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for cleaning up these files.

this.state = state;
}

public static SpatialCentroidCartesianPointDocValuesAggregatorFunction create(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure why we had these create methods but they seem to be just one layer of abstraction that eventually calls the public constructor. If we short-circuit that and call the constructor directly, we just arrived at the same result from a shorter path, less code, especially if they're a nuisance to something else you're trying to achieve. This is a safe change imo, and a passing ungrouped/grouped agg function tests will seal the case for that.

builder.addStatement("this.warnings = warnings");
}
builder.addStatement("this.channels = channels");
builder.addStatement("this.state = $L", initState());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Would be nice to make the ungrouped/grouped agg implementors, and by consequence the code they generate, as similar as possible, for comparison/learning purposes. If you agree, we can declare the class members in the same order as in AggregatorImplementer; context, then channels, then state.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

👍

Let me do that in a follow up. Because it'll be another huge PR that you can scan over. Rather than merge into this one.

@nik9000 nik9000 enabled auto-merge (squash) March 12, 2026 13:50
@nik9000 nik9000 merged commit 89888b2 into elastic:main Mar 12, 2026
27 of 28 checks passed
szybia added a commit to szybia/elasticsearch that referenced this pull request Mar 12, 2026
…elocations

* upstream/main: (49 commits)
  CCS logging fixes (elastic#144070)
  Improve CPS cluster exclusion handling (elastic#143488)
  Remove snapshot condition now that node_reduce phase is in non-snapshot builds (elastic#144090)
  Drop deprecation warnings when updating a mapping in the cluster state applier (elastic#143884) (elastic#144040)
  Add ensureGreenAndNoInitializingShards helper (elastic#144044)
  Removed unnecessary applies_to blocks from deprecated query (elastic#144096)
  [CPS] Use single CrossProjectModeDecider instance (elastic#144030)
  Fix ESQL TS requests with LIMIT 0 (elastic#144031)
  ESQL: Remove `create` methods in aggs (elastic#144098)
  ES|QL: Refactor ChangeLimitOperator (elastic#144017)
  Add Paginated Hit Source Tests (elastic#142592)
  Fix test failure not preferred (elastic#144019)
  Remove serialization logic from EIS authorization response (elastic#144021)
  ESQL: CSV schema inference and parsing enhancements (elastic#144050)
  ESQL: Fix incorrectly optimized fork with nullify unmapped_fields (elastic#143030)
  Fix MMR release test using subqueries (elastic#144087)
  Refactoring `UserAgentPlugin` (elastic#140712)
  Drop non-finite samples in Prometheus remote write (elastic#144055)
  [TEST] Wait for internal inference indices to be created in authorization IT (elastic#143885)
  Disable ndjson datasource QA tests in release-tests (elastic#143992)
  ...
michalborek pushed a commit to michalborek/elasticsearch that referenced this pull request Mar 23, 2026
I'm not sure what purpose they serve other than making people ask
"why do we have these?" Now that AI is pretty good at writing this
code, lets use it for great justice and remove this question.

I've also made the ctors package private. That forces folks building
them to do so through the "providers". Having "one way in" will
make things easier in the work I plan to do soon. And it fits the
theme of this change somewhat.

The vast, vast, vast majority of the code changes here are generated
code. If you want a flavor of the change look at, say,
`AnyDoubleAggregationFunctionSupplier` and
`AnyDoubleGroupingAggregatorFunction`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants