/** * 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); }