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



##########
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:
       Ah I think `translatedOperands` might be easy to read. For example, it 
can be mapped to function signature. When I write such code, I tend to map 
parameters to offsets. WatermarkCol expression is the first parameter, then 
others. Maybe not everyone thinks in this way.
   
   I guess you are thinking why not directly use expressions? Either is fine to 
me.




----------------------------------------------------------------
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:
[email protected]


Reply via email to