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; }
collationList.isEmpty() ? Collections.<RelCollation>emptyList() : collationList; assert isValid(true);
@Override public RelOptCost computeSelfCost( RelOptPlanner planner ) { return super.computeSelfCost( planner ).multiplyBy( .1 ); }
/** Copies a project. * * @see #copy(RelTraitSet, List) */ public abstract ProjectRelBase copy(RelTraitSet traitSet, RelNode input, List<RexNode> exps, RelDataType rowType);
/** * Returns a mapping, or null if this projection is not a mapping. */ public Mappings.TargetMapping getMapping() { return getMapping(getChild().getRowType().getFieldCount(), exps); }
/** Returns a list of (expression, name) pairs. Convenient for various * transformations. */ public final List<Pair<RexNode, String>> getNamedProjects() { return Pair.zip(getProjects(), getRowType().getFieldNames()); }
@Override public void onMatch(RelOptRuleCall call) { ProjectRelBase project = call.rel(0); assert RexOver.containsOver(project.getProjects(), null); final RelNode child = project.getChild(); final RelDataType rowType = project.getRowType(); final RexProgram program = RexProgram.create( child.getRowType(), project.getProjects(), null, project.getRowType(), project.getCluster().getRexBuilder()); project.getCluster(), project.getTraitSet(), child, rowType,
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); } }
List<RexNode> projExprs = rel.getProjects(); RelMetadataQuery.getUniqueKeys(rel.getChild(), ignoreNulls);
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"); }
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); } }
getRowType(), true)) getChild().getRowType(), fail); for (RexNode exp : exps) { exp.accept(checker); return false; if (!isBoxed()) { if (exps.size() != 1) { assert !fail;
List<RexNode> projExprs = rel.getProjects(); BitSet childColumns = new BitSet(); for (int bit : BitSets.toIter(columns)) { rel.getCluster().getTypeFactory(); RelDataType castType = typeFactory.createTypeWithNullability( rel.getChild(), childColumns, ignoreNulls);
/** * 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(); }
@Override public boolean matches(RelNode rel) { return super.matches(rel) && RexOver.containsOver(((ProjectRelBase) rel).getProjects(), null); } },
final RelNode leftLeft = ((JoinRelBase) left.getInput(0)).getLeft(); final int leftLeftCount = leftLeft.getRowType().getFieldCount(); final RelDataType nullableBooleanType =
public Mappings.TargetMapping getMapping() { return ProjectRelBase.getMapping( input.getRowType().getFieldCount(), projects); } }
public void onMatch(RelOptRuleCall call) { ProjectRelBase topProject = call.rel(0); ProjectRelBase bottomProject = call.rel(1); RexBuilder rexBuilder = topProject.getCluster().getRexBuilder(); bottomProject.getChild().getRowType(), bottomProject.getProjects(), null, bottomProject.getRowType(), rexBuilder); List<RexNode> projExprs = topProject.getProjects(); RexProgram topProgram = RexProgram.create( bottomProject.getRowType(), projExprs, null, topProject.getRowType(), rexBuilder); bottomProject.getChild(), newProjExprs, topProject.getRowType().getFieldNames());
final RelNode left = call.rel(2); final AggregateRelBase aggregate = call.rel(3); final BitSet bits = RelOptUtil.InputFinder.bits(project.getProjects(), null); final BitSet rightBits = BitSets.range(left.getRowType().getFieldCount(), ImmutableIntList.copyOf(newRightKeys)); final ProjectRelBase newProject = project.copy(project.getTraitSet(), semiJoin, project.getProjects(), project.getRowType()); call.transformTo(RemoveTrivialProjectRule.strip(newProject));
List<RexNode> projExprs = rel.getProjects(); RelMetadataQuery.getUniqueKeys(rel.getChild(), ignoreNulls);