Enum RexUnknownAs
- java.lang.Object
-
- java.lang.Enum<RexUnknownAs>
-
- org.apache.calcite.rex.RexUnknownAs
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<RexUnknownAs>
public enum RexUnknownAs extends java.lang.Enum<RexUnknownAs>
Policy for whether a simplified expression may instead return another value.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.
- See Also:
RexSimplify
-
-
Enum Constant Summary
Enum Constants Enum Constant 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.
-
Constructor Summary
Constructors Modifier Constructor Description private
RexUnknownAs()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RexUnknownAs
falseIf(boolean unknownAsFalse)
boolean
toBoolean()
static RexUnknownAs
valueOf(java.lang.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.
-
-
-
Enum Constant Detail
-
FALSE
public static final RexUnknownAs 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. Therefore, when simplifying the expression, it is acceptable for the simplified expression to evaluate to FALSE in some situations where the original expression would evaluate to UNKNOWN.SQL predicates (
WHERE
,ON
,HAVING
andFILTER (WHERE)
clauses, aWHEN
clause of aCASE
expression, and inCHECK
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
.
-
TRUE
public static final RexUnknownAs 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. Therefore, when simplifying the expression, it is acceptable for the simplified expression to evaluate to TRUE in some situations where the original expression would evaluate to UNKNOWN.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
.
-
UNKNOWN
public static final RexUnknownAs UNKNOWN
Policy that indicates that the expression is being used in a context Where an UNKNOWN value is treated as is. This occurs:- In any expression whose type is not
BOOLEAN
- In
BOOLEAN
expressions that areNOT NULL
- In
BOOLEAN
expressions whereUNKNOWN
should be returned as is, for example in aSELECT
clause, or within an expression such as an operand toAND
,OR
orNOT
If you are unsure, use UNKNOWN. It is the safest option.
- In any expression whose type is not
-
-
Method Detail
-
values
public static RexUnknownAs[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (RexUnknownAs c : RexUnknownAs.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static RexUnknownAs valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
falseIf
@Nonnull public static RexUnknownAs falseIf(boolean unknownAsFalse)
-
toBoolean
public boolean toBoolean()
-
-