Repository navigation
feat: reuse range partitioning for audited date_bin aggregation - #26835
jayzhan211 merged 14 commits into
Conversation
|
cc @NGA-TRAN @jayzhan211 This is extending the previous work on |
NGA-TRAN
left a comment
There was a problem hiding this comment.
Looks great. I just have a minor comment. Thanks @benbellick
| 06)----------DataSourceExec: file_groups={2 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch_range_partitioning/range_sorted_time_bin/part-0.parquet], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch_range_partitioning/range_sorted_time_bin/part-1.parquet]]}, projection=[key, col4, timestamp, value], output_ordering=[key@0 ASC, timestamp@2 ASC], output_partitioning=Range([timestamp@2 ASC], [(1704070800000000000)], 2), file_type=parquet, predicate=col4@4 = a, pruning_predicate=col4_null_count@2 != row_count@3 AND col4_min@0 <= a AND a <= col4_max@1, required_guarantees=[col4 in (a)] | ||
| 02)--AggregateExec: mode=SinglePartitioned, gby=[key@0 as key, date_bin(IntervalMonthDayNano { months: 0, days: 0, nanoseconds: 60000000000 }, timestamp@1) as date_bin(IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 0, nanoseconds: 60000000000 }"),range_sorted_time_bin.timestamp)], aggr=[sum(range_sorted_time_bin.value)], group_clustering_mode=Full | ||
| 03)----FilterExec: col4@1 = a, projection=[key@0, timestamp@2, value@3] | ||
| 04)------DataSourceExec: file_groups={2 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch_range_partitioning/range_sorted_time_bin/part-0.parquet], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch_range_partitioning/range_sorted_time_bin/part-1.parquet]]}, projection=[key, col4, timestamp, value], output_ordering=[key@0 ASC, timestamp@2 ASC], output_partitioning=Range([timestamp@2 ASC], [(1704070800000000000)], 2), file_type=parquet, predicate=col4@4 = a, pruning_predicate=col4_null_count@2 != row_count@3 AND col4_min@0 <= a AND a <= col4_max@1, required_guarantees=[col4 in (a)] |
| # An explicit origin remains outside the audited slice, even when it is | ||
| # the epoch and produces the same bins as the two-argument expression. | ||
| ########## |
There was a problem hiding this comment.
Do do think this comment will be clearer?
| # An explicit origin remains outside the audited slice, even when it is | |
| # the epoch and produces the same bins as the two-argument expression. | |
| ########## | |
| # This PR enables shuffle removal only for two-argument date_bin calls. | |
| # A three-argument call therefore retains the shuffle, even when its | |
| # explicit epoch origin produces identical bins and would be safe. | |
| ########## |
Do you plan to support this sometime; or maybe open a ticket for it?
There was a problem hiding this comment.
I opened a ticket for it and added a reference to it in the comment. Thanks!
jayzhan211
left a comment
There was a problem hiding this comment.
@benbellick thanks for extending this to date_bin! The admission logic looks right to me. My main ask is inline: could you fold the literal arguments into the existing, still-unreleased hook instead of adding a second one? The other inline comment is optional.
|
Thank you for opening this pull request! Reviewer note: 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 |
|
@jayzhan211 Thanks for the review :) just updated everything! |
|
Thanks @benbellick @NGA-TRAN ! |
Which issue does this PR close?
Closes #25344.
Closes #25345.
This completes the initial single-key work alongside #26449. Explicit origins (#26913) and compound range keys (#24644) remain follow-ups.
Rationale for this change
Extend the aggregate-locality optimization from #26449 to
date_bin. When bins stay within timestamp range partitions, aggregation can skip the hash shuffle.What changes are included in this PR?
Pass literal argument values to the existing admission hook.
INTERVAL '1 hour'andINTERVAL '1 month'have the sameIntervalMonthDayNanotype, so types alone cannot distinguish them. Inspecting the literal value letsdate_binrequire a positive fixed-duration stride without months, treating each day as 24 hours.date_trunccontinues to rely only on argument types.Initially, admit only two-argument calls over timezone-less nanosecond timestamps, using that literal stride. Explicit origins and other types remain excluded.
For example:
For ascending timestamp ranges:
01:00separates hourly bins, so the shuffle can be skipped.01:30cuts through the01:00bin, so the shuffle remains.Every split must pass the existing boundary proof. Evaluation errors conservatively retain the shuffle. This follows the NULL-to-error fix in #26607.
What is the testing strategy for this PR?
Unit tests cover admission, hook forwarding, ascending/descending boundaries, and evaluation errors. SQLLogicTests verify plans and results for aligned bins, crossing bins, and excluded explicit origins.
Are there any user-facing changes?
Eligible
date_binaggregations can avoid a hash shuffle. Function results are unchanged.Note: This PR was developed with AI assistance. All changes have been reviewed, and I take full responsibility for this contribution.