wojustme commented on pull request #2702:
URL: https://github.com/apache/calcite/pull/2702#issuecomment-1024816813


   Handle for Sort's mv-match
   
   - Equal collation's info, we just check offset and fetch. Query could be 
rewritten by mv, when mv's data-range must be larger than query's.
   such as:
   --query: 
   Sort(collation: [1], offset: 3)
     Calc(program: (expr#0..4=[{inputs}], name=[$t2], deptno=[$t1]))
       Scan(table: [hr, emps])
   --mv:
   Sort(collation: [1], offset: 2)
     Calc(program: (expr#0..4=[{inputs}], name=[$t2], deptno=[$t1]))
       Scan(table: [hr, emps])
   --rewrite:
   Sort(collation: [], offset: 1)
     Sort(collation: [1], offset: 2)
       Calc(program: (expr#0..4=[{inputs}], name=[$t2], deptno=[$t1]))
         Scan(table: [hr, emps])
   
   - No-equal collation's info, we could build a new sort above mv's, which 
collation must be query's
   such as:
   --query: 
   Sort(collation: [1 DESC])
     Calc(program: (expr#0..4=[{inputs}], name=[$t2], deptno=[$t1]))
       Scan(table: [hr, emps])
   --mv:
   Sort(collation: [1])
     Calc(program: (expr#0..4=[{inputs}], name=[$t2], deptno=[$t1]))
       Scan(table: [hr, emps])
   --rewrite:
   Sort(collation: [1 DESC])
     Sort(collation: [1])
       Calc(program: (expr#0..4=[{inputs}], name=[$t2], deptno=[$t1]))
         Scan(table: [hr, emps])


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to