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

xzh_dz commented on CALCITE-4348:
---------------------------------

[~julianhyde]

Thanks, It seems like that can not preserves line breaks, I use a screenshot to 
illustrate the exception information.By the way, We have encountered a large 
number of use cases of materialized view recognition, through the external 
materialized view recognition rules[1] can help us to solve these problems.

[1] [https://github.com/apache/calcite/pull/2094|Add an interface in 
RelOptMaterializations to allow registering UnifyRule]

> Materialization recognition fails when query has calculation expression
> -----------------------------------------------------------------------
>
>                 Key: CALCITE-4348
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4348
>             Project: Calcite
>          Issue Type: Wish
>            Reporter: xzh_dz
>            Priority: Major
>         Attachments: image-2020-10-21-11-40-08-353.png
>
>
> The following example should be recognized by materialized views, but failed.
> {code:java}
> // code placeholder
> org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest
> @Test void testAggregateComplexExpression() {
>   String mv = ""
>       + "select \"deptno\", \"salary\", count(\"commission\")\n"
>       + "from \"emps\"\n"
>       + "group by \"deptno\", \"salary\"";
>   String query = ""
>       + "select \"deptno\" + \"salary\", count(\"commission\")\n"
>       + "from \"emps\"\n"
>       + "group by \"deptno\" + \"salary\"";
>   sql(mv, query).ok();
> }
> {code}
> {code:java}
> Query:
> Aggregate(groupSet: {0}, groupSets: [{0}], calls: [COUNT($1)])
>     Calc(program: (expr#0..4=[{inputs}], expr#5=[+($t1, $t3)], $f0=[$t5], 
> commission=[$t4]))
>       Scan(table: [hr, emps])
> mv:
> Aggregate(groupSet: {0, 1}, groupSets: [{0, 1}], calls: [COUNT($2)])
>   Calc(program: (expr#0..4=[{inputs}], deptno=[$t1], salary=[$t3], 
> commission=[$t4]))
>     Scan(table: [hr, emps]){code}
> Exception:
> !image-2020-10-21-11-40-08-353.png|width=606,height=223!
>  
>  
>  



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

Reply via email to