Repository navigation
feat: reuse range partitioning for date_trunc aggregation - #26449
Open
benbellick wants to merge 49 commits into
Open
benbellick wants to merge 49 commits into
benbellick wants to merge 49 commits into
Conversation
Mark intentional expression hash keys with narrowly scoped lint expectations. Interior-mutable memory accounting does not affect expression hashing or equality.
Reject malformed effective split points before proving transformed-key locality. Cover uncombined aggregation, repeated optimization, incompatible join layouts, and grouping-set subtotals with executable regressions.
benbellick
force-pushed
the
feat/issue-25344-range-transform-locality
branch
from
October 17, 2026 16:32
2a0b4f5 to
a6482e5
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #26449 +/- ##
==========================================
+ Coverage 82.89% 82.92% +0.02%
==========================================
Files 1154 1154
Lines 457630 458406 +776
Branches 457630 458406 +776
==========================================
+ Hits 379370 380114 +744
- Misses 55256 55267 +11
- Partials 23004 23025 +21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
Closes #26448.
Related to #23569, #25344, and #25345.
Rationale for this change
This PR implements a focused subset of the optimization in Nga's PR #24501 for a known-safe case. The plan is to iteratively expand support to more safe cases, following Gene's review feedback.
Suppose
eventsis range-partitioned ontimestamp, with partitions split at hourly boundaries.Each
(key, hour)group belongs entirely to one input partition. The simplified physical plans below omit projections and usehourfor the grouping expression.Without the optimization
With the optimization
The new locality check is specific to aggregates. General distribution satisfaction and join-layout checks are unchanged.
What changes are included in this PR?
Add a default-deny capability that identifies functions and argument types safe for range-key analysis. Check expression ordering and arguments, then evaluate both sides of each split to prove groups stay within partitions.
The optimizer calls it through this path.
flowchart TD A["EnsureRequirements checks aggregate input"] --> B["AggregateExec::input_keeps_groups_local"] B --> C["Partitioning::keeps_keys_local"] C --> D{"Function admitted, expression supported, and split boundaries safe?"} D -->|Yes| E["Can skip the aggregate hash shuffle"] D -->|No or unknown| F["Retain normal repartitioning"]Support is intentionally limited to timezone-less
date_truncover single-key timestamp ranges, with literal non-range arguments.date_binremains excluded pending its safety audit, including null behavior. Compound range keys remain follow-up work in #24644.Keep the shuffle when buckets cross partitions or the checks fail. Grouping sets still use the existing distribution checks.
What is the testing strategy for this PR?
Added multiple unit and integration tests.
I'm happy to add a benchmark if maintainers would find it useful.
Are there any user-facing changes?
Eligible
date_truncaggregations can skip a hash shuffle. Results are unchanged.Note: This PR was developed with AI assistance. All changes have been reviewed, and I take full responsibility for this contribution.