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

Xurenhe commented on CALCITE-4779:
----------------------------------

Hi, [~julianhyde]
This case is `group by literal 1`.

And I think optimization of mv-rewrite is a process of pulling up some rexnode, 
which could be expressed by mv's rowtype.
Here, this case has some literal, which could be expressed of any one mv. But, 
this case is failed.

Could we do some pretreatments for query's relnode, before executing 
mv-rewrite-optimizer?
For this case, we could add `CoreRules.AGGREGATE_PROJECT_PULL_UP_CONSTANTS` 
into `org.apache.calcite.plan.RelOptMaterializations#substitute` to 
canonicalize query.

 

> GroupSet contains constant, materialized view recognition failed
> ----------------------------------------------------------------
>
>                 Key: CALCITE-4779
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4779
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: xzh_dz
>            Priority: Major
>
> {code:java}
> // code placeholder
> org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest
> @Test void testCountDistinct() {
>   final String mv = ""
>       + "select \"deptno\", \"empid\"\n"
>       + "from \"emps\"\n"
>       + "group by \"deptno\", \"empid\"";
>   final String query = ""
>       + "select 1, \"deptno\"\n"
>       + "from \"emps\"\n"
>       + "group by 1, \"deptno\"";
>   sql(mv, query).ok();
> }
> {code}
> Materialized view failed to be matched by optimized results:Materialized view 
> failed to be matched by optimized results: java.lang.AssertionError: 
> Materialized view failed to be matched by optimized results: at 
> org.apache.calcite.test.AbstractMaterializedViewTest.checkMaterialize(AbstractMaterializedViewTest.java:116)
>  at 
> org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:67)
>  at 
> org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:229)
>  at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)



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

Reply via email to