You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/07/15 09:40:03 UTC

[GitHub] [calcite] danny0405 commented on a change in pull request #1981: [CALCITE-4000] Support OFFSET parameter in TUMBLE/HOP table functions…

danny0405 commented on a change in pull request #1981:
URL: https://github.com/apache/calcite/pull/1981#discussion_r454924400



##########
File path: core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
##########
@@ -3406,9 +3406,22 @@ abstract Expression implementSafe(RexToLixTranslator translator,
       translatedOperands.add(wmColExpr);
       translatedOperands.add(intervalExpression);
 
-      return Expressions.call(BuiltInMethod.TUMBLING.method, inputEnumerable,
-          EnumUtils.tumblingWindowSelector(inputPhysType, outputPhysType,
-              translatedOperands.get(0), translatedOperands.get(1)));
+      // handle the optional offset parameter. Use 0 for the default value when offset
+      // parameter is not set.
+      final Expression offsetExpr = call.getOperands().size() > 2
+          ? translator.translate(call.getOperands().get(2))
+          : Expressions.constant(0, long.class);
+      translatedOperands.add(offsetExpr);
+
+      return Expressions.call(
+          BuiltInMethod.TUMBLING.method,
+          inputEnumerable,
+          EnumUtils.tumblingWindowSelector(
+              inputPhysType,
+              outputPhysType,
+              translatedOperands.get(0),

Review comment:
       Is there any special reason we must use a list here to keep the translatedOperands ?




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

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