hsyuan commented on a change in pull request #1383: [CALCITE-3254] Exception
while deserializing of interval type or with empty partition/order key for
RexOver
URL: https://github.com/apache/calcite/pull/1383#discussion_r331184317
##########
File path: core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
##########
@@ -686,6 +692,100 @@
);
}
+ @Test public void testOverWithoutPartition() {
+ final FrameworkConfig config = RelBuilderTest.config().build();
+ final RelBuilder builder = RelBuilder.create(config);
+ final RexBuilder rexBuilder = builder.getRexBuilder();
+ final RelDataType type =
rexBuilder.getTypeFactory().createSqlType(SqlTypeName.BIGINT);
+ final RelDataType fieldType =
rexBuilder.getTypeFactory().createSqlType(SqlTypeName.ANY);
+ // The rel stands for the sql of "select ENAME, count(*) over (order by
deptno) from EMP"
+ final RelNode rel = builder
+ .scan("EMP")
+ .project(
+ builder.field("ENAME"),
+ rexBuilder.makeOver(
+ type,
+ SqlStdOperatorTable.COUNT,
+ new ArrayList<>(),
+ new ArrayList<>(), // empty partition
+ ImmutableList.of(
+ new RexFieldCollation(
+ rexBuilder.makeInputRef(fieldType, 7),
ImmutableSet.of())),
+ RexWindowBound.create(
+ SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO),
null),
+ RexWindowBound.create(
+ SqlWindow.createCurrentRow(SqlParserPos.ZERO), null),
+ true, true, false, false, false))
+ .build();
+ String relJson = RelOptUtil.dumpPlan("", rel, SqlExplainFormat.JSON,
+ SqlExplainLevel.EXPPLAN_ATTRIBUTES);
+ String s = deserializeAndDumpToTextFormat(getSchema(rel), relJson);
+ final String expected = ""
+ + "LogicalProject(ENAME=[$1], $f1=[COUNT() OVER (ORDER BY $7 NULLS
LAST ROWS"
+ + " BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)])\n"
+ + " LogicalTableScan(table=[[scott, EMP]])\n";
+ assertThat(s, isLinux(expected));
+ }
+
+ @Test public void testOverWithoutOrderKey() {
Review comment:
They are similar, can we add a helper function to create the rel node, but
with dfferent arguments for partition and order keys?
----------------------------------------------------------------
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