caicancai commented on code in PR #3995:
URL: https://github.com/apache/calcite/pull/3995#discussion_r1792131838


##########
core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java:
##########
@@ -2309,10 +2311,20 @@ private static class TimestampSubConvertlet implements 
SqlRexConvertlet {
       //  => timestamp - count * INTERVAL '1' UNIT
       final RexBuilder rexBuilder = cx.getRexBuilder();
       final SqlParserPos pos = call.getParserPosition();
-      final SqlBasicCall operandCall = call.operand(1);
-      SqlIntervalQualifier qualifier = operandCall.operand(1);
-      final RexNode op1 = cx.convertExpression(operandCall.operand(0));
-      final RexNode op2 = cx.convertExpression(call.operand(0));
+      SqlIntervalQualifier qualifier;
+      final RexNode op1;
+      final RexNode op2;
+      if (call.getOperator() == SqlLibraryOperators.DATE_SUB_SPARK) {
+        // Spark-style 'DATE_SUB(date, integer days)'
+        qualifier = new SqlIntervalQualifier(TimeUnit.DAY, null, 
SqlParserPos.ZERO);
+        op2 = handleFirstParameter(cx, rexBuilder, call);
+        op1 = handleSecondParameter(cx, rexBuilder, call);
+      } else {
+        final SqlBasicCall operandCall = call.operand(1);
+        qualifier  = operandCall.operand(1);

Review Comment:
   fix



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

Reply via email to