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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/TimeDiff.java:
##########
@@ -83,11 +86,19 @@ public FunctionSignature computeSignature(FunctionSignature 
signature) {
             DateTimeV2Type left = (DateTimeV2Type) 
getArgument(0).getDataType();
             scale = Math.max(scale, left.getScale());
             useTimev2 = true;
+        } else if (getArgument(0).getDataType() instanceof TimeStampTzType) {
+            TimeStampTzType left = (TimeStampTzType) 
getArgument(0).getDataType();
+            scale = Math.max(scale, left.getScale());
+            useTimev2 = true;
         }
         if (getArgument(1).getDataType() instanceof DateTimeV2Type) {
             DateTimeV2Type right = (DateTimeV2Type) 
getArgument(1).getDataType();
             scale = Math.max(scale, right.getScale());
             useTimev2 = true;
+        } else if (getArgument(1).getDataType() instanceof TimeStampTzType) {

Review Comment:
   This FE path now returns `TIMEV2(max(leftScale, rightScale))` for 
TIMESTAMPTZ, but the BE implementation still builds the result type from only 
`arguments[0].type->get_scale()` in `TimeDiffImpl::get_return_type_impl()` 
(`be/src/exprs/function/function_date_or_datetime_computation.h`). For 
`timediff(CAST(... AS TIMESTAMPTZ(0)), CAST(... AS TIMESTAMPTZ(3)))`, FE plans 
`TIMEV2(3)` while BE creates `TIMEV2(0)`, which can truncate fractional seconds 
or make FE/BE result typing inconsistent. Please make BE use the max of both 
argument scales as well, and add a regression case with the higher scale on the 
right-hand argument.



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