-
Notifications
You must be signed in to change notification settings - Fork 25.5k
[ESQL] Plug TopN agg groupings filtering into the language #130111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…cs, and added it to benchmark
# Conflicts: # x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/BlockHashTests.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unrelated fix, as this class wasn't overriding those methods. I will move this to another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR opened with this: #130218
aggregatorFactories, | ||
context.pageSize(ts.estimatedRowSize()) | ||
context.pageSize(ts.estimatedRowSize()), | ||
context.queryPragmas().maxTopNAggsLimit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we inject the pragma
# Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/mapper/Mapper.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LocalPhysicalPlanOptimizerTests.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java
# Conflicts: # x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/OrdinalsGroupingOperator.java # x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/OperatorTests.java # x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/HashAggregationOperatorTests.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/AbstractPhysicalOperationProviders.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/TestPhysicalOperationProviders.java
Continuation of #127148
Depends on #129633 (Bug fix)
The first PR added a new
TopNBlockHash
that skips non-topN groups for specific cases (TopN
afterAggregate
, sharing the same attributes for groups/order).This PR plugs it into the language:
TopN
+Aggregate
toTopNAggregate
. This is done at the very end, so other logical rules remain unchangedTopNAggregate
toTopNAggregateExec
TopN
is converted toLimit
andSort
at the beginning, here we do the same convertingTopNAggregate
toTopN
andAggregate
TopNAggregateExec
is a child class ofAggregateExec
, so most rules still apply. Some other were updatedAlso, a new pragma was added (
max_top_n_aggs_limit
) to limit the maximum TopN limit after which the TopNBlockHash will be used. This is temporary until we use better index statistics.Draft
TopNAggregate
can't be serialized to older nodes. This must be fixed before merging.Future changes
OrdinalsGroupingOperator
to use the pragma for its BlockHash, if it makes sense