You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "adriangb (via GitHub)" <gi...@apache.org> on 2026/09/24 04:31:41 UTC

[PR] feat: mark hash join, TopK and aggregate dynamic filters as optional [datafusion]

adriangb opened a new pull request, #25681:
URL: https://github.com/apache/datafusion/pull/25681

   ## Which issue does this PR close?
   
   - Part of #22883 (experimental "optional filters" stack, design notes: https://claude.ai/artifact/SSz7t6hPyhFWp1MDPecVqt).
   - **Depends on #25673.** Review only the top two commits.
   
   ## Rationale for this change
   
   Dynamic filters from `HashJoinExec`, TopK (`SortExec` with a fetch) and `AggregateExec` are not needed for correctness: the producer checks the same condition again. #25673 adds `OptionalFilterPhysicalExpr` to state this. This PR makes the producers use it, so that consumers (#25674 and the Parquet / `FilterExec` PRs on top) can skip these filters when they do not remove enough rows.
   
   ## What changes are included in this PR?
   
   - The pushed copy of the dynamic filter is wrapped as `Optional(DynamicFilter [...])` in:
     - `HashJoinExec::gather_filters_for_pushdown` (probe side self filter),
     - `SortExec::gather_filters_for_pushdown` (TopK),
     - `AggregateExec::gather_filters_for_pushdown`.
   
     Each producer keeps its own unwrapped `Arc<DynamicFilterPhysicalExpr>` for `update()` / `mark_complete()`.
   - Hash join key transfer (#25255) rewrites below the wrapper, so a transferred dynamic filter stays optional. A transferred *parent* filter stays required: for inner and semi joins it replaces the original filter.
   - Direct downcasts now look through the wrapper (`as_dynamic_filter`): hash join consumer detection in `handle_child_pushdown_result` (#24601) and the dynamic filter routing in `NestedLoopJoinExec`.
   - `ParquetSource::try_pushdown_filters` calls `debug_assert_optional_on_root_chain` on its stored predicate.
   
   **No behavior change**: the wrapper evaluates its child. Only `EXPLAIN` text changes.
   
   ## What is the testing strategy for this PR?
   
   - New unit tests: `test_pushed_dynamic_filters_are_optional` (hash join self filter and key transfer), `test_nlj_routes_optional_dynamic_filter`.
   - The #24601 consumer detection tests pass unchanged.
   - Proto round trips for hash join, TopK and aggregate plans check that the scan predicate stays `Optional` and that the producer and scan still share one dynamic filter.
   - Snapshot updates: 11 inline snapshots in `filter_pushdown.rs` and 18 `.slt` files. A script checked that every changed line equals the old line once the `Optional(...)` wrapper is removed. The tree `EXPLAIN` format does not show the wrapper.
   - Full sqllogictest suite, `core_integration`, `parquet_integration`, and the physical-plan, proto, datasource-parquet, physical-optimizer and pruning crate tests pass.
   
   ## Are there any user-facing changes?
   
   `EXPLAIN` shows `Optional(DynamicFilter [...])` for pushed dynamic filters. Code outside this repository that downcasts a pushed-down predicate directly to `DynamicFilterPhysicalExpr` must now look through the wrapper (use `datafusion_physical_expr::utils::as_dynamic_filter`). This may need an upgrade guide note.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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] feat: mark hash join, TopK and aggregate dynamic filters as optional [datafusion]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25681:
URL: https://github.com/apache/datafusion/pull/25681#issuecomment-5807875200

   <!-- semver-check-comment -->
   Thank you for opening this pull request!
   
   Reviewer note: [cargo-semver-checks](https://github.com/obi1kenobi/cargo-semver-checks) reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).
   
   <details>
   <summary>Details</summary>
   
   ```
        Cloning apache/main
       Building datafusion v55.1.0 (current)
          Built [  79.948s] (current)
        Parsing datafusion v55.1.0 (current)
         Parsed [   0.036s] (current)
       Building datafusion v55.1.0 (baseline)
          Built [  64.232s] (baseline)
        Parsing datafusion v55.1.0 (baseline)
         Parsed [   0.038s] (baseline)
       Checking datafusion v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.591s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [ 177.407s] datafusion
       Building datafusion-datasource-parquet v55.1.0 (current)
          Built [  53.389s] (current)
        Parsing datafusion-datasource-parquet v55.1.0 (current)
         Parsed [   0.036s] (current)
       Building datafusion-datasource-parquet v55.1.0 (baseline)
          Built [  51.682s] (baseline)
        Parsing datafusion-datasource-parquet v55.1.0 (baseline)
         Parsed [   0.037s] (baseline)
       Checking datafusion-datasource-parquet v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.175s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [ 106.465s] datafusion-datasource-parquet
       Building datafusion-physical-expr v55.1.0 (current)
          Built [  30.313s] (current)
        Parsing datafusion-physical-expr v55.1.0 (current)
         Parsed [   0.050s] (current)
       Building datafusion-physical-expr v55.1.0 (baseline)
          Built [  29.923s] (baseline)
        Parsing datafusion-physical-expr v55.1.0 (baseline)
         Parsed [   0.050s] (baseline)
       Checking datafusion-physical-expr v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.322s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [  61.497s] datafusion-physical-expr
       Building datafusion-physical-plan v55.1.0 (current)
          Built [  39.988s] (current)
        Parsing datafusion-physical-plan v55.1.0 (current)
         Parsed [   0.174s] (current)
       Building datafusion-physical-plan v55.1.0 (baseline)
          Built [  39.699s] (baseline)
        Parsing datafusion-physical-plan v55.1.0 (baseline)
         Parsed [   0.176s] (baseline)
       Checking datafusion-physical-plan v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.727s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [  82.052s] datafusion-physical-plan
       Building datafusion-proto v55.1.0 (current)
          Built [  57.395s] (current)
        Parsing datafusion-proto v55.1.0 (current)
         Parsed [   0.017s] (current)
       Building datafusion-proto v55.1.0 (baseline)
          Built [  57.761s] (baseline)
        Parsing datafusion-proto v55.1.0 (baseline)
         Parsed [   0.019s] (baseline)
       Checking datafusion-proto v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.115s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [ 117.182s] datafusion-proto
       Building datafusion-proto-models v55.1.0 (current)
          Built [  26.581s] (current)
        Parsing datafusion-proto-models v55.1.0 (current)
         Parsed [   0.134s] (current)
       Building datafusion-proto-models v55.1.0 (baseline)
          Built [  26.123s] (baseline)
        Parsing datafusion-proto-models v55.1.0 (baseline)
         Parsed [   0.134s] (baseline)
       Checking datafusion-proto-models v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   1.833s] 223 checks: 222 pass, 1 fail, 0 warn, 31 skip
   
   --- failure enum_variant_added: enum variant added on exhaustive enum ---
   
   Description:
   A publicly-visible enum without #[non_exhaustive] has a new variant.
           ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
          impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/enum_variant_added.ron
   
   Failed in:
     variant ExprType:OptionalFilter in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1686
     variant ExprType:OptionalFilter in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1686
   
        Summary semver requires new major version: 1 major and 0 minor checks failed
       Finished [  55.993s] datafusion-proto-models
       Building datafusion-pruning v55.1.0 (current)
          Built [  42.515s] (current)
        Parsing datafusion-pruning v55.1.0 (current)
         Parsed [   0.016s] (current)
       Building datafusion-pruning v55.1.0 (baseline)
          Built [  43.393s] (baseline)
        Parsing datafusion-pruning v55.1.0 (baseline)
         Parsed [   0.016s] (baseline)
       Checking datafusion-pruning v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.087s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [  87.061s] datafusion-pruning
       Building datafusion-sqllogictest v55.1.0 (current)
          Built [ 108.022s] (current)
        Parsing datafusion-sqllogictest v55.1.0 (current)
         Parsed [   0.024s] (current)
       Building datafusion-sqllogictest v55.1.0 (baseline)
          Built [ 109.679s] (baseline)
        Parsing datafusion-sqllogictest v55.1.0 (baseline)
         Parsed [   0.023s] (baseline)
       Checking datafusion-sqllogictest v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.102s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [ 220.480s] datafusion-sqllogictest
   ```
   
   </details>


-- 
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] feat: mark hash join, TopK and aggregate dynamic filters as optional [datafusion]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #25681:
URL: https://github.com/apache/datafusion/pull/25681#issuecomment-5807954849

   ## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/25681?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `78.65613%` with `108 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 82.48%. Comparing base ([`95bb0a0`](https://app.codecov.io/gh/apache/datafusion/commit/95bb0a0dfa48ca20d017faa55b2fc96ee2f300fe?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`11d48c2`](https://app.codecov.io/gh/apache/datafusion/commit/11d48c2b03f9ed05496d9022367e2801da1758fc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/datafusion/pull/25681?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [datafusion/proto-models/src/generated/pbjson.rs](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&filepath=datafusion%2Fproto-models%2Fsrc%2Fgenerated%2Fpbjson.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9wcm90by1tb2RlbHMvc3JjL2dlbmVyYXRlZC9wYmpzb24ucnM=) | 0.00% | [57 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...n/physical-expr/src/expressions/optional\_filter.rs](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&filepath=datafusion%2Fphysical-expr%2Fsrc%2Fexpressions%2Foptional_filter.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1leHByL3NyYy9leHByZXNzaW9ucy9vcHRpb25hbF9maWx0ZXIucnM=) | 79.53% | [17 Missing and 18 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...tafusion/physical-plan/src/joins/hash\_join/exec.rs](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&filepath=datafusion%2Fphysical-plan%2Fsrc%2Fjoins%2Fhash_join%2Fexec.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1wbGFuL3NyYy9qb2lucy9oYXNoX2pvaW4vZXhlYy5ycw==) | 90.90% | [3 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [datafusion/physical-expr/src/utils/mod.rs](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&filepath=datafusion%2Fphysical-expr%2Fsrc%2Futils%2Fmod.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1leHByL3NyYy91dGlscy9tb2QucnM=) | 96.94% | [1 Missing and 3 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...fusion/physical-plan/src/joins/nested\_loop\_join.rs](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&filepath=datafusion%2Fphysical-plan%2Fsrc%2Fjoins%2Fnested_loop_join.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1wbGFuL3NyYy9qb2lucy9uZXN0ZWRfbG9vcF9qb2luLnJz) | 86.66% | [2 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [datafusion/physical-expr/src/simplifier/mod.rs](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&filepath=datafusion%2Fphysical-expr%2Fsrc%2Fsimplifier%2Fmod.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1leHByL3NyYy9zaW1wbGlmaWVyL21vZC5ycw==) | 88.88% | [0 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [datafusion/proto/src/physical\_plan/from\_proto.rs](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&filepath=datafusion%2Fproto%2Fsrc%2Fphysical_plan%2Ffrom_proto.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9wcm90by9zcmMvcGh5c2ljYWxfcGxhbi9mcm9tX3Byb3RvLnJz) | 0.00% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25681?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##             main   #25681      +/-   ##
   ==========================================
   - Coverage   82.48%   82.48%   -0.01%     
   ==========================================
     Files        1140     1141       +1     
     Lines      437614   438114     +500     
     Branches   437614   438114     +500     
   ==========================================
   + Hits       360986   361380     +394     
   - Misses      54834    54910      +76     
   - Partials    21794    21824      +30     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/25681?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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