public class Strong
extends java.lang.Object
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 strong
c1 = 1 OR c2 IS NULL
is strong in [c1] (definitely null if c1
is null)
Modifier and Type | Class and Description |
---|---|
static class |
Strong.Policy
How whether an operator's operands are null affects whether a call to
that operator evaluates to null.
|
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<SqlKind,Strong.Policy> |
MAP |
Constructor and Description |
---|
Strong() |
Modifier and Type | Method and Description |
---|---|
private boolean |
allNull(java.util.List<RexNode> operands)
Returns whether all expressions in a list are definitely null.
|
static boolean |
allStrong(java.util.List<RexNode> operands)
Returns whether all expressions in a list are strong.
|
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 boolean |
isStrong(RexNode e)
Returns whether a given expression is strong.
|
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.
|
private static final java.util.Map<SqlKind,Strong.Policy> MAP
public static Strong of(ImmutableBitSet nullColumns)
public static boolean isNull(RexNode node, ImmutableBitSet nullColumns)
public static boolean isNotTrue(RexNode node, ImmutableBitSet nullColumns)
public static Strong.Policy policy(SqlKind kind)
public static boolean isStrong(RexNode e)
Examples:
c = 1
since it returns null if and only if
c is null
c IS NULL
since it always returns TRUE
or FALSE
e
- Expressionpublic static boolean allStrong(java.util.List<RexNode> operands)
public boolean isNotTrue(RexNode node)
public boolean isNull(RexNode node)
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
"if x
is null, is x + y
null?
public boolean isNull(RexInputRef ref)
private boolean allNull(java.util.List<RexNode> operands)
private boolean anyNull(java.util.List<RexNode> operands)
private static java.util.Map<SqlKind,Strong.Policy> createPolicyMap()
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.