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/11/01 07:25:00 UTC

[jira] [Resolved] (CALCITE-3203) When matching materializations, match Project with child of Aggregate

     [ https://issues.apache.org/jira/browse/CALCITE-3203?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jin Xing resolved CALCITE-3203.
-------------------------------
    Resolution: Duplicate

> When matching materializations, match Project with child of Aggregate
> ---------------------------------------------------------------------
>
>                 Key: CALCITE-3203
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3203
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Jin Xing
>            Assignee: Jin Xing
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> In current code, {{SubstitutionVisitor}} & {{MaterializedViewSubstitutionVisitor}} fail to support below matching:
> {code:java}
>    query:   Project(projects: [$0, *(2, $1)])
>                   Aggregate(groupSet: {0}, groupSets: [{0}], calls: [SUM($1)])
>                      Scan(table: [hr, emps])</li>
>    target:  Project(projects: [$0, *(2, $1), *(2, $2)])
>                   Aggregate(groupSet: {0}, groupSets: [{0}], calls: [SUM($1), COUNT()])
>                      Scan(table: [hr, emps])</li>
> {code}
> And below test fails
> {code:java}
> // MaterializationTest.java
>   @Test public void testAggregate() {
>     checkMaterialize(
>       "select \"deptno\", count(1), 2 * sum(\"empid\") from "
>         + "(select * from \"emps\" union all select * from \"emps\")"
>         + "group by \"deptno\"",
>       "select \"deptno\", 2 * sum(\"empid\") from "
>         + "(select * from \"emps\" union all select * from \"emps\")"
>         + "group by \"deptno\"");
>   }
> {code}
> The reason is that {{Project&Aggregate}} are not taken into consideration at the same time in current matching rules.
> It might make sense to create a rule of {{ProjectOnAggregateToProjectOnAggregateUnifyRule}} to handle such case.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)