public class RexSimplify extends Object
| Modifier and Type | Field and Description |
|---|---|
RexBuilder |
rexBuilder |
| Constructor and Description |
|---|
RexSimplify(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.
|
| Modifier and Type | Method and Description |
|---|---|
RexNode |
removeNullabilityCast(RexNode e)
Removes any casts that change nullability but not type.
|
RexNode |
simplify(RexNode e)
Simplifies a boolean expression.
|
RexNode |
simplifyAnd(RexCall e)
Deprecated.
|
RexNode |
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.
|
RexNode |
simplifyOr(RexCall call)
Deprecated.
|
RexNode |
simplifyOrs(List<RexNode> terms)
Deprecated.
|
RexNode |
simplifyPreservingType(RexNode e)
Simplifies a boolean expression, always preserving its type and its
nullability.
|
RexNode |
simplifyPreservingType(RexNode e,
RexUnknownAs unknownAs,
boolean matchNullability) |
RexNode |
simplifyUnknownAs(RexNode e,
RexUnknownAs unknownAs)
As
simplify(RexNode), but specifying how UNKNOWN values are to be
treated. |
RexNode |
simplifyUnknownAsFalse(RexNode e)
As
simplify(RexNode), but for a boolean expression
for which a result of UNKNOWN will be treated as FALSE. |
RexSimplify |
withParanoid(boolean paranoid)
Returns a RexSimplify the same as this but which verifies that
the expression before and after simplification are equivalent.
|
RexSimplify |
withPredicates(RelOptPredicateList predicates)
Returns a RexSimplify the same as this but with a specified
predicates value. |
RexSimplify |
withUnknownAsFalse(boolean unknownAsFalse)
Deprecated.
Use methods with a
RexUnknownAs argument, such as
simplify(RexNode, RexUnknownAs). |
public final RexBuilder rexBuilder
public RexSimplify(RexBuilder rexBuilder, RelOptPredicateList predicates, RexExecutor executor)
rexBuilder - Rex builderpredicates - Predicates known to hold on input fieldsexecutor - Executor for constant reduction, not null@Deprecated public RexSimplify(RexBuilder rexBuilder, boolean unknownAsFalse, RexExecutor executor)
@Deprecated public RexSimplify(RexBuilder rexBuilder, RelOptPredicateList predicates, boolean unknownAsFalse, RexExecutor executor)
@Deprecated public RexSimplify withUnknownAsFalse(boolean unknownAsFalse)
RexUnknownAs argument, such as
simplify(RexNode, RexUnknownAs).defaultUnknownAs value.public RexSimplify withPredicates(RelOptPredicateList predicates)
predicates value.public RexSimplify withParanoid(boolean paranoid)
public RexNode simplifyPreservingType(RexNode e)
This is useful if you are simplifying expressions in a
Project.
public RexNode simplifyPreservingType(RexNode e, RexUnknownAs unknownAs, boolean matchNullability)
public RexNode simplify(RexNode e)
In particular:
simplify(x = 1 OR NOT x = 1 OR x IS NULL)
returns TRUEsimplify(x = 1 AND FALSE)
returns FALSEHandles UNKNOWN values using the policy specified when you created this
RexSimplify. Unless you used a deprecated constructor, that policy
is RexUnknownAs.UNKNOWN.
If the expression is a predicate in a WHERE clause, consider instead
using simplifyUnknownAsFalse(RexNode).
e - Expression to simplifypublic final RexNode simplifyUnknownAsFalse(RexNode e)
simplify(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.)
public RexNode simplifyUnknownAs(RexNode e, RexUnknownAs unknownAs)
simplify(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.)
@Deprecated public RexNode simplifyAnds(Iterable<? extends RexNode> nodes)
@Deprecated public RexNode simplifyAnd(RexCall e)
@Deprecated public RexNode simplifyOr(RexCall call)
@Deprecated public RexNode simplifyOrs(List<RexNode> terms)
public RexNode removeNullabilityCast(RexNode e)
For example, CAST(1 = 0 AS BOOLEAN) becomes 1 = 0.
public @Nullable RexNode simplifyFilterPredicates(Iterable<? extends RexNode> predicates)
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.
predicates - Filter condition predicatesCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.