final RexSimplify simplify = new RexSimplify(rexBuilder, true, executor); final RexNode x = simplify.simplifyAnds(listBuilder.build()); if (x.isAlwaysFalse()) {
/** * Simplifies a conjunction of boolean expressions. */ public RexNode simplifyAnds(Iterable<? extends RexNode> nodes) { return simplifyAnds(nodes, defaultUnknownAs); }
/** Creates an AND. * * <p>Simplifies the expression a little: * {@code e AND TRUE} becomes {@code e}; * {@code e AND e2 AND NOT e} becomes {@code e2}. */ public RexNode and(Iterable<? extends RexNode> operands) { return simplifier.simplifyAnds(operands); }
/** * Simplifies a conjunction of boolean expressions. */ public RexNode simplifyAnds(Iterable<? extends RexNode> nodes) { return simplifyAnds(nodes, defaultUnknownAs); }
/** Creates an AND. * * <p>Simplifies the expression a little: * {@code e AND TRUE} becomes {@code e}; * {@code e AND e2 AND NOT e} becomes {@code e2}. */ public RexNode and(Iterable<? extends RexNode> operands) { return simplifier.simplifyAnds(operands); }
/** * Simplifies a conjunction of boolean expressions. * * @deprecated Use * {@link RexSimplify#simplifyAnds(Iterable, RexUnknownAs)}. */ @Deprecated // to be removed before 2.0 public static RexNode simplifyAnds(RexBuilder rexBuilder, Iterable<? extends RexNode> nodes) { return new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, EXECUTOR) .simplifyAnds(nodes, RexUnknownAs.UNKNOWN); }
/** * Simplifies a conjunction of boolean expressions. * * @deprecated Use * {@link RexSimplify#simplifyAnds(Iterable, RexUnknownAs)}. */ @Deprecated // to be removed before 2.0 public static RexNode simplifyAnds(RexBuilder rexBuilder, Iterable<? extends RexNode> nodes) { return new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, EXECUTOR) .simplifyAnds(nodes, RexUnknownAs.UNKNOWN); }
@Deprecated // to be removed before 2.0 public static RexNode simplifyAnds(RexBuilder rexBuilder, Iterable<? extends RexNode> nodes, boolean unknownAsFalse) { return new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, EXECUTOR) .simplifyAnds(nodes, RexUnknownAs.falseIf(unknownAsFalse)); }
@Deprecated // to be removed before 2.0 public static RexNode simplifyAnds(RexBuilder rexBuilder, Iterable<? extends RexNode> nodes, boolean unknownAsFalse) { return new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, EXECUTOR) .simplifyAnds(nodes, RexUnknownAs.falseIf(unknownAsFalse)); }
/** * Combines predicates AND, optimizes, and returns null if the result is * always false. * * <p>The expression is simplified on the assumption that an UNKNOWN value * is always treated as FALSE. Therefore the simplified expression may * sometimes evaluate to FALSE where the original expression would evaluate to * UNKNOWN. * * @param predicates Filter condition predicates * @return simplified conjunction of predicates for the filter, null if always false */ public RexNode simplifyFilterPredicates(Iterable<? extends RexNode> predicates) { final RexNode simplifiedAnds = withPredicateElimination(Bug.CALCITE_2401_FIXED) .simplifyAnds(predicates, FALSE); if (simplifiedAnds.isAlwaysFalse()) { return null; } // Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts // nullable and not-nullable conditions, but a CAST might get in the way of // other rewrites. return removeNullabilityCast(simplifiedAnds); }
/** * Combines predicates AND, optimizes, and returns null if the result is * always false. * * <p>The expression is simplified on the assumption that an UNKNOWN value * is always treated as FALSE. Therefore the simplified expression may * sometimes evaluate to FALSE where the original expression would evaluate to * UNKNOWN. * * @param predicates Filter condition predicates * @return simplified conjunction of predicates for the filter, null if always false */ public RexNode simplifyFilterPredicates(Iterable<? extends RexNode> predicates) { final RexNode simplifiedAnds = withPredicateElimination(Bug.CALCITE_2401_FIXED) .simplifyAnds(predicates, FALSE); if (simplifiedAnds.isAlwaysFalse()) { return null; } // Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts // nullable and not-nullable conditions, but a CAST might get in the way of // other rewrites. return removeNullabilityCast(simplifiedAnds); }