public enum RexUnknownAs extends Enum<RexUnknownAs>
In particular, it deals with converting three-valued logic (TRUE, FALSE, UNKNOWN) to two-valued logic (TRUE, FALSE) for callers that treat the UNKNOWN value the same as TRUE or FALSE.
Sometimes the three-valued version of the expression is simpler (has a smaller expression tree) than the two-valued version. In these cases, favor simplicity over reduction to two-valued logic.
RexSimplify| Enum Constant and Description |
|---|
FALSE
Policy that indicates that the expression is being used in a context
Where an UNKNOWN value is treated in the same way as FALSE.
|
TRUE
Policy that indicates that the expression is being used in a context
Where an UNKNOWN value is treated in the same way as TRUE.
|
UNKNOWN
Policy that indicates that the expression is being used in a context
Where an UNKNOWN value is treated as is.
|
| Modifier and Type | Method and Description |
|---|---|
static RexUnknownAs |
falseIf(boolean unknownAsFalse)
|
RexUnknownAs |
negate() |
RexUnknownAs |
or(RexUnknownAs other)
Combines this with another
RexUnknownAs in the same way as the
three-valued logic of OR. |
boolean |
toBoolean() |
static RexUnknownAs |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static RexUnknownAs[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final RexUnknownAs FALSE
SQL predicates (WHERE, ON, HAVING and
FILTER (WHERE) clauses, a WHEN clause of a CASE
expression, and in CHECK constraints) all treat UNKNOWN as FALSE.
If the simplified expression never returns UNKNOWN, the simplifier
should make this clear to the caller, if possible, by marking its type as
BOOLEAN NOT NULL.
public static final RexUnknownAs TRUE
This does not occur commonly in SQL. However, it occurs internally
during simplification. For example, "WHERE NOT expression"
evaluates "NOT expression" in a context that treats UNKNOWN as
FALSE; it is useful to consider that "expression" is evaluated in a
context that treats UNKNOWN as TRUE.
If the simplified expression never returns UNKNOWN, the simplifier
should make this clear to the caller, if possible, by marking its type as
BOOLEAN NOT NULL.
public static final RexUnknownAs UNKNOWN
BOOLEAN
BOOLEAN expressions that are NOT NULL
BOOLEAN expressions where UNKNOWN should be
returned as is, for example in a SELECT clause, or within an
expression such as an operand to AND, OR or
NOT
If you are unsure, use UNKNOWN. It is the safest option.
public static RexUnknownAs[] values()
for (RexUnknownAs c : RexUnknownAs.values()) System.out.println(c);
public static RexUnknownAs valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static RexUnknownAs falseIf(boolean unknownAsFalse)
public boolean toBoolean()
public RexUnknownAs negate()
public RexUnknownAs or(RexUnknownAs other)
RexUnknownAs in the same way as the
three-valued logic of OR.
For example, TRUE or FALSE returns TRUE;
FALSE or UNKNOWN returns UNKNOWN.
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.