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


##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionExprDateTrunc.java:
##########
@@ -179,6 +181,14 @@ private DateTimeV2Literal dateTrunc(String value,
     private DateTimeV2Literal strToDate(String value,
             Optional<String> dateFormat) throws AnalysisException {
         try {
+            if (DateTimeChecker.hasTimeZone(value)) {
+                // For TIMESTAMPTZ values, parse preserving UTC semantics.
+                // DateTimeV2Literal would convert to session timezone, which 
would
+                // produce incorrect MV partition boundaries when session tz 
!= UTC.
+                TimestampTzLiteral tzLiteral = new TimestampTzLiteral(value);
+                return new DateTimeV2Literal(tzLiteral.getYear(), 
tzLiteral.getMonth(), tzLiteral.getDay(),

Review Comment:
   The new branch fixes the input side of MTMV rollup by parsing `+00:00` 
values as TIMESTAMPTZ/UTC, but it still returns a plain `DateTimeV2Literal`. 
For TIMESTAMPTZ partition columns, `generateRollUpPartitionKeyDesc()` later 
serializes that through `dateTimeToStr()`, which emits `yyyy-MM-dd HH:mm:ss` 
without a `+00:00` suffix. The new test also expects 
`PartitionValue("2024-01-15 00:00:00")`.
   
   That descriptor is not just an identity string. When the MV partition is 
created or refreshed, it flows through 
`SinglePartitionDesc.translateToPartitionDefinition()` and 
`RangePartitionInfo.createNewRangeForFixedPartitionValueType()` into 
`PartitionKey.createPartitionKey()`. Since the MV partition column remains 
TIMESTAMPTZ (`date_trunc()` returns TIMESTAMPTZ for TIMESTAMPTZ input), the 
suffix-free bound is interpreted by `TimestampTzLiteral.fromSessionTimeZone()`. 
In a session like `America/New_York`, the intended UTC day lower bound 
`2024-01-15 00:00:00+00:00` is stored as `2024-01-15 05:00:00+00:00`, so the 
MTMV partition range is shifted even though the rollup grouping itself used UTC.
   
   Please keep generated TIMESTAMPTZ rollup bounds explicit UTC as well, for 
example by making the TIMESTAMPTZ branch of `dateTimeToStr()` return a 
`TimestampTzLiteral(...).getStringValue()` or otherwise appending the UTC 
offset for these generated bounds, and extend the test to cover actual 
descriptor analysis/addition rather than only comparing the intermediate 
suffix-free `PartitionKeyDesc`.



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