Class RexSimplify
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRexSimplify
(RexBuilder rexBuilder, boolean unknownAsFalse, RexExecutor executor) Deprecated.RexSimplify
(RexBuilder rexBuilder, RelOptPredicateList predicates, boolean unknownAsFalse, RexExecutor executor) Deprecated.RexSimplify
(RexBuilder rexBuilder, RelOptPredicateList predicates, RexExecutor executor) Creates a RexSimplify. -
Method Summary
Modifier and TypeMethodDescriptionRemoves any casts that change nullability but not type.Simplifies a boolean expression.Deprecated.simplifyAnds
(Iterable<? extends RexNode> nodes) Deprecated.@Nullable RexNode
simplifyFilterPredicates
(Iterable<? extends RexNode> predicates) Combines predicates AND, optimizes, and returns null if the result is always false.simplifyOr
(RexCall call) Deprecated.simplifyOrs
(List<RexNode> terms) Deprecated.Simplifies a boolean expression, always preserving its type and its nullability.simplifyPreservingType
(RexNode e, RexUnknownAs unknownAs, boolean matchNullability) simplifyUnknownAs
(RexNode e, RexUnknownAs unknownAs) Assimplify(RexNode)
, but specifying how UNKNOWN values are to be treated.final RexNode
Assimplify(RexNode)
, but for a boolean expression for which a result of UNKNOWN will be treated as FALSE.withParanoid
(boolean paranoid) Returns a RexSimplify the same as this but which verifies that the expression before and after simplification are equivalent.withPredicates
(RelOptPredicateList predicates) Returns a RexSimplify the same as this but with a specifiedpredicates
value.withUnknownAsFalse
(boolean unknownAsFalse) Deprecated.
-
Field Details
-
rexBuilder
-
-
Constructor Details
-
RexSimplify
Creates a RexSimplify.- Parameters:
rexBuilder
- Rex builderpredicates
- Predicates known to hold on input fieldsexecutor
- Executor for constant reduction, not null
-
RexSimplify
Deprecated. -
RexSimplify
@Deprecated public RexSimplify(RexBuilder rexBuilder, RelOptPredicateList predicates, boolean unknownAsFalse, RexExecutor executor) Deprecated.
-
-
Method Details
-
withUnknownAsFalse
Deprecated.Use methods with aRexUnknownAs
argument, such assimplify(RexNode, RexUnknownAs)
.Returns a RexSimplify the same as this but with a specifieddefaultUnknownAs
value. -
withPredicates
Returns a RexSimplify the same as this but with a specifiedpredicates
value. -
withParanoid
Returns a RexSimplify the same as this but which verifies that the expression before and after simplification are equivalent.- See Also:
-
verify(org.apache.calcite.rex.RexNode, org.apache.calcite.rex.RexNode, org.apache.calcite.rex.RexUnknownAs)
-
simplifyPreservingType
Simplifies a boolean expression, always preserving its type and its nullability.This is useful if you are simplifying expressions in a
Project
. -
simplifyPreservingType
-
simplify
Simplifies a boolean expression.In particular:
simplify(x = 1 OR NOT x = 1 OR x IS NULL)
returnsTRUE
simplify(x = 1 AND FALSE)
returnsFALSE
Handles UNKNOWN values using the policy specified when you created this
RexSimplify
. Unless you used a deprecated constructor, that policy isRexUnknownAs.UNKNOWN
.If the expression is a predicate in a WHERE clause, consider instead using
simplifyUnknownAsFalse(RexNode)
.- Parameters:
e
- Expression to simplify
-
simplifyUnknownAsFalse
Assimplify(RexNode)
, but for a boolean expression for which a result of UNKNOWN will be treated as FALSE.Use this form for expressions on a WHERE, ON, HAVING or FILTER(WHERE) clause.
This may allow certain additional simplifications. A result of UNKNOWN may yield FALSE, however it may still yield UNKNOWN. (If the simplified expression has type BOOLEAN NOT NULL, then of course it can only return FALSE.)
-
simplifyUnknownAs
Assimplify(RexNode)
, but specifying how UNKNOWN values are to be treated.If UNKNOWN is treated as FALSE, this may allow certain additional simplifications. A result of UNKNOWN may yield FALSE, however it may still yield UNKNOWN. (If the simplified expression has type BOOLEAN NOT NULL, then of course it can only return FALSE.)
-
simplifyAnds
Deprecated.Simplifies a conjunction of boolean expressions. -
simplifyAnd
Deprecated. -
simplifyOr
Deprecated.Simplifies OR(x, x) into x, and similar. The simplified expression returns UNKNOWN values as is (not as FALSE). -
simplifyOrs
Deprecated.Simplifies a list of terms and combines them into an OR. Modifies the list in place. The simplified expression returns UNKNOWN values as is (not as FALSE). -
removeNullabilityCast
Removes any casts that change nullability but not type.For example,
CAST(1 = 0 AS BOOLEAN)
becomes1 = 0
. -
simplifyFilterPredicates
Combines predicates AND, optimizes, and returns null if the result is always false.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.
- Parameters:
predicates
- Filter condition predicates- Returns:
- simplified conjunction of predicates for the filter, null if always false
-
RexUnknownAs
argument, such assimplify(RexNode, RexUnknownAs)
.