You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by 刘东明 <l....@foxmail.com> on 2016/10/25 03:20:07 UTC

Calcite how to push down project/filter/aggregation to TableScan.

Hi, all

    I am using Apache Calcite to implement a distributed OLAP system, which datasource is RDBMS. So I want to push down the project/filter/aggregation in RelNode tree to MyTableScan extends TableScan. In MyTableScan, a RelBuilder to get the pushed RelNode. At last, RelBuilder to genatate the Query to the source database. At the same time, the project/filter/aggregation in original RelNode tree should be moved or modified.


    I am using RelOptRule and HepPlanner to implement this feature. I create a rule that match some operands, when onmatch(), I will use one tableScan to replace the matched subtree.


   There are some case:
   1) filter->tableScan  Use transformTo method in RelOptRule I can easily push the filter into tableScan and remove the filter in original tree.
   2) project->tableScan Can not use transformTo method, because the areRowTypesEqual is false. 
   3) push and change aggregation node. In original RelNode tree, count change to sum, avg change to sum/count, at the same time, the agg function be pushed to tableScan.


   for 2) and 3), any idea to implement? 


Thanks.