danny0405 commented on a change in pull request #1449: [CALCITE-3302] Implement 
CLASSIFIER and LAST function for MATCH_RECOG…
URL: https://github.com/apache/calcite/pull/1449#discussion_r323084980
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMatch.java
 ##########
 @@ -163,26 +169,74 @@ private Expression 
implementEmitter(EnumerableRelImplementor implementor,
         Expressions.parameter(int.class, "match");
     final ParameterExpression consumer_ =
         Expressions.parameter(Consumer.class, "consumer");
+    final ParameterExpression i_ = Expressions.parameter(int.class, "i");
 
     final ParameterExpression row_ =
         Expressions.parameter(inputPhysType.getJavaRowType(), "row");
+
     final BlockBuilder builder2 = new BlockBuilder();
 
+    // Add loop variable initialization
+    builder2.add(
+        Expressions.declare(0, row_,
+            Types.castIfNecessary(
+                inputPhysType.getJavaRowType(),
+                Expressions.call(
+                    rows_,
+                    Types.lookupMethod(List.class, "get", int.class),
+                    i_))));
+
     RexBuilder rexBuilder = new RexBuilder(implementor.getTypeFactory());
     RexProgramBuilder rexProgramBuilder = new 
RexProgramBuilder(inputPhysType.getRowType(),
         rexBuilder);
     for (Map.Entry<String, RexNode> entry : measures.entrySet()) {
       rexProgramBuilder.addProject(entry.getValue(), entry.getKey());
     }
-    final List<Expression> arguments =
-        RexToLixTranslator.translateProjects(rexProgramBuilder.getProgram(),
-            (JavaTypeFactory) getCluster().getTypeFactory(),
-            implementor.getConformance(), builder2, physType,
-            implementor.getRootExpression(),
-            new RexToLixTranslator.InputGetterImpl(
-                Collections.singletonList(
-                    Pair.of(row_, inputPhysType))),
-            implementor.allCorrelateVariables);
+    // TODO intersect here and do the translation a bit differently (?!)
+    final RexToLixTranslator translator = RexToLixTranslator.forAggregation(
+        (JavaTypeFactory) getCluster().getTypeFactory(),
+        builder2,
+        new PassedRowsInputGetter(row_, rows_, inputPhysType),
+        implementor.getConformance());
+
+    // ...
+
 
 Review comment:
   Remove the meaningless comment.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to