Skip to content

[ES|QL] Any-value aggregators#143619

Merged
mouhc1ne merged 7 commits intoelastic:mainfrom
mouhc1ne:any-value-aggregators
Mar 5, 2026
Merged

[ES|QL] Any-value aggregators#143619
mouhc1ne merged 7 commits intoelastic:mainfrom
mouhc1ne:any-value-aggregators

Conversation

@mouhc1ne
Copy link
Copy Markdown
Contributor

@mouhc1ne mouhc1ne commented Mar 4, 2026

  • Create an any-value agg string template and use it to generate an aggregator for all supported types.
  • These aggregators read from one channel only, and are invoked from FIRST/LAST whenever the sort field is null-typed or is foldable, because in such case we're happy getting back any value from the search field.
  • They can be used whenever it is irrelevant which value we get as long as we get one from the field. To not confuse with getting back a random value, because this isn't really random; the aggregator will return the first value encountered, whether it was null, single-valued or multi-valued.
  • Create grouped/ungrouped agg functions unit tests.

mouhc1ne added 2 commits March 4, 2026 16:28
- Create an "any-value" agg string template and use it to generate an aggregator for all supported types.
- These aggregators read from one channel only, and are invoked from FIRST/LAST whenever the sort field is null-typed or is foldable, because in such case we're happy getting back any value from the search field.
- They can be used whenever it is irrelevant which value we get as long as we get one from the field. To not confuse with getting back a random value, because this isn't really random; the aggregator will return the first value encountered, whether it was null, single-valued or multi-valued.
- Create grouped/ungrouped agg functions unit tests.
@mouhc1ne mouhc1ne self-assigned this Mar 4, 2026
@mouhc1ne mouhc1ne added >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL labels Mar 4, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@mouhc1ne mouhc1ne linked an issue Mar 4, 2026 that may be closed by this pull request
@mouhc1ne mouhc1ne requested a review from nik9000 March 4, 2026 21:37
@mouhc1ne mouhc1ne assigned dnhatn and unassigned dnhatn Mar 4, 2026
@mouhc1ne mouhc1ne requested review from alex-spies and dnhatn March 4, 2026 21:38
Copy link
Copy Markdown
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

Heya, I reviewed only the spec tests to check in on the general behavior. That looks correct and very nice to me. I left some minor test suggestions, only, but realize that the bulk of it should be tested via aggs (unit) tests.

mouhc1ne added 5 commits March 5, 2026 08:17
# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
- Add supplier dispatch logic to LAST
- Add csv test where FIRST is the pipeline breaker
- Pass more types
for (int i = 0; i < count; ++i) {
groupValues.set(i, valuesBlock.get$v_Type$(i + offset));
}
$endif$
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's easier to read these if they are pulled all the way to the left. Like, then the "control" stuff is out of the way of the code. Mostly.

@mouhc1ne mouhc1ne merged commit 5fafabc into elastic:main Mar 5, 2026
35 checks passed
spinscale pushed a commit to spinscale/elasticsearch that referenced this pull request Mar 6, 2026
- Create an "any-value" agg string template and use it to generate an aggregator for all supported types.
- These aggregators read from one channel only, and are invoked from FIRST/LAST whenever the sort field is null-typed or is foldable, because in such case we're happy getting back any value from the search field.
- They can be used whenever it is irrelevant which value we get as long as we get one from the field. To not confuse with getting back a random value, because this isn't really random; the aggregator will return the first value encountered, whether it was null, single-valued or multi-valued.
- Create grouped/ungrouped agg functions unit tests.
sidosera pushed a commit to sidosera/elasticsearch that referenced this pull request Mar 6, 2026
- Create an "any-value" agg string template and use it to generate an aggregator for all supported types.
- These aggregators read from one channel only, and are invoked from FIRST/LAST whenever the sort field is null-typed or is foldable, because in such case we're happy getting back any value from the search field.
- They can be used whenever it is irrelevant which value we get as long as we get one from the field. To not confuse with getting back a random value, because this isn't really random; the aggregator will return the first value encountered, whether it was null, single-valued or multi-valued.
- Create grouped/ungrouped agg functions unit tests.
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 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.

Channels issue when an agg is called with the same field

5 participants