github-actions[bot] commented on code in PR #65319:
URL: https://github.com/apache/doris/pull/65319#discussion_r3557602537


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/StringLikeLiteral.java:
##########
@@ -384,11 +360,36 @@ protected DateTimeV2Literal getDateTimeLiteral(String 
year, String month, String
                 throw new CastException("Time zone offset couldn't be larger 
than 14:00");
             }
         }
-        String format = String.format("%s-%s-%sT%s:%s:%s%s%s", year4, month, 
date, hour, minute, second, fraction, tz);
-        try {
-            return new DateTimeV2Literal((DateTimeV2Type) targetType, format);
-        } catch (AnalysisException e) {
-            throw new CastException(e.getMessage(), e);
+        String format;
+        if (targetType.isDateType() || targetType.isDateV2Type()) {
+            format = String.format("%s-%s-%sT00:00:00%s", year4, month, date, 
tz);

Review Comment:
   This DATE/DATEV2 path now throws away the parsed time fields before any date 
literal validation, so invalid times can fold to a valid date. For example 
`cast('2024-5-1T24:00' as date)`, `cast('2024-05-01T12:60' as date)`, or 
`cast('2012-06-30T23:59:60' as date)` match the parser, then this branch 
rewrites them to midnight and `DateLiteral` no longer sees the invalid 
hour/minute/second. The existing `fe_constant_cast_to_date` cases expect those 
inputs to fail, and BE string-to-date parsing validates 
`HOUR`/`MINUTE`/`SECOND` before truncating to DATE. Please validate the full 
parsed datetime first, then truncate to DATE/DATEV2 after validation.
   



-- 
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