You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Xurenhe (Jira)" <ji...@apache.org> on 2021/09/27 00:11:00 UTC

[jira] [Comment Edited] (CALCITE-4801) SubstitutionVisitor don't support query pull up no-equal filter, when mv's aggregate rollup to query's aggregate

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

Xurenhe edited comment on CALCITE-4801 at 9/27/21, 12:10 AM:
-------------------------------------------------------------

As GitHub discussed, this issue is invalid.


was (Author: wojustme):
I debug this case, I found `org.apache.calcite.plan.SubstitutionVisitor#unifyAggregates` just working in equal constant.

Should we remove restriction of equal constant?
I will make a pr to enhance it.

> SubstitutionVisitor don't support query pull up no-equal filter, when mv's aggregate rollup to query's aggregate
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4801
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4801
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Xurenhe
>            Assignee: Xurenhe
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> SubstitutionVisitor don't support pull up filter under query's aggregate, for example:
>  
> {code:java}
> // test case
> @Test void testNoEqualFilterInAgg() {
>   final String mv = ""
>       + "select \"name\", \"deptno\", count(distinct \"commission\") as cnt\n"
>       + "from \"emps\"\n"
>       + " group by \"name\", \"deptno\"";
>   final String query = ""
>       + "select \"deptno\", count(distinct \"commission\") as cnt\n"
>       + "from \"emps\" where \"name\" <> 'jack'\n"
>       + "group by \"deptno\"";
>   sql(mv, query).ok();
> }{code}
> {code:java}
>  // exec mv match fail
> +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) 
> + at org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:299) 
> + at org.apache.calcite.util.ImmutableBeans$BeanImpl.invoke(ImmutableBeans.java:480) 
> + at com.sun.proxy.$Proxy16.ok(Unknown Source) 
> + at org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest.testNoEqualFilterInAgg(MaterializedViewSubstitutionVisitorTest.java:1058) 
> + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> {code}
>  
> ----
> {code:java}
> --query
> select deptno, count(distinct commission) as cnt
> from emps
> where name <> 'jack'
> group by deptno
> -- mv
> select name, deptno, count(distinct commission) as cnt
> from emps
> group by name, deptno
> -- after executing mv-match
> select deptno, cnt
> from mv
> where name <> 'jack'{code}



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