Package org.apache.calcite.plan
Class Strong
- java.lang.Object
-
- org.apache.calcite.plan.Strong
-
public class Strong extends java.lang.Object
Utilities for strong predicates.A predicate is strong (or null-rejecting) if it is UNKNOWN if any of its inputs is UNKNOWN.
By the way, UNKNOWN is just the boolean form of NULL.
Examples:
UNKNOWN
is strong in [] (definitely null)c = 1
is strong in [c] (definitely null if and only if c is null)c IS NULL
is not strong (always returns TRUE or FALSE, never null)p1 AND p2
is strong in [p1, p2] (definitely null if either p1 is null or p2 is null)p1 OR p2
is strong if p1 and p2 are strongc1 = 1 OR c2 IS NULL
is strong in [c1] (definitely null if c1 is null)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Strong.Policy
How whether an operator's operands are null affects whether a call to that operator evaluates to null.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<SqlKind,Strong.Policy>
MAP
-
Constructor Summary
Constructors Constructor Description Strong()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
allNull(java.util.List<RexNode> operands)
Returns whether all expressions in a list are definitely null.private boolean
anyNull(java.util.List<RexNode> operands)
Returns whether any expressions in a list are definitely null.private static java.util.Map<SqlKind,Strong.Policy>
createPolicyMap()
boolean
isNotTrue(RexNode node)
Returns whether an expression is definitely not true.static boolean
isNotTrue(RexNode node, ImmutableBitSet nullColumns)
Returns whether the analyzed expression will definitely not return true (equivalently, will definitely not return null or false) if all of a given set of input columns are null.boolean
isNull(RexInputRef ref)
Returns whether a given input is definitely null.boolean
isNull(RexNode node)
Returns whether an expression is definitely null.static boolean
isNull(RexNode node, ImmutableBitSet nullColumns)
Returns whether the analyzed expression will definitely return null if all of a given set of input columns are null.static Strong
of(ImmutableBitSet nullColumns)
Returns a checker that consults a bit set to find out whether particular inputs may be null.static Strong.Policy
policy(SqlKind kind)
Returns how to deduce whether a particular kind of expression is null, given whether its arguments are null.
-
-
-
Field Detail
-
MAP
private static final java.util.Map<SqlKind,Strong.Policy> MAP
-
-
Method Detail
-
of
public static Strong of(ImmutableBitSet nullColumns)
Returns a checker that consults a bit set to find out whether particular inputs may be null.
-
isNull
public static boolean isNull(RexNode node, ImmutableBitSet nullColumns)
Returns whether the analyzed expression will definitely return null if all of a given set of input columns are null.
-
isNotTrue
public static boolean isNotTrue(RexNode node, ImmutableBitSet nullColumns)
Returns whether the analyzed expression will definitely not return true (equivalently, will definitely not return null or false) if all of a given set of input columns are null.
-
policy
public static Strong.Policy policy(SqlKind kind)
Returns how to deduce whether a particular kind of expression is null, given whether its arguments are null.
-
isNotTrue
public boolean isNotTrue(RexNode node)
Returns whether an expression is definitely not true.
-
isNull
public boolean isNull(RexNode node)
Returns whether an expression is definitely null.The answer is based on calls to
isNull(org.apache.calcite.rex.RexNode, org.apache.calcite.util.ImmutableBitSet)
for its constituent expressions, and you may override methods to test hypotheses such as "ifx
is null, isx + y
null?
-
isNull
public boolean isNull(RexInputRef ref)
Returns whether a given input is definitely null.
-
allNull
private boolean allNull(java.util.List<RexNode> operands)
Returns whether all expressions in a list are definitely null.
-
anyNull
private boolean anyNull(java.util.List<RexNode> operands)
Returns whether any expressions in a list are definitely null.
-
createPolicyMap
private static java.util.Map<SqlKind,Strong.Policy> createPolicyMap()
-
-