Skip to content

Conversation

@ivancea
Copy link
Contributor

@ivancea ivancea commented Jun 19, 2025

Minor change plus a test to ensure we check that code path.

Basically, we were doing a value.isNull() for each group the value had to be aggregated in, instead of doing it just once at the beginning.

The affectation goes as follows:

  • 1 group, null value: We avoid some extra lightweight calls
  • N groups, null value: We avoid calling it N times
  • No groups, or non-null value: No effect

I don't expect this to notably improve aggs, but it was something like a quick-win

@ivancea ivancea requested a review from nik9000 June 19, 2025 12:51
@ivancea ivancea added >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.1.0 labels Jun 19, 2025
@elasticsearchmachine
Copy link
Collaborator

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

}

var intArray = blockFactory.bigArrays().newIntArray(totalValues);
for (int i = 0; i < block.getPositionCount(); i++) {
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 was a bug in the randomizer, which apparently wasn't triggering before

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch

@tylerperk tylerperk changed the title [ESQL] Shortcitcuit grouping aggs on null value [ESQL] Shortcircuit grouping aggs on null value Jun 24, 2025
Copy link
Contributor

@luigidellaquila luigidellaquila left a comment

Choose a reason for hiding this comment

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

👍

}

var intArray = blockFactory.bigArrays().newIntArray(totalValues);
for (int i = 0; i < block.getPositionCount(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch

@ivancea ivancea enabled auto-merge (squash) July 10, 2025 09:20
@ivancea ivancea merged commit 7380179 into elastic:main Jul 10, 2025
33 checks passed
@ivancea ivancea deleted the esql-grouping-aggs-null-check-move branch July 10, 2025 12:35
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 17, 2025
Minor aggregators change plus a test to ensure we check that code path.

We were doing a `value.isNull()` for each group the value had to be aggregated in, instead of doing it just once at the beginning.

The affectation goes as follows:
- 1 group, null value: We avoid some extra lightweight calls
- N groups, null value: We avoid calling it N times
- No groups, or non-null value: No effect
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 17, 2025
Minor aggregators change plus a test to ensure we check that code path.

We were doing a `value.isNull()` for each group the value had to be aggregated in, instead of doing it just once at the beginning.

The affectation goes as follows:
- 1 group, null value: We avoid some extra lightweight calls
- N groups, null value: We avoid calling it N times
- No groups, or non-null value: No effect
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.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants