Feng Zhu created CALCITE-3088:
---------------------------------
Summary: Multi-groupsets query failed due to datype preservation check
Key: CALCITE-3088
URL: https://issues.apache.org/jira/browse/CALCITE-3088
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.20.0
Reporter: Feng Zhu
Assignee: Feng Zhu
We encounter the proble in our environment. It can be reproduced by the modification on _testCube_
in *SqlToRelConverterTest*.
{code:java}
@Test public void testCube() {
// cube(a, b) is {(a, b), (a), (b), ()}
final String sql = "select a+1\n"
+ "from (values (1, 2, 3, 4)) as t(a, b, c, d)\n"
+ "group by cube(a, b)";
sql(sql).ok();
}
{code}
This query will fail with following exception:
{code:java}
java.lang.AssertionError: Conversion to relational algebra failed to preserve datatypes:
validated type:
RecordType(INTEGER NOT NULL EXPR$0) NOT NULL
converted type:
RecordType(INTEGER EXPR$0) NOT NULL
rel:
LogicalProject(EXPR$0=[+($0, 1)])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {1}, {}]])
LogicalProject(A=[$0], B=[$1])
LogicalValues(tuples=[[{ 1, 2, 3, 4 }]])
at org.apache.calcite.sql2rel.SqlToRelConverter.checkConvertedType(SqlToRelConverter.java:406)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:523)
at org.apache.calcite.test.SqlToRelTestBase$TesterImpl.convertSqlToRel(SqlToRelTestBase.java:610)
at org.apache.calcite.test.SqlToRelTestBase$TesterImpl.assertConvertsTo(SqlToRelTestBase.java:723)
at org.apache.calcite.test.SqlToRelConverterTest$Sql.convertsTo(SqlToRelConverterTest.java:3073)
at org.apache.calcite.test.SqlToRelConverterTest$Sql.ok(SqlToRelConverterTest.java:3065)
at org.apache.calcite.test.SqlToRelConverterTest.testCube(SqlToRelConverterTest.java:474)
{code}
The exception stacktrace is very clear. In validation phase, SqlValidator does not take such
case into consideration, and consequently the type of {color:#FF0000}EXPR$0(a+1){color} cannot
be inferred as nullable.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
|