Skip to content

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Aug 3, 2025

Adds support for multiple parameters to ungrouped aggregations.

Relates to #108385

Adds support for multiple parameters to ungrouped aggregations. Relates to elastic#108385
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Aug 3, 2025
@nik9000
Copy link
Member Author

nik9000 commented Aug 3, 2025

This should add support for something like | STATS AGG(foo, bar). It works on my private branch working on FIRST and LAST.

The changes to the generated files pretty much just renaming variables and moving some if statements to methods describing what they are doing.

If the foo or bar are multivalued then the agg receives the combinatorial explosion of the values. That's fine for FIRST and LAST which is what I'm working towards now.

If either foo or bar are null, then the agg receives no values.

Copy link
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 Nik!

@nik9000
Copy link
Member Author

nik9000 commented Aug 4, 2025

This is what it looks like for multivalued fields:

 private void addRawVector(LongVector timestampVector, DoubleVector valueVector) { state.seen(true); for (int i = 0; i < timestampVector.getPositionCount(); i++) { long timestampValue = timestampVector.getLong(i); double valueValue = valueVector.getDouble(i); FirstOverTimeDoubleAggregator.combine(state, timestampValue, valueValue); } } private void addRawBlock(LongBlock timestampBlock, DoubleBlock valueBlock) { for (int p = 0; p < timestampBlock.getPositionCount(); p++) { if (timestampBlock.isNull(p)) { continue; } if (valueBlock.isNull(p)) { continue; } state.seen(true); int timestampStart = timestampBlock.getFirstValueIndex(p); int timestampEnd = timestampStart + timestampBlock.getValueCount(p); for (int timestampOffset = timestampStart; timestampOffset < timestampEnd; timestampOffset++) { long timestampValue = timestampBlock.getLong(timestampOffset); int valueStart = valueBlock.getFirstValueIndex(p); int valueEnd = valueStart + valueBlock.getValueCount(p); for (int valueOffset = valueStart; valueOffset < valueEnd; valueOffset++) { double valueValue = valueBlock.getDouble(valueOffset); FirstOverTimeDoubleAggregator.combine(state, timestampValue, valueValue); } } } } 
@nik9000 nik9000 merged commit 3fea67d into elastic:main Aug 4, 2025
33 checks passed
@nik9000
Copy link
Member Author

nik9000 commented Aug 4, 2025

Thanks @dnhatn and @idegtiarenko .

szybia added a commit to szybia/elasticsearch that referenced this pull request Aug 5, 2025
…cking * upstream/main: (26 commits) [Fleet] add privileges to `kibana_system` to read integrations data (elastic#132400) Add `TestEntitlementsRule` with support for dynamic entitled node paths for testing (elastic#132077) Reduce logging frequency for GCS per project clients (elastic#132429) Skip update/100_synthetic_source tests in yamlRestCompatTests (elastic#132296) Correct exception for missing nested path (elastic#132408) Fixing esql release tests elastic#132369 (elastic#132406) Adjust date docvalue formatting to return 4xx instead of 5xx (elastic#132414) Handle nested fields with the termvectors REST API in artificial docs (elastic#92568) Only collect bulk scored vectors when exceeding min competitive (elastic#132293) Fix release tests diskbbq update (elastic#132405) ESQL: Fix skipping of generative tests (elastic#132390) Short circuit failure handling in OIDC flow (elastic#130618) Small optimization in OptimizedScalarQuantizer by using mul instead of div (elastic#132397) Aggs: Add validation to Bucket script pipeline agg (elastic#132320) ESQL: Multiple parameters in ungrouped aggs (elastic#132375) ESQL: Explain test operators (elastic#132374) EQL: Deal with internally created IN in a different way for EQL (elastic#132167) Speed up hierarchical k-means by computing distances in bulk (elastic#132384) Reduce the number of fields per document (elastic#132322) Assert current thread in ESQL (elastic#132324) ...
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) v9.2.0

4 participants