/** * Returns the child of the project that will be used as input into the new * JoinRel once the projects are pulled above the JoinRel. * * @param call RelOptRuleCall * @param project project RelNode * @param leftChild true if the project corresponds to the left projection * @return child of the project that will be used as input into the new * JoinRel once the projects are pulled above the JoinRel */ protected RelNode getProjectChild( RelOptRuleCall call, ProjectRelBase project, boolean leftChild) { return project.getChild(); }
/** * Returns the child of a project if the project is trivial, otherwise * the project itself. */ public static RelNode strip(ProjectRelBase project) { return isTrivial(project) ? project.getChild() : project; }
public Double getRowCount(ProjectRelBase rel) { return RelMetadataQuery.getRowCount(rel.getChild()); }
public Double getRowCount(ProjectRelBase rel) { return RelMetadataQuery.getRowCount(rel.getChild()); }
public RelOptCost computeSelfCost(RelOptPlanner planner) { double dRows = RelMetadataQuery.getRowCount(getChild()); double dCpu = dRows * exps.size(); double dIo = 0; return planner.makeCost(dRows, dCpu, dIo); }
public RelOptCost computeSelfCost(RelOptPlanner planner) { double dRows = RelMetadataQuery.getRowCount(getChild()); double dCpu = dRows * exps.size(); double dIo = 0; return planner.getCostFactory().makeCost(dRows, dCpu, dIo); }
/** * Returns a mapping, or null if this projection is not a mapping. */ public Mappings.TargetMapping getMapping() { return getMapping(getChild().getRowType().getFieldCount(), exps); }
public Double visitInputRef(RexInputRef var) { int index = var.getIndex(); BitSet col = new BitSet(index); col.set(index); Double distinctRowCount = RelMetadataQuery.getDistinctRowCount( rel.getChild(), col, null); if (distinctRowCount == null) { return null; } else { return RelMdUtil.numDistinctVals( distinctRowCount, RelMetadataQuery.getRowCount(rel)); } }
public Double visitInputRef(RexInputRef var) { int index = var.getIndex(); BitSet col = new BitSet(index); col.set(index); Double distinctRowCount = RelMetadataQuery.getDistinctRowCount( rel.getChild(), col, null); if (distinctRowCount == null) { return null; } else { return RelMdUtil.numDistinctVals( distinctRowCount, RelMetadataQuery.getRowCount(rel)); } }
public Set<RelColumnOrigin> getColumnOrigins( ProjectRelBase rel, int iOutputColumn) { final RelNode child = rel.getChild(); RexNode rexNode = rel.getProjects().get(iOutputColumn);
public Double getRowCount(FilterRelBase rel) { return NumberUtil.multiply( RelMetadataQuery.getSelectivity( rel.getChild(), rel.getCondition()), RelMetadataQuery.getRowCount(rel.getChild())); }
rel.getChild(), baseCols); if (population == null) {
rel.getChild(), baseCols); if (population == null) {
public static boolean isTrivial(ProjectRelBase project) { RelNode child = project.getChild(); final RelDataType childRowType = child.getRowType(); if (!childRowType.isStruct()) { return false; } if (!project.isBoxed()) { return false; } if (!isIdentity( project.getProjects(), project.getRowType(), childRowType)) { return false; } return true; }
public Double getSelectivity(ProjectRelBase rel, RexNode predicate) { List<RexNode> notPushable = new ArrayList<RexNode>(); List<RexNode> pushable = new ArrayList<RexNode>(); RelOptUtil.splitFilters( rel.getRowType().getFieldCount(), predicate, pushable, notPushable); RexBuilder rexBuilder = rel.getCluster().getRexBuilder(); RexNode childPred = RexUtil.andRexNodeList(rexBuilder, pushable); RexNode modifiedPred; if (childPred == null) { modifiedPred = null; } else { modifiedPred = RelOptUtil.pushFilterPastProject(childPred, rel); } Double selectivity = RelMetadataQuery.getSelectivity( rel.getChild(), modifiedPred); if (selectivity == null) { return null; } else { RexNode pred = RexUtil.andRexNodeList(rexBuilder, notPushable); return selectivity * RelMdUtil.guessSelectivity(pred); } }
public Double getSelectivity(ProjectRelBase rel, RexNode predicate) { List<RexNode> notPushable = new ArrayList<RexNode>(); List<RexNode> pushable = new ArrayList<RexNode>(); RelOptUtil.splitFilters( BitSets.range(rel.getRowType().getFieldCount()), predicate, pushable, notPushable); final RexBuilder rexBuilder = rel.getCluster().getRexBuilder(); RexNode childPred = RexUtil.composeConjunction(rexBuilder, pushable, true); RexNode modifiedPred; if (childPred == null) { modifiedPred = null; } else { modifiedPred = RelOptUtil.pushFilterPastProject(childPred, rel); } Double selectivity = RelMetadataQuery.getSelectivity( rel.getChild(), modifiedPred); if (selectivity == null) { return null; } else { RexNode pred = RexUtil.composeConjunction(rexBuilder, notPushable, true); return selectivity * RelMdUtil.guessSelectivity(pred); } }
getChild().getRowType(), fail); for (RexNode exp : exps) { exp.accept(checker);
public void onMatch(RelOptRuleCall call) { final FilterRelBase filterRel = call.rel(0); final ProjectRelBase projRel = call.rel(1); // convert the filter to one that references the child of the project RexNode newCondition = RelOptUtil.pushFilterPastProject(filterRel.getCondition(), projRel); RelNode newFilterRel = filterFactory == null ? filterRel.copy(filterRel.getTraitSet(), projRel.getChild(), newCondition) : filterFactory.createFilter(projRel.getChild(), newCondition); RelNode newProjRel = projectFactory == null ? projRel.copy(projRel.getTraitSet(), newFilterRel, projRel.getProjects(), projRel.getRowType()) : projectFactory.createProject(newFilterRel, projRel.getProjects(), projRel.getRowType().getFieldNames()); call.transformTo(newProjRel); } }
private static MutableRel toMutable(RelNode rel) { if (rel instanceof TableAccessRelBase) { return MutableScan.of((TableAccessRelBase) rel); } if (rel instanceof ValuesRelBase) { return MutableValues.of((ValuesRelBase) rel); } if (rel instanceof ProjectRelBase) { final ProjectRelBase project = (ProjectRelBase) rel; final MutableRel input = toMutable(project.getChild()); return MutableProject.of(input, project.getProjects(), project.getRowType().getFieldNames()); } if (rel instanceof FilterRelBase) { final FilterRelBase filter = (FilterRelBase) rel; final MutableRel input = toMutable(filter.getChild()); return MutableFilter.of(input, filter.getCondition()); } if (rel instanceof AggregateRelBase) { final AggregateRelBase aggregate = (AggregateRelBase) rel; final MutableRel input = toMutable(aggregate.getChild()); return MutableAggregate.of(input, aggregate.getGroupSet(), aggregate.getAggCallList()); } throw new RuntimeException("cannot translate " + rel + " to MutableRel"); }
RexProgram bottomProgram = RexProgram.create( projRel.getChild().getRowType(), projRel.getProjects(), null,