You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Heng Xiao (Jira)" <ji...@apache.org> on 2025/02/22 13:55:00 UTC
[jira] [Created] (CALCITE-6853) Nested window aggregate throws UnsupportedOperationException with the default ValidatorConfig
Heng Xiao created CALCITE-6853:
----------------------------------
Summary: Nested window aggregate throws UnsupportedOperationException with the default ValidatorConfig
Key: CALCITE-6853
URL: https://issues.apache.org/jira/browse/CALCITE-6853
Project: Calcite
Issue Type: Bug
Components: core
Reporter: Heng Xiao
Assignee: Heng Xiao
I was trying to run TPC-DS with the default ValidatorConfig. And the default value of validatorConfig.identifierExpansion is false. java.lang.UnsupportedOperationException were thrown when executing TPC-DS query12 and some other queries which used nested window aggregate, like `sum(sum(col)) over()`.
This bug can be easily reproduced using the following testcase
{code:java}
// SqlToRelConverterTest
@Test void testNestedWindowAggWithIdentifierExpansionDisabled(){
String sql = "select sum(sum(sal)) over() from emp";
sql(sql)
.withFactory(f ->
f.withValidator((opTab, catalogReader, typeFactory, config) -> {
if (config.conformance().allowGeometry()) {
opTab =
SqlOperatorTables.chain(opTab,
SqlOperatorTables.spatialInstance());
}
return SqlValidatorUtil.newValidator(opTab, catalogReader,
typeFactory, config.withIdentifierExpansion(false));
}))
.withTrim(false)
.ok();
} {code}
The error stacktrace is as follows.
{code:java}
java.lang.UnsupportedOperationException: class org.apache.calcite.sql.SqlBasicCall: SUM(SUM(`SAL`)) OVER ()
at org.apache.calcite.util.Util.needToImplement(Util.java:1112)
at org.apache.calcite.sql.validate.SqlValidatorImpl.getValidatedNodeType(SqlValidatorImpl.java:1908)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertOver(SqlToRelConverter.java:2333)
at org.apache.calcite.sql2rel.SqlToRelConverter.access$2200(SqlToRelConverter.java:253)
at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:5701)
at org.apache.calcite.sql2rel.SqlToRelConverter.createAggImpl(SqlToRelConverter.java:3664)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertAgg(SqlToRelConverter.java:3500)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectList(SqlToRelConverter.java:4739)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:809)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:735)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3915)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:628)
at org.apache.calcite.sql.test.AbstractSqlTester.convertSqlToRel2(AbstractSqlTester.java:544)
at org.apache.calcite.sql.test.AbstractSqlTester.assertSqlConvertsTo(AbstractSqlTester.java:485)
at org.apache.calcite.sql.test.AbstractSqlTester.assertConvertsTo(AbstractSqlTester.java:463)
at org.apache.calcite.test.SqlToRelFixture.convertsTo(SqlToRelFixture.java:106)
at org.apache.calcite.test.SqlToRelFixture.ok(SqlToRelFixture.java:94)
at org.apache.calcite.test.SqlToRelConverterTest.testNestedWindowAggWithIdentifierExpansionDisabled(SqlToRelConverterTest.java:5373){code}
The identifierExpansion config option is suppose to have nothing to do with nested window aggregate, so I think this is a bug, and was not tested out before due to the Caclite test framework `Fixture` sets this option to true as default for test cases.
{code:java}
public static final SqlToRelFixture DEFAULT =
new SqlToRelFixture("?", true, TESTER, SqlTestFactory.INSTANCE, false,
false, null)
.withFactory(f ->
f.withValidator((opTab, catalogReader, typeFactory, config) -> {
if (config.conformance().allowGeometry()) {
opTab =
SqlOperatorTables.chain(opTab,
SqlOperatorTables.spatialInstance());
}
return SqlValidatorUtil.newValidator(opTab, catalogReader,
typeFactory, config.withIdentifierExpansion(true));
})
// ........{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)