morrySnow opened a new pull request, #67815:
URL: https://github.com/apache/doris/pull/67815

   ### What problem does this PR solve?
   
   Problem Summary:
   
   A valid comparison against the maximum supported date failed during planning:
   
   ```sql
   EXPLAIN SELECT * FROM t_datetime
   WHERE DATE(dt) > '9999-12-31';
   ```
   
   `DateFunctionRewrite` normally converts `DATE(datetime) > date_literal` into 
a comparison with the beginning of the following day. For `9999-12-31`, 
constructing that bound creates year 10000, which is outside the Doris date 
domain and raises `datetime out of range`.
   
   The rewrite now detects when the following day is outside the supported 
range. Because no non-null `DATETIME` or `DATETIMEV2` value can have a date 
above the maximum date, it simplifies the predicate to false while preserving 
NULL semantics through `falseOrNull`. 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 `DATETIME` 
and `DATETIMEV2(6)` and verify both filter and projection semantics.
   
   ### 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to