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

Feng Zhu commented on CALCITE-3182:
-----------------------------------

Hi, [~jinxing6...@126.com]. Can you take CALCITE-3113 i[nto consideration 
|https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-3113]together?

> Trim unused fields for plan of materialized-view before matching.
> -----------------------------------------------------------------
>
>                 Key: CALCITE-3182
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3182
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: jin xing
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> In current code, before matching query with materialized-view, unused fields 
> of query is trimmed but materialized-view is not. Thus below simple SQL fails 
> to be matched though query and materialized-
>  view are exactly the same:
> {code:java}
> @Test public void testMaterializationAfterTrimingOfUnusedFields() {
> String sql =
> "select \"y\".\"deptno\", \"y\".\"name\", \"x\".\"sum_salary\"\n" +
> "from\n" +
> " (select \"deptno\", sum(\"salary\") \"sum_salary\" from \"emps\" group by 
> \"deptno\") \"x\"\n" +
> " join\n" +
> " \"depts\" \"y\"\n" +
> " on \"x\".\"deptno\"=\"y\".\"deptno\"\n";
> checkMaterialize(sql, sql);
> }{code}
>  Checking {{CalciteMaterializer}} 
> [https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/prepare/CalciteMaterializer.java#L83]
>  , I think the code intends to do the trimming, but didn't call the method.
>  Since unused fields of query is trimmed anyway 
> [https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L995]
>  , thus I think there's no necessity to keep the materialized-view un-trimmed



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

Reply via email to