calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Tzolov <ctzo...@pivotal.io>
Subject Project + Sort on single and on multiple columns
Date Fri, 10 Nov 2017 17:42:04 GMT
​I've observed in my
no-sql adapter
​ implementation that for q
ueries with
​P
roject
​ +
​S
ort by
​ONE
 column
​t​
he
​Project

​is pushed (as expected) ​
before the Sort but for Sort
​on MULTIPLE
 columns
​the Sort is before the Project.
For example
​for a query with one
sort column:

SELECT yearPublished FROM BookMaster ORDER BY yearPublished ASC

​The plan looks like expected (project before the sort)


PLAN=GeodeToEnumerableConverterRel
  *GeodeSortRel*(sort0=[$0], dir0=[ASC])
       GeodeProjectRel(yearPublished=[$2])
           GeodeTableScanRel(table=[[TEST, BookMaster]])

But
​ for sort​
with
​two​
​
columns:

SELECT yearPublished, itemNumber from BookMaster ORDER BY yearPublished
ASC, itemNumber ASC

The
​the plan is:


PLAN=GeodeToEnumerableConverterRel
  GeodeProjectRel(yearPublished=[$2], itemNumber=[$0])
    *GeodeSortRel*(sort0=[$2], sort1=[$0], dir0=[ASC], dir1=[ASC])
      GeodeTableScanRel(table=[[TEST, BookMaster]])

I'm not sure i can explain
​ why in the second case the Sort appears before the Project?
Here
​are my cost functions:

​* ​
GeodeSortRel
​:
https://github.com/tzolov/calcite/blob/geode-1.3/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeSortRel.java#L51

* GoedeProjectRel:
https://github.com/tzolov/calcite/blob/4a631d9055340f64f5e644454551f964ea08f9de/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeProjectRel.java#L52
​

​
​Cheers,
Christian​

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message