/** Creates an OR. */ public RexNode or(Iterable<? extends RexNode> operands) { return RexUtil.composeDisjunction(cluster.getRexBuilder(), operands, false); }
/** Creates an OR. */ public RexNode or(Iterable<? extends RexNode> operands) { return RexUtil.composeDisjunction(cluster.getRexBuilder(), operands, false); }
RexNode disjPred = RexUtil.composeDisjunction(rB, finalResidualPreds, false); if (!disjPred.isAlwaysTrue()) { preds.add(disjPred);
for (String ref : refsInAllOperands) { commonOperands .add(RexUtil.composeDisjunction(rexBuilder, reductionCondition.get(ref), false));
RexNode disjPred = RexUtil.composeDisjunction(rB, finalResidualPreds, false); if (!disjPred.isAlwaysTrue()) { preds.add(disjPred);
newOperands.addAll(operands); node = RexUtil.composeDisjunction(rexBuilder, newOperands, false); break; default:
newOperands.addAll(operands); node = RexUtil.composeDisjunction(rexBuilder, newOperands, false); break; default:
private RexNode convertToStatsCondition(RexNode condition, IndexDescriptor index, IndexCallContext context, RelNode scanRel, List<SqlKind>typesToProcess) { RexBuilder builder = scanRel.getCluster().getRexBuilder(); if (condition.getKind() == SqlKind.AND) { final List<RexNode> conditions = Lists.newArrayList(); for(RexNode pred : RelOptUtil.conjunctions(condition)) { conditions.add(convertToStatsCondition(pred, index, context, scanRel, typesToProcess)); } return RexUtil.composeConjunction(builder, conditions, false); } else if (condition.getKind() == SqlKind.OR) { final List<RexNode> conditions = Lists.newArrayList(); for(RexNode pred : RelOptUtil.disjunctions(condition)) { conditions.add(convertToStatsCondition(pred, index, context, scanRel, typesToProcess)); } return RexUtil.composeDisjunction(builder, conditions, false); } else if (condition instanceof RexCall) { // LIKE operator - convert to a RANGE predicate, if possible if (typesToProcess.contains(SqlKind.LIKE) && ((RexCall) condition).getOperator().getKind() == SqlKind.LIKE) { return convertLikeToRange((RexCall)condition, builder); } else if (typesToProcess.contains(SqlKind.CAST) && hasCastExpression(condition)) { return convertCastForFIdx(((RexCall) condition), index, context, scanRel); } else { return condition; } } return condition; }
for (String ref : refsInAllOperands) { commonOperands .add(RexUtil.composeDisjunction(rexBuilder, reductionCondition.get(ref), false));
private RexNode or(Iterable<? extends RexNode> nodes) { return composeDisjunction(rexBuilder, nodes); } }
private RexNode or(Iterable<? extends RexNode> nodes) { return composeDisjunction(rexBuilder, nodes); } }
private RexNode or(Iterable<? extends RexNode> nodes) { return composeDisjunction(rexBuilder, nodes); } }
private RexNode or(Iterable<? extends RexNode> nodes) { return composeDisjunction(rexBuilder, nodes); } }
/** * Converts a collection of expressions into an OR. * If there are zero expressions, returns FALSE. * If there is one expression, returns just that expression. * If any of the expressions are TRUE, returns TRUE. * Removes expressions that always evaluate to FALSE. * Flattens expressions that are ORs. */ @Nonnull public static RexNode composeDisjunction(RexBuilder rexBuilder, Iterable<? extends RexNode> nodes) { final RexNode e = composeDisjunction(rexBuilder, nodes, false); return Objects.requireNonNull(e); }
/** * Converts a collection of expressions into an OR. * If there are zero expressions, returns FALSE. * If there is one expression, returns just that expression. * If any of the expressions are TRUE, returns TRUE. * Removes expressions that always evaluate to FALSE. * Flattens expressions that are ORs. */ @Nonnull public static RexNode composeDisjunction(RexBuilder rexBuilder, Iterable<? extends RexNode> nodes) { final RexNode e = composeDisjunction(rexBuilder, nodes, false); return Objects.requireNonNull(e); }
/** Creates an OR. */ public RexNode or(Iterable<? extends RexNode> operands) { return RexUtil.composeDisjunction(cluster.getRexBuilder(), operands); }
/** Creates an OR. */ public RexNode or(Iterable<? extends RexNode> operands) { return RexUtil.composeDisjunction(cluster.getRexBuilder(), operands); }
@Override public RexNode visitCall(RexCall call) { SqlOperator op = call.getOperator(); SqlKind kind = op.getKind(); RelDataType type = call.getType(); if (kind == SqlKind.AND) { List<RexNode> conjuncts = Lists.newArrayList(); for (RexNode child : call.getOperands()) { conjuncts.addAll(RelOptUtil.conjunctions(child.accept(this))); } return RexUtil.composeConjunction(builder, conjuncts, true); } if (kind == SqlKind.OR) { List<RexNode> disjuncts = Lists.newArrayList(); for (RexNode child : call.getOperands()) { disjuncts.addAll(RelOptUtil.disjunctions(child.accept(this))); } return RexUtil.composeDisjunction(builder, disjuncts, true); } return builder.makeCall(type, op, visitChildren(call)); }
private RexNode simplifyIsNull(RexNode a) { if (!a.getType().isNullable()) { return rexBuilder.makeLiteral(false); } if (RexUtil.isNull(a)) { return rexBuilder.makeLiteral(true); } switch (Strong.policy(a.getKind())) { case NOT_NULL: return rexBuilder.makeLiteral(false); case ANY: // "f" is a strong operator, so "f(operand0, operand1) IS NULL" simplifies // to "operand0 IS NULL OR operand1 IS NULL" final List<RexNode> operands = new ArrayList<>(); for (RexNode operand : ((RexCall) a).getOperands()) { final RexNode simplified = simplifyIsNull(operand); if (simplified == null) { operands.add( rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL, operand)); } else { operands.add(simplified); } } return RexUtil.composeDisjunction(rexBuilder, operands, false); case AS_IS: default: return null; } }
@Override public RexNode visitCall(RexCall call) { SqlOperator op = call.getOperator(); SqlKind kind = op.getKind(); RelDataType type = call.getType(); if (kind == SqlKind.AND) { List<RexNode> conjuncts = Lists.newArrayList(); for (RexNode child : call.getOperands()) { conjuncts.addAll(RelOptUtil.conjunctions(child.accept(this))); } return RexUtil.composeConjunction(builder, conjuncts, true); } if (kind == SqlKind.OR) { List<RexNode> disjuncts = Lists.newArrayList(); for (RexNode child : call.getOperands()) { disjuncts.addAll(RelOptUtil.disjunctions(child.accept(this))); } return RexUtil.composeDisjunction(builder, disjuncts, true); } return builder.makeCall(type, op, visitChildren(call)); }