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/13 07:12:54 UTC

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

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



##########
File path: core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
##########
@@ -3406,9 +3406,23 @@ 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.
+      if (call.getOperands().size() > 2) {
+        translatedOperands.add(translator.translate(call.getOperands().get(2)));
+      } else {
+        // use 0 for the default value when offset parameter is not set.

Review comment:
       Can we simpilfy this logic as below? It may be more intuitive.
   ```
   // handle the optional offset parameter, use 0 as default when ...
   final Expression xxxExpression = call.getOperands().size() > 2 ? translator.translate(call.getOperands().get(2)) : Expressions.constant(0, long.class);
   translatedOperands.add(xxxExpression);
   ```




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