[
https://issues.apache.org/jira/browse/CALCITE-6557?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17878074#comment-17878074
]
suibianwanwan commented on CALCITE-6557:
----------------------------------------
Hi, These seem to be two issues. Assertion Error in AggregateMergeRule because
of insufficient type checking, and whether Calcite needs to be more tolerant
with type checking. For the first one, I think you can add more error stacks
> Type Assertion Error In LogicalAggregate
> ----------------------------------------
>
> Key: CALCITE-6557
> URL: https://issues.apache.org/jira/browse/CALCITE-6557
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.37.0
> Reporter: Corvin Kuebler
> Priority: Critical
>
> Hey all!
> The following Test in JdbcAdapterTests:
> {code:java}
> @Test
> void testSumOfSumWithGroupBy() {
> CalciteAssert.model(JdbcTest.SCOTT_MODEL)
> .query("SELECT\n" +
> " SUM(DEPTNO)\n" +
> "FROM\n" +
> " (\n" +
> " SELECT\n" +
> " SUM(DEPTNO) AS DEPTNO\n" +
> " FROM\n" +
> " \"SCOTT\".\"DEPT\"\n" +
> " GROUP BY\n" +
> " DNAME\n" +
> " )")
> .enable(CalciteAssert.DB == CalciteAssert.DatabaseInstance.HSQLDB)
> .runs();
> }
> {code}
> fails with:
> {code:java}
> java.lang.AssertionError: type mismatch:
> aggCall type:
> TINYINT NOT NULL
> inferred type:
> TINYINT
> at org.apache.calcite.util.Litmus.lambda$static$0(Litmus.java:31)
> at org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:2204)
> at
> org.apache.calcite.rel.core.Aggregate.typeMatchesInferred(Aggregate.java:450)
> at org.apache.calcite.rel.core.Aggregate.<init>(Aggregate.java:177)
> {code}
> Its possible to workaround this issue by adding a COALESCE block
> (see
> {code:java}
> @Test
> void testSumOfSumWithGroupBy() {
> CalciteAssert.model(JdbcTest.SCOTT_MODEL)
> .query("SELECT\n" +
> " SUM(DEPTNO)\n" +
> "FROM\n" +
> " (\n" +
> " SELECT\n" +
> " COALESCE(SUM(DEPTNO),0) AS DEPTNO\n" +
> " FROM\n" +
> " \"SCOTT\".\"DEPT\"\n" +
> " GROUP BY\n" +
> " DNAME\n" +
> " )")
> .enable(CalciteAssert.DB == CalciteAssert.DatabaseInstance.HSQLDB)
> .runs();
> }
> {code}
> )
> however I think the statement should also work without the workaround.
> Since "TINYINT NOT NULL" is a subset of "TINYINT" the equality check could be
> made more tolerant?
> BR,
> Corvin
--
This message was sent by Atlassian Jira
(v8.20.10#820010)