morrySnow commented on code in PR #64795:
URL: https://github.com/apache/doris/pull/64795#discussion_r3489171941
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/TimestampTzLiteral.java:
##########
@@ -64,6 +67,62 @@ public TimestampTzLiteral(TimeStampTzType dateType,
roundMicroSecond(dateType.getScale());
}
+ /**
+ * Build a TIMESTAMPTZ literal from a session-local datetime string.
+ * Strings with an explicit zone/offset keep their own timezone semantics;
+ * strings without one are interpreted in the current session timezone and
converted to UTC.
+ */
+ public static TimestampTzLiteral fromSessionTimeZone(TimeStampTzType
dateType, String s) {
+ if (DateTimeChecker.hasTimeZone(s)) {
+ return new TimestampTzLiteral(dateType, s);
+ }
+
+ return fromSessionTimeZone(dateType, new DateTimeV2Literal(s));
+ }
+
+ /**
+ * fromSessionTimeZone
+ */
+ public static TimestampTzLiteral fromSessionTimeZone(TimeStampTzType
dateType, DateTimeV2Literal literal) {
+ return fromTimeZone(dateType, literal, getSessionTimeZone());
+ }
+
+ /**
+ * Build a TIMESTAMPTZ literal from a datetime string, explicitly
specifying the source timezone.
+ * Strings with an explicit zone/offset keep their own timezone semantics;
+ * strings without one are converted from the given timeZone to UTC.
+ */
+ public static TimestampTzLiteral fromTimeZone(TimeStampTzType dateType,
String s, String timeZone) {
+ if (DateTimeChecker.hasTimeZone(s)) {
+ return new TimestampTzLiteral(dateType, s);
Review Comment:
## MTMV Compatibility Concern
The `+00:00` suffix introduced in `getStringValue()` will be exposed to MTMV
code paths that read partition values via `PartitionValue.getStringValue()`.
Specifically in `MTMVPartitionExprDateTrunc.strToDate()`, the value is parsed
as a `DateTimeV2Literal`:
```java
return new DateTimeV2Literal(value);
```
`DateTimeLiteral.init()` detects the zone offset and converts to the
**session timezone** (not UTC) because `DateTimeV2Literal` is not a
`TimeStampTzType`:
```java
ZoneId targetZone = this.dataType instanceof TimeStampTzType
? ZoneId.of("UTC")
: DateUtils.getTimeZone(); // session timezone!
```
This means the date-trunc arithmetic runs in session-local time rather than
UTC, potentially producing incorrect MV partition boundaries when the session
timezone differs from UTC.
**Recommendation:** Add a regression test with session timezone != UTC
(e.g., Asia/Shanghai) that exercises the full MTMV partition rollup flow with
TIMESTAMPTZ partition columns. Alternatively, consider using
`TimestampTzLiteral` instead of `DateTimeV2Literal` in
`MTMVPartitionExprDateTrunc` when the partition column type is TIMESTAMPTZ.
--
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]