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 2022/01/26 04:11:00 UTC

[jira] [Comment Edited] (CALCITE-4800) Add SortToSortUnifyRule in SubstitutionVisitor

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

Xurenhe edited comment on CALCITE-4800 at 1/26/22, 4:10 AM:
------------------------------------------------------------

Hi [~xzh_dz] 
Are you still working on this issue?
If not, could I can follow it?
----
1. The same collation, we should check info of fetch and offset.

case1-1: the same offset
{code:java}
query: select * from tbl order by c1 limit 10;
mv: select * from tbl order by c1 limit 5; {code}
case1-2: the different offset
{code:java}
query: select * from tbl order by c1 limit 0, 10;
mv: select * from tbl order by c1 limit 2, 5; {code}
case1-3: the no limit info in mv
{code:java}
query: select * from tbl order by c1 limit 0, 10;
mv: select * from tbl order by c1; {code}
2. The different collation, we should check it.
case2-1: mv has no direction
{code:java}
query: select * from tbl order by c1 desc;
mv: select * from tbl order by c1; {code}
case2-2: mv has more field in collation
{code:java}
query: select * from tbl order by c1;
mv: select * from tbl order by c1, c2; {code}
 


was (Author: wojustme):
Hi [~xzh_dz] 
Are you still working on this issue?
If not, could I can follow it?
----
1. The same collation, we should check info of fetch and offset.

case1-1: the same offset

 
{code:java}
query: select * from tbl order by c1 limit 10;
mv: select * from tbl order by c1 limit 5; {code}
case1-2: the different offset
{code:java}
query: select * from tbl order by c1 limit 0, 10;
mv: select * from tbl order by c1 limit 2, 5; {code}
case1-3: the no limit info in mv
{code:java}
query: select * from tbl order by c1 limit 0, 10;
mv: select * from tbl order by c1; {code}
2. The different collation, we should check it.
case2-1: mv has no direction
{code:java}
query: select * from tbl order by c1 desc;
mv: select * from tbl order by c1; {code}
case2-2: mv has more field in collation
{code:java}
query: select * from tbl order by c1;
mv: select * from tbl order by c1, c2; {code}
 

> Add SortToSortUnifyRule in SubstitutionVisitor
> ----------------------------------------------
>
>                 Key: CALCITE-4800
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4800
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: xzh_dz
>            Priority: Major
>
> In my project, there are more usage scenarios for materialized view recognition, and the `Sort Operator` can help sort data sets.But it has not been supported yet.A `Sort Operator` failed example can be reproduced as follows.
> {code:java}
> // code placeholder
> org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest
> @Test void testSortToSort() {
>   final String mv = ""
>       + "select \"name\", \"deptno\"\n"
>       + "from \"emps\"\n"
>       + "order by \"deptno\"";
>   final String query = ""
>       + "select \"name\", \"deptno\"\n"
>       + "from \"emps\"\n"
>       + "order by \"deptno\" desc";
>   sql(mv, query).withChecker(
>       resultContains(""
>           + "EnumerableTableScan(table=[[hr, MV0]])")).ok();
> }
> {code}
> Exception:
> {code:java}
> // code placeholder
> 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) at org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:299)
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)