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

jin xing updated CALCITE-3256:
------------------------------
    Description: 
This issue proposes to add a rule to match a project
{code:java}
MV:
select deptno, sum(salary) + 2, sum(commission)
from emps
group by deptno

Query:
select deptno, sum(salary) + 2
from emps
group by deptno
{code}

After matching of the Aggregates, a compensating Project is added, but 
afterwards matching fails to handle it.

  was:
In current implementation of rules in SubstitutionVisitor.java & 
MaterializedViewSubstitutionVisitor.java, it's quite common to add a 
compensating Project on top of child node of target(MV-rel) during matching. 
But afterwards the next round matching should be able to handle such a 
compensated Project and match upward along the plan tree. Otherwise we fail the 
matching. After all, the goal of matching is to transform the query and let a 
complete 'target' show up in the transformed query plan.

I found cases where the compensated Project cannot be properly handled.

{code:java}
MV:
select deptno, sum(salary) + 2, sum(commission)
from emps
group by deptno

Query:
select deptno, sum(salary) + 2
from emps
group by deptno
{code}

After matching of the Aggregates, a compensating Project is added, but 
afterwards matching fails to handle it.


> Add ProjectOnProjectToProjectUnifyRule for materialization matching.
> --------------------------------------------------------------------
>
>                 Key: CALCITE-3256
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3256
>             Project: Calcite
>          Issue Type: Sub-task
>          Components: core
>            Reporter: jin xing
>            Assignee: jin xing
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue proposes to add a rule to match a project
> {code:java}
> MV:
> select deptno, sum(salary) + 2, sum(commission)
> from emps
> group by deptno
> Query:
> select deptno, sum(salary) + 2
> from emps
> group by deptno
> {code}
> After matching of the Aggregates, a compensating Project is added, but 
> afterwards matching fails to handle it.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to