/** * If the filter list passed in is non-empty, creates a FilterRel on top of * the existing RelNode; otherwise, just returns the RelNode * * @param rexBuilder rex builder * @param rel the RelNode that the filter will be put on top of * @param filters list of filters * * @return new RelNode or existing one if no filters */ private RelNode createFilterOnRel( RexBuilder rexBuilder, RelNode rel, List<RexNode> filters) { RelNode newRel; if (filters.size() == 0) { newRel = rel; } else { RexNode andFilters = RexUtil.andRexNodeList(rexBuilder, filters); newRel = CalcRel.createFilter(rel, andFilters); } return newRel; } }
/** * Applies a mapping to a list of field collations. * * @param mapping Mapping * @param fieldCollations Field collations * @return collations with mapping applied */ public static List<RelFieldCollation> applyFields( Mappings.TargetMapping mapping, List<RelFieldCollation> fieldCollations) { final List<RelFieldCollation> newFieldCollations = new ArrayList<RelFieldCollation>(fieldCollations.size()); for (RelFieldCollation fieldCollation : fieldCollations) { newFieldCollations.add(apply(mapping, fieldCollation)); } return newFieldCollations; }
/** * Applies a mapping to a collation. * * @param mapping Mapping * @param collation Collation * @return collation with mapping applied */ public static RelCollation apply( Mappings.TargetMapping mapping, RelCollation collation) { List<RelFieldCollation> fieldCollations = applyFields(mapping, collation.getFieldCollations()); return fieldCollations.equals(collation.getFieldCollations()) ? collation : RelCollationImpl.of(fieldCollations); }
&& call.getOperands().length == leftKeys.size(); rexComparison = RexUtil.composeConjunction( rexBuilder, Iterables.transform( RexUtil.composeDisjunction(rexBuilder, comparisons, true); assert result != null;
&& call.getOperands().length == leftKeys.length; rexComparison = RexUtil.composeConjunction( rexBuilder, RexUtil.generate( leftKeys.length, new Function1<Integer, RexNode>() { RexUtil.composeDisjunction(rexBuilder, comparisons, true); assert result != null;
list.add(equalsCall); return RexUtil.composeConjunction(rexBuilder, list, false);
if (!RexUtil.containIdentity(exprs, inputRowType, fail)) { assert !fail; return false; return false; if (RexUtil.containForwardRefs(exprs, inputRowType, fail)) { assert !fail; return false; if (RexUtil.containNonTrivialAggs(exprs, fail)) { assert !fail; return false;
private MutableProject(RelDataType rowType, MutableRel input, List<RexNode> projects) { super(MutableRelType.PROJECT, rowType, input); this.projects = projects; assert RexUtil.compatibleTypes(projects, rowType, true); }
RelDataType innerType = inner.getType(); RelDataType valueType = value.getType(); boolean outerCheck = RexUtil.canReinterpretOverflow(outer); boolean innerCheck = RexUtil.canReinterpretOverflow(inner);
final List<RexNode> exprList = program.getExprList(); final RexNode[] exprs = exprList.toArray(new RexNode[exprList.size()]); assert !RexUtil.containComplexExprs(exprList);
RexNode compose(RexBuilder rexBuilder, Iterable<RexNode> exprs) { exprs = Linq4j.asEnumerable(exprs).where(new Predicate1<RexNode>() { public boolean apply(RexNode expr) { return expr != null; } }); return RexUtil.composeConjunction(rexBuilder, exprs, false); }
if (!RexUtil.containIdentity(exprs, inputRowType, fail)) { assert !fail; return false; return false; if (RexUtil.containForwardRefs(exprs, inputRowType, fail)) { assert !fail; return false; if (RexUtil.containNonTrivialAggs(exprs, fail)) { assert !fail; return false;
/** * Infers predicates for a UnionRelBase. * * <p>The pulled up expression is a disjunction of its children's predicates. */ public RelOptPredicateList getPredicates(UnionRelBase union) { RexBuilder rB = union.getCluster().getRexBuilder(); List<RexNode> orList = Lists.newArrayList(); for (RelNode input : union.getInputs()) { RelOptPredicateList info = RelMetadataQuery.getPulledUpPredicates(input); if (!info.pulledUpPredicates.isEmpty()) { orList.addAll( RelOptUtil.disjunctions( RexUtil.composeConjunction(rB, info.pulledUpPredicates, false))); } } if (orList.isEmpty()) { return RelOptPredicateList.EMPTY; } return RelOptPredicateList.of( RelOptUtil.conjunctions(RexUtil.composeDisjunction(rB, orList, false))); }
return false; if (!RexUtil.compatibleTypes( exps, getRowType(),
RelDataType innerType = inner.getType(); RelDataType valueType = value.getType(); boolean outerCheck = RexUtil.canReinterpretOverflow(outer); boolean innerCheck = RexUtil.canReinterpretOverflow(inner);
final List<RexNode> exprList = program.getExprList(); final RexNode [] exprs = exprList.toArray(new RexNode[exprList.size()]); assert !RexUtil.containComplexExprs(exprList);
/** * If the filter list passed in is non-empty, creates a FilterRel on top of * the existing RelNode; otherwise, just returns the RelNode * * @param rexBuilder rex builder * @param rel the RelNode that the filter will be put on top of * @param filters list of filters * @return new RelNode or existing one if no filters */ private RelNode createFilterOnRel( RexBuilder rexBuilder, RelNode rel, List<RexNode> filters) { RexNode andFilters = RexUtil.composeConjunction(rexBuilder, filters, false); if (andFilters.isAlwaysTrue()) { return rel; } return filterFactory.createFilter(rel, andFilters); }
/** * Applies a mapping to a list of field collations. * * @param mapping Mapping * @param fieldCollations Field collations * @return collations with mapping applied */ public static List<RelFieldCollation> applyFields( Mappings.TargetMapping mapping, List<RelFieldCollation> fieldCollations) { final List<RelFieldCollation> newFieldCollations = new ArrayList<RelFieldCollation>(fieldCollations.size()); for (RelFieldCollation fieldCollation : fieldCollations) { newFieldCollations.add(apply(mapping, fieldCollation)); } return newFieldCollations; }
/** * AND's two predicates together, either of which may be null, removing * redundant filters. * * @param rexBuilder rexBuilder used to construct AND'd RexNode * @param pred1 first predicate * @param pred2 second predicate * * @return AND'd predicate or individual predicates if one is null */ public static RexNode unionPreds( RexBuilder rexBuilder, RexNode pred1, RexNode pred2) { final List<RexNode> unionList = new ArrayList<RexNode>(); final Set<String> strings = new HashSet<String>(); for (RexNode rex : RelOptUtil.conjunctions(pred1)) { if (strings.add(rex.toString())) { unionList.add(rex); } } for (RexNode rex2 : RelOptUtil.conjunctions(pred2)) { if (strings.add(rex2.toString())) { unionList.add(rex2); } } return RexUtil.andRexNodeList(rexBuilder, unionList); }
return false; if (!RexUtil.compatibleTypes( exps, getRowType(),