jduo commented on code in PR #3757:
URL: https://github.com/apache/calcite/pull/3757#discussion_r1571176366
##########
core/src/test/java/org/apache/calcite/test/RelBuilderTest.java:
##########
@@ -547,6 +547,31 @@ private void
checkSimplify(UnaryOperator<RelBuilder.Config> transform,
assertThat(root, matcher);
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-6340">
+ * [CALCITE-6340] RelBuilder always creates Project with Convention.NONE
during aggregate_.</a>.
+ */
+ @Test void testPruneProjectInputOfAggregatePreservesTraitSet() {
+ final RelBuilder builder = createBuilder(config ->
config.withPruneInputOfAggregate(true));
+
+ // This issue only occurs when projecting more columns than there are
fields and putting
+ // an aggregate over that projection.
+ RelNode root =
+ builder.scan("DEPT")
+ .adoptConvention(EnumerableConvention.INSTANCE)
+ .project(builder.alias(builder.field(0), "a"),
+ builder.alias(builder.field(1), "b"),
+ builder.alias(builder.field(2), "c"),
+ builder.alias(builder.field(1), "d"))
+ .aggregate(builder.groupKey(0, 1, 2, 1),
+ builder.aggregateCall(SqlStdOperatorTable.SUM,
+ builder.field(0)))
+ .build();
+
+ // Verify that the project under the aggregate kept the
EnumerableConvention.INSTANCE trait.
+
assertTrue(root.getInput(0).getTraitSet().contains(EnumerableConvention.INSTANCE));
Review Comment:
Thanks! Good suggestions @asolimando
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]