[Enhancement] Enable zone-map pruning for date_trunc predicates - #79021
[Enhancement] Enable zone-map pruning for date_trunc predicates#79021zhangyaqi1989 wants to merge 1 commit into
Conversation
Signed-off-by: Yaqi Zhang <y.zhang@celonis.com>
4236d52 to
9ec1796
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 1 / 1 (100.00%) file detail
|
|



Why I'm doing:
Predicates such as
date_trunc('day', ts) = '2026-09-10'reach the scan as expression predicates, butDATE_TRUNCis missing from the FE's monotonic-function allowlist. The BE therefore cannot use the expression for zone-map pruning.What I'm doing:
Add
DATE_TRUNCto the existing allowlist. Its unit is already required to be a constant by function analysis, and truncation preserves timestamp ordering. The existing recursive check still rejects non-monotonic child expressions; the BE already handles equality by deriving>=and<=zone-map predicates.Add a serialization regression test covering DATE/DATETIME units, nullable and non-nullable columns, equality and range predicates, and a non-monotonic CASE input.
Related issue: none.
Validation
Confirmed the new regression fails on unmodified upstream:
DATE: day ==> expected: <true> but was: <false>.With the fix,
ExprToThriftTestpasses: 2 tests, 0 failures/errors. Run in a Linux ARM64 container with JDK 17:Checked truncation ordering with synthetic NULL, minimum/maximum date, leap-day, and subsecond inputs on a local StarRocks instance. These are boundary sanity checks; the regression above verifies the changed upstream serialization path.
mvn -B -ntp -pl fe-core checkstyle:check: passed with 0 violations.Reproducer
Observability: reviewed the existing
RawRowsRead,ReadPagesNum, andZoneMapIndexFilterRowsscan-profile counters. They already expose the pruning improvement and remain unchanged; no new metrics are needed.What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Eligible DATE_TRUNC predicates can prune additional pages. SQL results and configuration interfaces are unchanged.
Checklist:
Bugfix cherry-pick branch check: