zclllyybb commented on code in PR #55693:
URL: https://github.com/apache/doris/pull/55693#discussion_r2332764337


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java:
##########
@@ -917,48 +918,24 @@ public static Expression 
processBinaryArithmetic(BinaryArithmetic binaryArithmet
      * process timestamp arithmetic type coercion.
      */
     public static Expression processTimestampArithmetic(TimestampArithmetic 
timestampArithmetic) {
-        // check
         timestampArithmetic.checkLegalityBeforeTypeCoercion();
 
+        String name = timestampArithmetic.getFuncName().toLowerCase();
+        List<Expression> children = timestampArithmetic.children();
         Expression left = timestampArithmetic.left();
         Expression right = timestampArithmetic.right();
-        // left
-        DataType leftType = left.getDataType();
-
-        if (!leftType.isDateLikeType()) {
-            if (Config.enable_date_conversion && canCastTo(leftType, 
DateTimeV2Type.SYSTEM_DEFAULT)) {
-                leftType = DateTimeV2Type.SYSTEM_DEFAULT;
-            } else if (canCastTo(leftType, DateTimeType.INSTANCE)) {
-                leftType = DateTimeType.INSTANCE;
-            } else {
-                throw new AnalysisException("Operand '" + left.toSql()
-                        + "' of timestamp arithmetic expression '" + 
timestampArithmetic.toSql() + "' returns type '"
-                        + left.getDataType() + "'. Expected type 
'TIMESTAMP/DATE/DATETIME'.");
-            }
-        }
-        if (leftType.isDateType() && 
timestampArithmetic.getTimeUnit().isDateTimeUnit()) {
-            leftType = DateTimeType.INSTANCE;
-        }
-        if (leftType.isDateV2Type() && 
timestampArithmetic.getTimeUnit().isDateTimeUnit()) {
-            leftType = DateTimeV2Type.SYSTEM_DEFAULT;
-        }
-        if (!left.getDataType().isDateLikeType() && 
!left.getDataType().isNullType()) {
-            checkCanCastTo(left.getDataType(), leftType);
-            left = castIfNotSameType(left, leftType);
-        }
 
-        // right
-        if (!(right.getDataType() instanceof PrimitiveType)) {
-            throw new AnalysisException("the second argument must be a scalar 
type. but it is " + right.toSql());
-        }
-        if (!right.getDataType().isIntegerType()) {
-            if (!ScalarType.canCastTo((ScalarType) 
right.getDataType().toCatalogDataType(), Type.INT)) {
-                throw new AnalysisException("Operand '" + right.toSql()
-                        + "' of timestamp arithmetic expression '" + 
timestampArithmetic.toSql() + "' returns type '"
-                        + right.getDataType() + "' which is incompatible with 
expected type 'INT'.");
-            }
-            right = castIfNotSameType(right, IntegerType.INSTANCE);
-        }
+        // get right signature by normal function resolution
+        FunctionBuilder functionBuilder = 
Env.getCurrentEnv().getFunctionRegistry().findFunctionBuilder(name,

Review Comment:
   see `ExpressionAnalyzer::visitTimestampArithmetic`. it will set name for 
TimestampArithmetic and it's before 
`TypeCoercionUtils.processTimestampArithmetic`. so I think when reach here, the 
name couldn't be null.



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