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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnFE.java:
##########
@@ -554,7 +554,8 @@ public Expression visitBoundFunction(BoundFunction 
boundFunction, ExpressionRewr
         if (checkedExpr.isPresent()) {
             return checkedExpr.get();
         }
-        return ExpressionEvaluator.INSTANCE.eval(boundFunction);
+        return TypeCoercionUtils.ensureSameResultType(

Review Comment:
   像这些最好都加个注释说明为什么



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeArithmetic.java:
##########
@@ -879,26 +878,31 @@ public static Expression 
milliSecondsSub(TimestampTzLiteral date, BigIntLiteral
      */
     @ExecFunction(name = "datediff")
     public static Expression dateDiff(DateV2Literal date1, DateV2Literal 
date2) {
-        return new IntegerLiteral(dateDiff(date1.toJavaDateType(), 
date2.toJavaDateType()));
+        return dateDiff((DateLiteral) date1, date2);
     }
 
     @ExecFunction(name = "datediff")
     public static Expression dateDiff(DateV2Literal date1, DateTimeV2Literal 
date2) {
-        return new IntegerLiteral(dateDiff(date1.toJavaDateType(), 
date2.toJavaDateType()));
+        return dateDiff((DateLiteral) date1, date2);
     }
 
     @ExecFunction(name = "datediff")
     public static Expression dateDiff(DateTimeV2Literal date1, DateV2Literal 
date2) {
-        return new IntegerLiteral(dateDiff(date1.toJavaDateType(), 
date2.toJavaDateType()));
+        return dateDiff((DateLiteral) date1, date2);
     }
 
     @ExecFunction(name = "datediff")
     public static Expression dateDiff(DateTimeV2Literal date1, 
DateTimeV2Literal date2) {
-        return new IntegerLiteral(dateDiff(date1.toJavaDateType(), 
date2.toJavaDateType()));
+        return dateDiff((DateLiteral) date1, date2);
     }
 
-    private static int dateDiff(LocalDateTime date1, LocalDateTime date2) {
-        return ((int) ChronoUnit.DAYS.between(date2.toLocalDate(), 
date1.toLocalDate()));

Review Comment:
   以前的错误在哪?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/SearchSignature.java:
##########
@@ -257,14 +258,15 @@ private Pair<Boolean, Pair<Integer, Integer>> 
doMatchTypes(FunctionSignature sig
             // we need to try to do string literal coercion when search 
signature.
             // for example, FUNC_A has two signature FUNC_A(datetime) and 
FUNC_A(string)
             // if SQL block is `FUNC_A('2020-02-02 00:00:00')`, we should 
return signature FUNC_A(datetime).
-            if (!argument.isNullLiteral() && argument.isLiteral() && 
realType.isStringLikeType()) {
-                realType = 
TypeCoercionUtils.characterLiteralTypeCoercion(((Literal) 
argument).getStringValue(),
+            Optional<Literal> literalAfterUnwrapNullable = 
ExpressionUtils.getLiteralAfterUnwrapNullable(argument);
+            if (!argument.isNullLiteral() && 
literalAfterUnwrapNullable.isPresent() && realType.isStringLikeType()) {

Review Comment:
   这个得优化器看下



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