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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/format/DateTimeChecker.java:
##########
@@ -160,14 +161,26 @@ private FormatChecker nanoSecond() {
     }
 
     private FormatChecker timeZone() {
+        return or(namedTimeZone(), offsetTimeZone());
+    }
+
+    private FormatChecker namedTimeZone() {
+        return and(
+                atLeast(1, Character::isLetter),
+                atLeast(0, c -> Character.isLetterOrDigit(c) || c == '/' || c 
== '_'
+                        || c == '-' || c == '+')
+        );
+    }
+
+    private FormatChecker offsetTimeZone() {
         // Z or +08:00 or UTC-01:00
         return and(
             // timezone: Europe/London, America/New_York
             atLeast(0, c -> ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') 
|| c == '/' || c == '_'),
             option(
                 and(
                     chars(c -> c == '+' || c == '-'),
-                    digit(1, 2),
+                    digit(1, 4),

Review Comment:
   [P2] Preserve fractional scale for newly recognized compact offsets. With 
time_zone='+00:00', CONVERT_TZ('20240102120000.123456+0000','UTC','UTC') now 
loses .123456. ConvertTz.castDateTime calls DateTimeV2Type.forTypeFromString; 
this wider match makes the input valid, activating 
DateTimeLiteral.determineScale, which still returns 0 for a compact string 
without '-' or ':'. The resulting CAST to DATETIME(0) rounds away the fraction 
before CONVERT_TZ runs, even with folding disabled. Previously the checker left 
two offset digits unconsumed, so inference retained MAX_SCALE=6; the existing 
StringLikeLiteral parser already accepted +0000 and normalized it to +00:00, 
preserving all six digits. Update compact fractional scale inference together 
with this grammar change and test an inferred-scale input; the current 
CONVERT_TZ matrix explicitly uses DATETIME(6) and cannot catch this regression.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java:
##########
@@ -339,13 +353,22 @@ static Result<TemporalAccessor, AnalysisException> 
parseDateTime(String s, int m
             }
             if (!containsPunctuation) {
                 s = normalizeBasic(s);
+                boolean hasTimeSeparator = s.length() > 8 && s.charAt(8) == 
'T';
+                int zoneStart = 0;
+                while (zoneStart < s.length() && 
(Character.isDigit(s.charAt(zoneStart))
+                        || (hasTimeSeparator && zoneStart == 8) || 
s.charAt(zoneStart) == '.')) {
+                    zoneStart++;
+                }
+                if (zoneStart < s.length() && s.charAt(zoneStart) != ' ') {
+                    s = s.substring(0, zoneStart) + 
TimeZoneParser.normalize(s.substring(zoneStart), usage);
+                }
                 boolean parseNanoseconds = maxFractionDigits > 7;
                 if (parseNanoseconds) {
                     s = DateUtils.truncateFractionalSecondForJavaParser(s);
                 }
                 // mysql reject "20200219 010101" "200219 010101", can't use ' 
' spilt basic date time.
 
-                if (!s.contains("T")) {
+                if (!hasTimeSeparator) {

Review Comment:
   [P2] Align short compact TIMESTAMPTZ parsing with BE. With 
time_zone='+00:00', CAST('240102120000UTC' AS TIMESTAMPTZ(6)) now folds to 
2024-01-02 12:00:00 UTC: normalizeBasic expands the two-digit year and this 
branch chooses the formatter without T. BE still receives the original 12 
digits; CastToDatetimeV2 only special-cases 14 contiguous digits, otherwise 
reads 2401-02-12 and fails the required date/time delimiter. Its non-strict 
fallback also requires date separators. The same value in a stored STRING or 
with folding disabled therefore returns NULL (or a parse error in strict mode). 
Before this change UTC's T selected the T formatter and left this CAST to the 
same failing runtime path, so the folded/runtime split is new. Add matching 
short-compact handling in BE or keep these values on the runtime path, and 
cover 12-digit inputs across folded and stored evaluation.



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