You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "notashes (via GitHub)" <gi...@apache.org> on 2026/02/16 10:32:03 UTC
[PR] Fix/changing boundaries [datafusion]
notashes opened a new pull request, #20380:
URL: https://github.com/apache/datafusion/pull/20380
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Part of #20324 (dynamic filter update overhead for aggregates)
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
Right now `AggregateStream::maybe_update_dyn_filter()` unconditionally updates filter predicates after every batch even without any change. Which triggers predicate rebuilds for file pruners even though we converge towards the bounds quite early on.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
We only conditionally update filter predicates if the bounds change.
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
The existing test suits pass. The existing clickbench regression shows virtually no change.
<details>
<summary>Benchmark Results</summary>
The existing benchmarks don't reproduce this as it gets the data from stats. So we can use a trick like `"EventDate" + 0` to force full table scan.
```sql
SET datafusion.execution.parquet.binary_as_string = true;
SET datafusion.execution.parquet.pushdown_filters = false;
CREATE EXTERNAL TABLE hits STORED AS PARQUET LOCATION 'benchmarks/data/hits_partitioned';
CREATE VIEW hits_view AS SELECT "EventDate" + 0 AS "EventDate" FROM hits;
-- Warmup
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view;
-- dyn_off x5: hard-coded filter, dynamic filter disabled
SET datafusion.optimizer.enable_aggregate_dynamic_filter_pushdown = false;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view WHERE "EventDate" > 0 AND "EventDate" < 99999999;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view WHERE "EventDate" > 0 AND "EventDate" < 99999999;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view WHERE "EventDate" > 0 AND "EventDate" < 99999999;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view WHERE "EventDate" > 0 AND "EventDate" < 99999999;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view WHERE "EventDate" > 0 AND "EventDate" < 99999999;
-- dyn_on x5: dynamic filter enabled
SET datafusion.optimizer.enable_aggregate_dynamic_filter_pushdown = true;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view;
SELECT MIN("EventDate"), MAX("EventDate") FROM hits_view;
```
### Before (baseline)
| Iteration | dyn_off | dyn_on |
|-----------|---------|--------|
| 1 | 39ms | 44ms |
| 2 | 39ms | 44ms |
| 3 | 40ms | 44ms |
| 4 | 39ms | 45ms |
| 5 | 38ms | 45ms |
| **Avg** | **39.0ms** | **44.4ms** |
We can see that that it's a little slow to execute with dynamic filters on.
### After (this PR)
| Iteration | dyn_off | dyn_on |
|-----------|---------|--------|
| 1 | 40ms | 33ms |
| 2 | 41ms | 32ms |
| 3 | 40ms | 32ms |
| 4 | 42ms | 32ms |
| 5 | 39ms | 31ms |
| **Avg** | **40.4ms** | **32.0ms** |
And we get approx 20% boost with the patch (in my local setup)
</details>
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: update filter predicates for min/max aggregates only if bounds change [datafusion]
Posted by "adriangb (via GitHub)" <gi...@apache.org>.
adriangb merged PR #20380:
URL: https://github.com/apache/datafusion/pull/20380
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: update filter predicates for min/max aggregates only if bounds change [datafusion]
Posted by "notashes (via GitHub)" <gi...@apache.org>.
notashes commented on PR #20380:
URL: https://github.com/apache/datafusion/pull/20380#issuecomment-3907696275
cc: @adriangb
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org