morrySnow commented on code in PR #14662:
URL: https://github.com/apache/doris/pull/14662#discussion_r1036246536


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java:
##########
@@ -62,7 +62,6 @@ public enum Operator {
         BITXOR("^", "bitxor", OperatorPosition.BINARY_INFIX, 
TExprOpcode.BITXOR),
         BITNOT("~", "bitnot", OperatorPosition.UNARY_PREFIX, 
TExprOpcode.BITNOT),
         FACTORIAL("!", "factorial", OperatorPosition.UNARY_POSTFIX, 
TExprOpcode.FACTORIAL);
-

Review Comment:
   add this line back



##########
fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java:
##########
@@ -363,6 +363,16 @@ private String paramsToSql() {
         }
         int len = children.size();
         List<String> result = Lists.newArrayList();
+        if (fnName.getFunction().equalsIgnoreCase("years_diff")
+                || fnName.getFunction().equalsIgnoreCase("months_diff")
+                || fnName.getFunction().equalsIgnoreCase("days_diff")
+                || fnName.getFunction().equalsIgnoreCase("hours_diff")
+                || fnName.getFunction().equalsIgnoreCase("minutes_diff")
+                || fnName.getFunction().equalsIgnoreCase("seconds_diff")) {
+            sb.append(children.get(1).toSql()).append(", ");
+            sb.append(children.get(0).toSql()).append(")");
+            return sb.toString();
+        }

Review Comment:
   add comment to explain this is use for nereids and should not be removed



##########
fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4:
##########
@@ -257,8 +257,15 @@ valueExpression
     | left=valueExpression comparisonOperator right=valueExpression            
              #comparison
     ;
 
+datetimeUnit
+    : YEAR | MONTH
+    | WEEK | DAY
+    | HOUR | MINUTE | SECOND
+    ;
+
 primaryExpression
-    : CASE whenClause+ (ELSE elseExpression=expression)? END                   
                #searchedCase
+    : name=(TIMESTAMPDIFF | DATEDIFF) LEFT_PAREN unit=datetimeUnit COMMA 
startTimestamp=valueExpression COMMA endTimestamp=valueExpression RIGHT_PAREN   
 #timestampdiff

Review Comment:
   wrap this line, such as:
   ```suggestion
       : name=(TIMESTAMPDIFF | DATEDIFF) LEFT_PAREN unit=datetimeUnit COMMA
          startTimestamp=valueExpression COMMA endTimestamp=valueExpression 
RIGHT_PAREN    #timestampdiff
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -613,7 +643,8 @@ public UnboundFunction 
visitFunctionCall(DorisParser.FunctionCallContext ctx) {
             //      the function information is obtained by parsing the 
catalog. This method is more scalable.
             String functionName = ctx.identifier().getText();
             boolean isDistinct = ctx.DISTINCT() != null;
-            List<Expression> params = visit(ctx.expression(), 
Expression.class);
+            List<ExpressionContext> expressionContexts = ctx.expression();
+            List<Expression> params = visit(expressionContexts, 
Expression.class);

Review Comment:
   why add a local var?



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to