public void onMatch(RelOptRuleCall call) { FilterRel topFilter = call.rel(0); FilterRel bottomFilter = call.rel(1); // use RexPrograms to merge the two FilterRels into a single program // so we can convert the two FilterRel conditions to directly // reference the bottom FilterRel's child RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder(); RexProgram bottomProgram = createProgram(bottomFilter); RexProgram topProgram = createProgram(topFilter); RexProgram mergedProgram = RexProgramBuilder.mergePrograms( topProgram, bottomProgram, rexBuilder); RexNode newCondition = mergedProgram.expandLocalRef( mergedProgram.getCondition()); FilterRel newFilterRel = new FilterRel( topFilter.getCluster(), bottomFilter.getChild(), newCondition); call.transformTo(newFilterRel); }
public void onMatch(RelOptRuleCall call) { FilterRel topFilter = call.rel(0); FilterRel bottomFilter = call.rel(1); // use RexPrograms to merge the two FilterRels into a single program // so we can convert the two FilterRel conditions to directly // reference the bottom FilterRel's child RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder(); RexProgram bottomProgram = createProgram(bottomFilter); RexProgram topProgram = createProgram(topFilter); RexProgram mergedProgram = RexProgramBuilder.mergePrograms( topProgram, bottomProgram, rexBuilder); RexNode newCondition = mergedProgram.expandLocalRef( mergedProgram.getCondition()); FilterRel newFilterRel = new FilterRel( topFilter.getCluster(), bottomFilter.getChild(), newCondition); call.transformTo(newFilterRel); }