xzh_dz created CALCITE-4800:
-------------------------------

             Summary: Add SortToSortUnifyRule in SubstitutionVisitor
                 Key: CALCITE-4800
                 URL: https://issues.apache.org/jira/browse/CALCITE-4800
             Project: Calcite
          Issue Type: Improvement
            Reporter: xzh_dz


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.3.4#803005)

Reply via email to