You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "jin xing (JIRA)" <ji...@apache.org> on 2019/07/09 06:11:00 UTC

[jira] [Commented] (CALCITE-3113) Equivalent MutableAggregates with different row types fail with AssertionError

    [ https://issues.apache.org/jira/browse/CALCITE-3113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16880958#comment-16880958 ] 

jin xing commented on CALCITE-3113:
-----------------------------------

In SQLs below, Aggregations operator in both materialization and query should definitely matches with each other and regarded as equivalent. 
{code:java}
"select count as c from \"emps\" group by \"empid\"",
"select count + 1 as c from \"emps\" group by \"empid\"");{code}

row-type checking in https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java#L498 is too strict. In my understanding, we might just need to assure that the final result from {{SubstitutionVisitor}} should have same row-type as before.

> Equivalent MutableAggregates with different row types fail with AssertionError
> ------------------------------------------------------------------------------
>
>                 Key: CALCITE-3113
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3113
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.19.0
>            Reporter: Feng Zhu
>            Priority: Major
>
> Add test case in MaterializationTest: 
> {code:java}
> @Test public void testAggregateAlias() {
>   checkMaterialize(
>       "select count(*) as c from \"emps\" group by \"empid\"",
>       "select count(*) + 1 as c from \"emps\" group by \"empid\"");
> }
> {code}
>  It fails due to different rowtype.
> {code:java}
> java.lang.AssertionError
>     at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:504)
>     at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:465)
>     at org.apache.calcite.plan.MaterializedViewSubstitutionVisitor.go(MaterializedViewSubstitutionVisitor.java:56)
>     at org.apache.calcite.plan.RelOptMaterializations.substitute(RelOptMaterializations.java:200)
>     at org.apache.calcite.plan.RelOptMaterializations.useMaterializedViews(RelOptMaterializations.java:72)
>     at org.apache.calcite.plan.volcano.VolcanoPlanner.registerMaterializations(VolcanoPlanner.java:347)
> {code}
> However, according to MutableAggregate's hashCode&equals implementation, this materialization can be reused, i.e., queryDescedant=targetDescendant.
> {code:java}
> queryDescendant: RecordType(JavaType(int) empid, BIGINT $f1)
> =============================================================================
> Aggregate(groupSet: {0}, groupSets: [{0}], calls: [COUNT()])
>   Project(projects: [$0])
>     Scan(table: [hr, emps])
> targetDescendant: RecordType(JavaType(int) empid, BIGINT C)
> =============================================================================
> Aggregate(groupSet: {0}, groupSets: [{0}], calls: [COUNT()])
>   Project(projects: [$0])
>     Scan(table: [hr, emps])
> {code}
> So, how can we align them?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)