Skip to content

consider date_bin in range partition satisfaction - #23536

Closed
jayshrivastava wants to merge 3 commits into
apache:mainfrom
jayshrivastava:js/make-date-bin-range-aware
Closed

consider date_bin in range partition satisfaction#23536
jayshrivastava wants to merge 3 commits into
apache:mainfrom
jayshrivastava:js/make-date-bin-range-aware

Conversation

@jayshrivastava

@jayshrivastava jayshrivastava commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

When a projection calls date_bin on a column used in a Partitioning::Range expression, the projection should preserve the Partitioning. This enables the optimizer to use the partitioning property in later plan nodes.

Example 1

ordering = [timestamp ASC]

  split points = [
      (2024-01-01 10:00),
      (2024-01-01 11:00),
  ]

Projecting date_bin(15 minutes, 10:00) as time_bin allows us to safely preserve the partitioning on the new expression:

ordering = [time_bin ASC]

  split points = [
      (2024-01-01 10:00),
      (2024-01-01 11:00),
  ]

This can be done without repartitioning as long as the date_bin "widow" does not cross any split points and is smaller than all of the ranges. For example, these would not work in this scenario:

  • date_bin(16 minutes, 10:00) as time_bin
  • date_bin(2 hours, 10:00) as time_bin

When the range partitioning tuple expression is on multiple columns, we fallback to the current behavior, using UnknownPartitioning.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) physical-plan Changes to the physical-plan crate labels Jul 13, 2026
@jayshrivastava jayshrivastava changed the title wip consider date_bin in range partition satisfaction Jul 14, 2026
@github-actions github-actions Bot added logical-expr Logical plan and expressions functions Changes to functions implementation labels Jul 21, 2026
@jayshrivastava

Copy link
Copy Markdown
Contributor Author

Closed in favor of #24501 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Changes to the physical-expr crates physical-plan Changes to the physical-plan crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant