zabetak commented on a change in pull request #1164: [CALCITE-2998] RexCopier
should support all rex types (Chunwei Lei)
URL: https://github.com/apache/calcite/pull/1164#discussion_r277288371
##########
File path: core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java
##########
@@ -558,6 +566,101 @@ private void checkDate(RexNode node) {
checkBigDecimalLiteral(builder, "-73786976294838206464");
}
+ /** Tests {@link RexCopier#visitOver(RexOver)} */
+ @Test public void testCopyOver() {
+ final RelDataTypeFactory typeFactory =
+ new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
+ final RexBuilder builder = new RexBuilder(typeFactory);
+ final RelDataType type = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ final RexOver node = (RexOver) builder.makeOver(type,
+ SqlStdOperatorTable.COUNT,
+ ImmutableList.of(builder.makeInputRef(type, 0)),
+ ImmutableList.of(builder.makeInputRef(type, 1)),
+ ImmutableList.of(
+ new RexFieldCollation(
+ builder.makeInputRef(type, 2), ImmutableSet.of())),
+ RexWindowBound.create(
+ SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO), null),
+ RexWindowBound.create(
+ SqlWindow.createCurrentRow(SqlParserPos.ZERO), null),
+ true, true, false, false, false);
+ final RexNode copy = builder.copy(node);
Review comment:
As far as I understand the code, the main advantage of RexCopier (over
RexShuttle) is that it can copy a RexNode copying also the type from one
factory to the other. The tests are good but they do not seem to verify that
the typeFactory is used correctly.
----------------------------------------------------------------
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]
With regards,
Apache Git Services