zabetak commented on a change in pull request #1104: [CALCITE-2900]
RewriteRexShuttle generates wrong type during flatten for structured type when
visitInputRef
URL: https://github.com/apache/calcite/pull/1104#discussion_r265887105
##########
File path: core/src/test/java/org/apache/calcite/tools/PlannerTest.java
##########
@@ -996,6 +997,66 @@ private void checkBushy(String sql, String expected)
throws Exception {
assertThat(toString(transform), containsString(expected));
}
+ private void checkFlattenTypesOnNestedColumn(String sql, String expected)
throws Exception {
+ final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
+ final SqlParser.Config sqlParserConfig = SqlParser.configBuilder()
+ .setCaseSensitive(false)
+ .setUnquotedCasing(Casing.UNCHANGED)
+ .setQuotedCasing(Casing.UNCHANGED)
+ .build();
+ final FrameworkConfig config = Frameworks.newConfigBuilder()
+ .parserConfig(sqlParserConfig)
+ .defaultSchema(
+ CalciteAssert.addSchema(rootSchema,
+ CalciteAssert.SchemaSpec.BOOKSTORE))
+ .traitDefs((List<RelTraitDef>) null)
+ .build();
+ final Planner planner = Frameworks.getPlanner(config);
+ SqlNode parse = planner.parse(sql);
+ SqlNode validate = planner.validate(parse);
+ RelNode convert = planner.rel(validate).rel;
+ assertThat(toString(convert), containsString(expected));
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-2900">[CALCITE-2900]
+ * RewriteRexShuttle generates wrong type during flatten for structured type
when
+ * visitInputRef</a>. */
+ @Test
+ public void testFlattenTypesWithFieldAccessOnFirstLevel() throws Exception {
+ String sql = ""
Review comment:
Is this query the minimun that reproduces the problem? For example, I tried
removing group by and avg and the query still fails. Maybe it can be reduced
even more. In every case I think it is nice to have the bare minimum that
reproduces the problem.
----------------------------------------------------------------
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