POC: Support dynamic filter in MIN/MAX aggregates
#18579
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
Background for dynamic filter: https://datafusion.apache.org/blog/2025/09/10/dynamic-filters/
The following queries can be used for quick global insights:
Now Q1 can get executed very efficiently by directly check the file metadata if possible:
However for Q2 now it's still doing the whole scan, and it's possible to use dynamic filters to speed them up.
Benchmarking Q2
Setup
tpchgen-cli -s 100 --format=parquet(https://github.com/clflushopt/tpchgen-rs/tree/main/tpchgen-cli)Result
Main: 0.55s
PR: 0.09s
Rationale
What changes are included in this PR?
This PR has not finish yet, the above demo is working, but I plan to do cleanups and tests afterwards, now I would like to get some early feedbacks on the PoC.
The goal is is to let aggregate expressions
MIN/MAXwith only column reference as argument (e.g. min(col1)) support dynamic filter, the above implementation rationale has explained it further.The implementation includes:
AggrDynFilterstruct, and it would be shared across different partition streams to store the current bounds for dynamic filter update.init_dynamic_filteris responsible checking the conditions for whether to enable dynamic filter in the current aggregate execution plan, and finally build theAggrDynFilterinside the operator.gather_filters_for_pushdownandhandle_child_pushdown_resultAPI inAggregateExecto enable self dynamic filter generation and pushdown.TODOs:
Add a configuration to turn it on and off
Comprehensive tests
Cleanup and more comments
Are these changes tested?
Not yet
Are there any user-facing changes?
No