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/08/27 08:15:25 UTC

[GitHub] [calcite] danny0405 commented on a change in pull request #2121: [CALCITE-4192]Relmdcolumnorigins should obtain the true column index of the group by column of the aggregation operator instead of passing through directly

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



##########
File path: core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
##########
@@ -6764,4 +6767,24 @@ protected MyProjectRule(Config config) {
         .checkUnchanged();
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-4192">[CALCITE-4192]
+   * fix aggregate column origins searching by RelMdColumnOrigins</a>. */
+  @Test void testColumnOriginAfterAggProjectMergeRule() {
+    final String sql = "select count(ename), SAL from emp group by SAL";
+    final RelNode rel = tester.convertSqlToRel(sql).rel;
+    final HepProgramBuilder programBuilder = HepProgram.builder();
+    programBuilder.addRuleInstance(CoreRules.AGGREGATE_PROJECT_MERGE);
+    final HepPlanner planner = new HepPlanner(programBuilder.build());
+    planner.setRoot(rel);
+    final RelNode optimizedRel = planner.findBestExp();
+
+    Set<RelColumnOrigin> origins = RelMetadataQuery.instance()
+        .getColumnOrigins(optimizedRel, 1);
+    assertEquals(1, origins.size());
+
+    RelColumnOrigin columnOrigin = origins.iterator().next();
+    assertEquals(5, columnOrigin.getOriginColumnOrdinal());
+    assertEquals("SAL", columnOrigin.getOriginTable().getRowType().getFieldNames().get(5));

Review comment:
       Calcite prefer `assertThat` than `assertEquals`.




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