RexLocalRef condition = program.getCondition(); if (condition != null) { RexNode conditionNode = program.expandLocalRef(condition); filterInstance = planCreator.createScalarInstance(Lists.newArrayList(conditionNode), inputRowType, StormRelUtils.getClassName(this)); List<RexNode> expandedNodes = new ArrayList<>(); for (RexLocalRef project : projectList) { expandedNodes.add(program.expandLocalRef(project));
/** Splits this program into a list of project expressions and a list of * filter expressions. * * <p>Neither list is null. * The filters are evaluated first. */ public Pair<ImmutableList<RexNode>, ImmutableList<RexNode>> split() { final List<RexNode> filters = new ArrayList<>(); if (condition != null) { RelOptUtil.decomposeConjunction(expandLocalRef(condition), filters); } final ImmutableList.Builder<RexNode> projects = ImmutableList.builder(); for (RexLocalRef project : this.projects) { projects.add(expandLocalRef(project)); } return Pair.of(projects.build(), ImmutableList.copyOf(filters)); }
/** Splits this program into a list of project expressions and a list of * filter expressions. * * <p>Neither list is null. * The filters are evaluated first. */ public Pair<ImmutableList<RexNode>, ImmutableList<RexNode>> split() { final List<RexNode> filters = new ArrayList<>(); if (condition != null) { RelOptUtil.decomposeConjunction(expandLocalRef(condition), filters); } final ImmutableList.Builder<RexNode> projects = ImmutableList.builder(); for (RexLocalRef project : this.projects) { projects.add(expandLocalRef(project)); } return Pair.of(projects.build(), ImmutableList.copyOf(filters)); }
public static double estimateFilteredRows(RelNode child, RexProgram program, RelMetadataQuery mq) { // convert the program's RexLocalRef condition to an expanded RexNode RexLocalRef programCondition = program.getCondition(); RexNode condition; if (programCondition == null) { condition = null; } else { condition = program.expandLocalRef(programCondition); } return estimateFilteredRows(child, condition, mq); }
public static double estimateFilteredRows(RelNode child, RexProgram program, RelMetadataQuery mq) { // convert the program's RexLocalRef condition to an expanded RexNode RexLocalRef programCondition = program.getCondition(); RexNode condition; if (programCondition == null) { condition = null; } else { condition = program.expandLocalRef(programCondition); } return estimateFilteredRows(child, condition, mq); }
public void onMatch(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Calc calc = call.rel(1); final RexProgram program = calc.getProgram(); final List<RexNode> projects = new ArrayList<>(); for (RexLocalRef localRef : program.getProjectList()) { projects.add(program.expandLocalRef(localRef)); } final Project project = LogicalProject.create(calc.getInput(), projects, calc.getRowType()); RelNode x = AggregateProjectMergeRule.apply(call, aggregate, project); if (x != null) { call.transformTo(x); } } }
@Override protected RelNode handle(RelNode rel) { if (!(rel instanceof LogicalCalc)) { return rel; } final LogicalCalc calc = (LogicalCalc) rel; final RexProgram program = calc.getProgram(); relBuilder.push(calc.getInput()); if (program.getCondition() != null) { relBuilder.filter( program.expandLocalRef(program.getCondition())); } if (!program.projectsOnlyIdentity()) { relBuilder.project( Lists.transform(program.getProjectList(), program::expandLocalRef), calc.getRowType().getFieldNames()); } return relBuilder.build(); } };
@Override protected RelNode handle(RelNode rel) { if (!(rel instanceof LogicalCalc)) { return rel; } final LogicalCalc calc = (LogicalCalc) rel; final RexProgram program = calc.getProgram(); relBuilder.push(calc.getInput()); if (program.getCondition() != null) { relBuilder.filter( program.expandLocalRef(program.getCondition())); } if (!program.projectsOnlyIdentity()) { relBuilder.project( Lists.transform(program.getProjectList(), program::expandLocalRef), calc.getRowType().getFieldNames()); } return relBuilder.build(); } };
public void onMatch(RelOptRuleCall call) { final Filter topFilter = call.rel(0); final Filter bottomFilter = call.rel(1); // use RexPrograms to merge the two FilterRels into a single program // so we can convert the two LogicalFilter conditions to directly // reference the bottom LogicalFilter'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()); final RelBuilder relBuilder = call.builder(); relBuilder.push(bottomFilter.getInput()).filter(newCondition); call.transformTo(relBuilder.build()); }
public void onMatch(RelOptRuleCall call) { final Filter topFilter = call.rel(0); final Filter bottomFilter = call.rel(1); // use RexPrograms to merge the two FilterRels into a single program // so we can convert the two LogicalFilter conditions to directly // reference the bottom LogicalFilter'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()); final RelBuilder relBuilder = call.builder(); relBuilder.push(bottomFilter.getInput()) .filter(newCondition); call.transformTo(relBuilder.build()); }
mergedProgram.expandLocalRef( mergedProgram.getCondition());
public void onMatch(RelOptRuleCall call) { final Filter topFilter = call.rel(0); final Filter bottomFilter = call.rel(1); // use RexPrograms to merge the two FilterRels into a single program // so we can convert the two LogicalFilter conditions to directly // reference the bottom LogicalFilter'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()); final RelBuilder relBuilder = call.builder(); relBuilder.push(bottomFilter.getInput()) .filter(newCondition); call.transformTo(relBuilder.build()); }
mergedProgram.expandLocalRef( mergedProgram.getCondition()); Join newJoinRel = int[] adjustments = new int[nJoinFields]; for (int i = 0; i < nProjExprs; i++) { RexNode newExpr = mergedProgram.expandLocalRef(projList.get(i)); if (joinType != JoinRelType.INNER) { newExpr =
mergedProgram.expandLocalRef( mergedProgram.getCondition()); Join newJoinRel = int[] adjustments = new int[nJoinFields]; for (int i = 0; i < nProjExprs; i++) { RexNode newExpr = mergedProgram.expandLocalRef(projList.get(i)); if (joinType != JoinRelType.INNER) { newExpr =
rexBuilder); return mergedProgram.expandLocalRef( mergedProgram.getCondition());
rexBuilder); return mergedProgram.expandLocalRef( mergedProgram.getCondition());
rexBuilder); return mergedProgram.expandLocalRef( mergedProgram.getCondition());
if (calc.getProgram().getCondition() != null) { RexNode cond = calc.getProgram().expandLocalRef(calc.getProgram().getCondition()); final RexLocalRef rexLocalRef = topProgramBuilder.addExpr(cond.accept(rexInputConverter));