[fix](expr opt) Handle maximum date in function rewrite - #67815
Merged
Conversation
### What problem does this PR solve? Problem Summary: Rewriting DATE(datetime) greater than the maximum supported date attempted to construct the following day. That produced year 10000 and aborted query planning even though the original predicate is valid and can never be true for a non-null value. This change detects when the next day is outside the Doris date domain and simplifies the comparison to false while preserving NULL semantics. Normal dates continue to use the existing range rewrite. Tests cover legacy DATETIME, DATETIMEV2, nullable inputs, and the day immediately before the upper bound. ### Release note Fix planning failures for DATE comparisons at the maximum supported date. ### Check List (For Author) - Test: Unit Test and Regression Test - Behavior changed: Yes. An impossible upper-bound predicate is safely simplified instead of failing planning. - Does this need documentation: No
morrySnow
requested review from
924060929,
englefly and
starocean999
as code owners
September 10, 2026 12:16
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 16744 ms |
Contributor
TPC-DS: Total hot run time: 81822 ms |
Contributor
ClickBench: Total hot run time: 14.58 s |
starocean999
approved these changes
Sep 11, 2026
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.
What problem does this PR solve?
Problem Summary:
A valid comparison against the maximum supported date failed during planning:
DateFunctionRewritenormally convertsDATE(datetime) > date_literalinto a comparison with the beginning of the following day. For9999-12-31, constructing that bound creates year 10000, which is outside the Doris date domain and raisesdatetime out of range.The rewrite now detects when the following day is outside the supported range. Because no non-null
DATETIMEorDATETIMEV2value can have a date above the maximum date, it simplifies the predicate to false while preserving NULL semantics throughfalseOrNull. Other dates continue to use the existing range rewrite.Unit tests cover both datetime families, nullable values, and the preceding day. Regression tests reproduce the original planning failure for
DATETIMEandDATETIMEV2(6)and verify both filter and projection semantics.Release note
Fix planning failures for
DATEcomparisons at the maximum supported date.Check List (For Author)