private void simplifyAndTerms(List<RexNode> terms) { RexSimplify simplify = this; for (int i = 0; i < terms.size(); i++) { RexNode t = terms.get(i); if (Predicate.of(t) == null) { continue; } terms.set(i, simplify.simplify(t, UNKNOWN)); RelOptPredicateList newPredicates = simplify.predicates.union(rexBuilder, RelOptPredicateList.of(rexBuilder, terms.subList(i, i + 1))); simplify = simplify.withPredicates(newPredicates); } for (int i = 0; i < terms.size(); i++) { RexNode t = terms.get(i); if (Predicate.of(t) != null) { continue; } terms.set(i, simplify.simplify(t, UNKNOWN)); } }
private void simplifyAndTerms(List<RexNode> terms) { RexSimplify simplify = this; for (int i = 0; i < terms.size(); i++) { RexNode t = terms.get(i); if (Predicate.of(t) == null) { continue; } terms.set(i, simplify.simplify(t, UNKNOWN)); RelOptPredicateList newPredicates = simplify.predicates.union(rexBuilder, RelOptPredicateList.of(rexBuilder, terms.subList(i, i + 1))); simplify = simplify.withPredicates(newPredicates); } for (int i = 0; i < terms.size(); i++) { RexNode t = terms.get(i); if (Predicate.of(t) != null) { continue; } terms.set(i, simplify.simplify(t, UNKNOWN)); } }
private void simplifyOrTerms(List<RexNode> terms) { // Suppose we are processing "e1(x) OR e2(x) OR e3(x)". When we are // visiting "e3(x)" we know both "e1(x)" and "e2(x)" are not true (they // may be unknown), because if either of them were true we would have // stopped. RexSimplify simplify = this; for (int i = 0; i < terms.size(); i++) { final RexNode t = terms.get(i); if (Predicate.of(t) == null) { continue; } final RexNode t2 = simplify.simplify(t, RexUnknownAs.UNKNOWN); terms.set(i, t2); final RexNode inverse = simplify.simplify(rexBuilder.makeCall(SqlStdOperatorTable.NOT, t2), RexUnknownAs.UNKNOWN); final RelOptPredicateList newPredicates = simplify.predicates.union(rexBuilder, RelOptPredicateList.of(rexBuilder, ImmutableList.of(inverse))); simplify = simplify.withPredicates(newPredicates); } for (int i = 0; i < terms.size(); i++) { final RexNode t = terms.get(i); if (Predicate.of(t) != null) { continue; } terms.set(i, simplify.simplify(t, RexUnknownAs.UNKNOWN)); } }
private void simplifyOrTerms(List<RexNode> terms) { // Suppose we are processing "e1(x) OR e2(x) OR e3(x)". When we are // visiting "e3(x)" we know both "e1(x)" and "e2(x)" are not true (they // may be unknown), because if either of them were true we would have // stopped. RexSimplify simplify = this; for (int i = 0; i < terms.size(); i++) { final RexNode t = terms.get(i); if (Predicate.of(t) == null) { continue; } final RexNode t2 = simplify.simplify(t, RexUnknownAs.UNKNOWN); terms.set(i, t2); final RexNode inverse = simplify.simplify(rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_TRUE, t2), RexUnknownAs.UNKNOWN); final RelOptPredicateList newPredicates = simplify.predicates.union(rexBuilder, RelOptPredicateList.of(rexBuilder, ImmutableList.of(inverse))); simplify = simplify.withPredicates(newPredicates); } for (int i = 0; i < terms.size(); i++) { final RexNode t = terms.get(i); if (Predicate.of(t) != null) { continue; } terms.set(i, simplify.simplify(t, RexUnknownAs.UNKNOWN)); } }
private void checkSimplifyFilter(RexNode node, RelOptPredicateList predicates, String expected) { final RexNode simplified = simplify.withPredicates(predicates) .simplifyUnknownAs(node, RexUnknownAs.FALSE); assertThat(simplified.toString(), equalTo(expected)); }
private void checkSimplifyFilter(RexNode node, RelOptPredicateList predicates, String expected) { final RexNode simplified = simplify.withPredicates(predicates) .simplifyUnknownAs(node, RexUnknownAs.FALSE); assertThat(simplified.toString(), equalTo(expected)); }
RexSimplify condSimplifier = this.withPredicates(RelOptPredicateList.EMPTY); RexSimplify valueSimplifier = this; RelDataType caseType = call.getType();