}
@Override
public void onMatch(RelOptRuleCall call) {
final ProjectRel proj = (ProjectRel) call.rel(0);
final EnumerableTableAccessRel scan = (EnumerableTableAccessRel) call.rel(1);
try {
ProjectPushInfo columnInfo = PrelUtil.getColumns(scan.getRowType(), proj.getProjects());
if(columnInfo == null || columnInfo.isStarQuery() //
|| !scan.getTable().unwrap(DrillTable.class) //
.getGroupScan().canPushdownProjects(columnInfo.columns)) return;
final DrillScanRel newScan =
new DrillScanRel(scan.getCluster(),
scan.getTraitSet().plus(DrillRel.DRILL_LOGICAL),
scan.getTable(),
columnInfo.createNewRowType(proj.getChild().getCluster().getTypeFactory()),
columnInfo.columns);
List<RexNode> newProjects = Lists.newArrayList();
for(RexNode n : proj.getChildExps()){
newProjects.add(n.accept(columnInfo.getInputRewriter()));
}
final DrillProjectRel newProj =
new DrillProjectRel(proj.getCluster(),
proj.getTraitSet().plus(DrillRel.DRILL_LOGICAL),
newScan,
newProjects,
proj.getRowType());
if (RemoveTrivialProjectRule.isTrivial(newProj)) {
call.transformTo(newScan);
} else {
call.transformTo(newProj);