Repository navigation
feat: use range partitioning for date_trunc aggregation - #2
Closed
benbellick wants to merge 4 commits into
Closed
benbellick wants to merge 4 commits into
benbellick wants to merge 4 commits into
Conversation
benbellick
changed the base branch from
main
to
fix/issue-25425-date-trunc-scalar-rounding
September 18, 2026 18:50
|
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 |
Owner
Author
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?
None. This is a fork-only preview for reviewing the combined change.
Rationale for this change
Grouped aggregation currently inserts a hash repartition when grouping by a monotonic transformation of a range-partitioned key, even when the concrete range boundaries keep every resulting group within one input partition.
What changes are included in this PR?
An argument-type-aware, default-deny audit capability enables only timezone-less
date_trunc. Concrete boundary analysis establishes group locality rather than general partition-layout compatibility, so it can be consumed by aggregation without authorizing co-partitioned joins.Aggregation enforcement and validation share one locality policy across combined and uncombined plans. Non-range arguments must be literals, and unsupported inputs, overlapping buckets, null or extreme boundaries, and evaluation errors fail closed.
date_bin, timezone-bearing timestamps, dynamic precision, grouping sets, and joins remain excluded.This preview is temporarily stacked on the scalar
date_trunccorrectness fix. That prerequisite will disappear from the optimization diff after it is available onmain.Are these changes tested?
Tests cover all timestamp units and supported granularities, fractional and pre-epoch values, calendar boundaries, nulls, extremes, ascending and descending ranges, compound keys, repeated optimization, uncombined aggregates, and join isolation. A table-driven harness evaluates actual arrays assigned to source ranges and verifies that accepted transformations have disjoint partition images.
The full extended workspace test suite, strict all-target/all-feature Clippy, and the targeted SQLLogicTest pass.
A reproducible Criterion benchmark over aligned hourly partitions measured approximately 35–36% lower execution time on two synthetic workloads by eliminating hash repartitioning.
Are there any user-facing changes?
Eligible grouped aggregations can avoid hash repartitioning. Public range-analysis and aggregate-locality APIs are added.
Note: This PR was developed with AI assistance. All changes have been reviewed, and I take full responsibility for this contribution.