Class OperandTypes
This class defines singleton instances of strategy objects for operand
type-checking. ReturnTypes
and InferTypes
provide similar strategies
for operand type inference and operator return type inference.
Note to developers: avoid anonymous inner classes here except for unique, non-generalizable strategies; anything else belongs in a reusable top-level class. If you find yourself copying and pasting an existing strategy's anonymous inner class, you're making a mistake.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlOperandTypeChecker
Operand type-checking strategy used byARG_MIN(value, comp)
and similar functions, where the first operand can have any type and the second must be comparable.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy where the first operand must be array and the second operand must be a boolean non-NULL literal.static final SqlOperandTypeChecker
static final SqlOperandTypeChecker
static final SqlOperandTypeChecker
static final SqlOperandTypeChecker
static final SqlOperandTypeChecker
Type checker that accepts an ARRAY as the first argument, but not an expression with type NULL (i.e.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlOperandTypeChecker
Operand type-checking strategy where any positive number of operands must all be in the same type family.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy type must be a boolean non-NULL literal.static final SqlSingleOperandTypeChecker
Operand type-checking strategy where the first operand is a character or binary string (CHAR, VARCHAR, BINARY or VARBINARY), and the second operand is INTEGER.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Checks that returns whether a value is a multiset or an array.static final SqlSingleOperandTypeChecker
static final SqlOperandTypeChecker
Operand type-checking strategy where operand type must allow ordered comparisons.static final SqlOperandTypeChecker
Operand type-checking strategy where operand types must allow ordered comparisons.static final SqlOperandTypeChecker
Operand type-checking strategy where operand types must allow unordered comparisons.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Type-checking strategy for the "/" operator.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final FamilyOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Parameter type-checking strategy where type must a nullable time interval, nullable time interval.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy type must be a non-NULL literal.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlOperandTypeChecker
static final FamilyOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Type-checking strategy for the "*" operator.static final SqlSingleOperandTypeChecker
static final SqlOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy for an operator which takes no operands.static final SqlSingleOperandTypeChecker
Operand type-checking strategy where all types must be non-NULL value.static final SqlSingleOperandTypeChecker
Operand type-checking strategy where type must be a literal or NULL.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy where the first operand must be numeric and the second operand must be a numeric non-NULL literal in the range 0 to 1 inclusive.static final SqlOperandTypeChecker
Operand type-checking strategy that allows one or more operands.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy type must be a positive integer non-NULL literal.static final SqlSingleOperandTypeChecker
Checker that returns whether a value is a multiset of records or an array of records.static final SqlOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy where two operands must both be in the same type family.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy where three operands must all be in the same type family.static final SqlOperandTypeChecker
Operand type-checking strategy where any number of operands must all be in the same type family.static final SqlSingleOperandTypeChecker
Checker that returns whether a value is a collection (multiset or array) of scalar or record values.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy where the second and third operands must be comparable.static final SqlOperandTypeChecker
Operand type-checking strategy for a set operator (UNION, INTERSECT, EXCEPT).static final SqlSingleOperandTypeChecker
static final SqlOperandTypeChecker
static final SqlOperandTypeChecker
Operand type-checking strategy that the first argument is of string type, and the remaining arguments can be any type.static final SqlOperandTypeChecker
Operand type-checking strategy that the first argument is of string type, and the remaining arguments can be of string or array of string type.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final FamilyOperandTypeChecker
static final FamilyOperandTypeChecker
static final FamilyOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy where two operands must both be in the same string type family.static final SqlSingleOperandTypeChecker
Operand type-checking strategy where two operands must both be in the same string type family and last type is INTEGER.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy where three operands must all be in the same string type family.static final FamilyOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final FamilyOperandTypeChecker
static final FamilyOperandTypeChecker
static final FamilyOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Type-checker that matches "TIMESTAMP WITH LOCAL TIME ZONE" but not other members of the "TIMESTAMP" family (e.g.static final SqlSingleOperandTypeChecker
Type-checker that matches "TIMESTAMP" but not other members of the "TIMESTAMP" family (e.g.static final SqlSingleOperandTypeChecker
static final SqlSingleOperandTypeChecker
Operand type-checking strategy where type must be a numeric non-NULL literal in the range 0 to 1 inclusive.static final SqlOperandTypeChecker
Operand type-checking strategy for an operator with no restrictions on number or type of operands. -
Method Summary
Modifier and TypeMethodDescriptionstatic SqlOperandTypeChecker
and
(SqlOperandTypeChecker... rules) Creates a checker that passes if all of the rules pass.static SqlSingleOperandTypeChecker
and
(SqlSingleOperandTypeChecker... rules) Creates a single-operand checker that passes if all of the rules pass.static SqlSingleOperandTypeChecker
Creates a checker for DATE intervals (YEAR, WEEK, ISOWEEK, WEEK_WEDNESDAY, etc.)static FamilyOperandTypeChecker
family
(List<SqlTypeFamily> families) Creates a checker that passes if each operand is a member of a corresponding family.static FamilyOperandTypeChecker
family
(List<SqlTypeFamily> families, Predicate<Integer> optional) Creates a checker that passes if each operand is a member of a corresponding family, and allows specified parameters to be optional.static FamilyOperandTypeChecker
family
(SqlTypeFamily... families) Creates a checker that passes if each operand is a member of a corresponding family.static SqlSingleOperandTypeChecker
function
(SqlTypeFamily returnTypeFamily, List<SqlTypeFamily> paramTypeFamilies) Creates a checker that passes if the operand is a function with a given return type and parameter types.static SqlSingleOperandTypeChecker
function
(SqlTypeFamily returnTypeFamily, SqlTypeFamily... paramTypeFamilies) Creates a checker that passes if the operand is a function with a given return type and parameter types.static SqlSingleOperandTypeChecker
Creates a checker that passes if the operand is an interval appropriate for a given date/time type.static SqlOperandTypeChecker
nth
(int ordinal, int operandCount, SqlSingleOperandTypeChecker rule) Creates an operand checker that applies a single-operand checker to theordinal
th operand.static SqlOperandMetadata
operandMetadata
(List<SqlTypeFamily> families, Function<RelDataTypeFactory, List<RelDataType>> typesFactory, IntFunction<String> operandName, Predicate<Integer> optional) Creates a checker for user-defined functions (including user-defined aggregate functions, table functions, and table macros).static SqlOperandTypeChecker
or
(SqlOperandTypeChecker... rules) Creates a checker that passes if any one of the rules passes.static SqlSingleOperandTypeChecker
or
(SqlSingleOperandTypeChecker... rules) Creates a single-operand checker that passes if any one of the rules passes.static SqlOperandTypeChecker
repeat
(SqlOperandCountRange range, SqlSingleOperandTypeChecker... rules) Creates a checker that passes if all of the rules pass for each operand, using a given operand count strategy.static SqlSingleOperandTypeChecker
same
(int operandCount, int... ordinals) Operand type-checking strategy where a given list of operands must all have the same type.static SqlOperandTypeChecker
sequence
(String allowedSignatures, SqlSingleOperandTypeChecker... rules) Creates an operand checker from a sequence of single-operand checkers.static SqlOperandTypeChecker
sequence
(BiFunction<SqlOperator, String, String> signatureGenerator, SqlSingleOperandTypeChecker... rules) Creates an operand checker from a sequence of single-operand checkers, generating the signature from the components.static SqlSingleOperandTypeChecker
Creates a checker for TIME intervals (HOUR, SECOND, etc.)static SqlSingleOperandTypeChecker
Creates a checker for TIMESTAMP intervals (YEAR, WEEK, ISOWEEK, WEEK_WEDNESDAY, HOUR, SECOND, etc.)static SqlSingleOperandTypeChecker
typeName
(SqlTypeName typeName) Creates a single-operand checker that passes if the operand's type has a particularSqlTypeName
.static SqlOperandTypeChecker
variadic
(SqlOperandCountRange range)
-
Field Details
-
NILADIC
Operand type-checking strategy for an operator which takes no operands. -
VARIADIC
Operand type-checking strategy for an operator with no restrictions on number or type of operands. -
ONE_OR_MORE
Operand type-checking strategy that allows one or more operands. -
BOOLEAN
-
BOOLEAN_BOOLEAN
-
NUMERIC
-
INTEGER
-
INTEGER_INTEGER
-
NUMERIC_OPTIONAL_NUMERIC
-
NUMERIC_OPTIONAL_INTEGER
-
NUMERIC_INT32
-
NUMERIC_CHARACTER
-
NUMERIC_INTEGER
-
NUMERIC_NUMERIC
-
EXACT_NUMERIC
-
EXACT_NUMERIC_EXACT_NUMERIC
-
BINARY
-
BINARY_BINARY
-
STRING
-
STRING_STRING
-
STRING_OPTIONAL_STRING
-
STRING_STRING_STRING
-
STRING_STRING_OPTIONAL_STRING
-
STRING_OPTIONAL_STRING_OPTIONAL_STRING
-
STRING_STRING_STRING_STRING
-
STRING_NUMERIC_OPTIONAL_STRING
-
CHARACTER
-
DATETIME
-
DATE
-
TIME
-
TIMESTAMP
-
DATE_OR_TIMESTAMP
-
TIMESTAMP_LTZ
Type-checker that matches "TIMESTAMP WITH LOCAL TIME ZONE" but not other members of the "TIMESTAMP" family (e.g. "TIMESTAMP"). -
TIMESTAMP_NTZ
Type-checker that matches "TIMESTAMP" but not other members of the "TIMESTAMP" family (e.g. "TIMESTAMP WITH LOCAL TIME ZONE"). -
INTERVAL
-
CHARACTER_CHARACTER
-
CHARACTER_CHARACTER_DATETIME
-
CHARACTER_DATE
-
CHARACTER_TIME
-
PERIOD
-
PERIOD_OR_DATETIME
-
INTERVAL_INTERVAL
-
MULTISET
-
ARRAY
-
ARRAY_ARRAY
-
ARRAY_OR_MAP
-
STRING_ARRAY_CHARACTER_OPTIONAL_CHARACTER
-
ARRAY_OF_INTEGER
-
STRING_FIRST_OBJECT_REPEAT
Operand type-checking strategy that the first argument is of string type, and the remaining arguments can be any type. -
STRING_FIRST_STRING_ARRAY_REPEAT
Operand type-checking strategy that the first argument is of string type, and the remaining arguments can be of string or array of string type. -
COLLECTION
Checks that returns whether a value is a multiset or an array. Cf Java, where list and set are collections but a map is not. -
COLLECTION_OR_MAP
-
MAP
-
ARRAY_FUNCTION
-
ARRAY_ELEMENT
-
ARRAY_ELEMENT_NONNULL
-
ARRAY_NONNULL
Type checker that accepts an ARRAY as the first argument, but not an expression with type NULL (i.e. a NULL literal). -
ARRAY_INSERT
-
MAP_FROM_ENTRIES
-
MAP_FUNCTION
-
MAP_KEY
-
NULLABLE_LITERAL
Operand type-checking strategy where type must be a literal or NULL. -
LITERAL
Operand type-checking strategy type must be a non-NULL literal. -
NONNULL_NONNULL
Operand type-checking strategy where all types must be non-NULL value. -
BOOLEAN_LITERAL
Operand type-checking strategy type must be a boolean non-NULL literal. -
ARRAY_BOOLEAN_LITERAL
Operand type-checking strategy where the first operand must be array and the second operand must be a boolean non-NULL literal. -
POSITIVE_INTEGER_LITERAL
Operand type-checking strategy type must be a positive integer non-NULL literal. -
UNIT_INTERVAL_NUMERIC_LITERAL
Operand type-checking strategy where type must be a numeric non-NULL literal in the range 0 to 1 inclusive. -
NUMERIC_UNIT_INTERVAL_NUMERIC_LITERAL
Operand type-checking strategy where the first operand must be numeric and the second operand must be a numeric non-NULL literal in the range 0 to 1 inclusive. -
SAME_SAME
Operand type-checking strategy where two operands must both be in the same type family. -
SAME_SAME_INTEGER
-
SAME_SAME_SAME
Operand type-checking strategy where three operands must all be in the same type family. -
SAME_VARIADIC
Operand type-checking strategy where any number of operands must all be in the same type family. -
AT_LEAST_ONE_SAME_VARIADIC
Operand type-checking strategy where any positive number of operands must all be in the same type family. -
COMPARABLE_ORDERED_COMPARABLE_ORDERED
Operand type-checking strategy where operand types must allow ordered comparisons. -
COMPARABLE_ORDERED
Operand type-checking strategy where operand type must allow ordered comparisons. Used when instance comparisons are made on single operand functions -
COMPARABLE_UNORDERED_COMPARABLE_UNORDERED
Operand type-checking strategy where operand types must allow unordered comparisons. -
STRING_SAME_SAME
Operand type-checking strategy where two operands must both be in the same string type family. -
STRING_SAME_SAME_SAME
Operand type-checking strategy where three operands must all be in the same string type family. -
STRING_STRING_INTEGER
-
STRING_STRING_INTEGER_INTEGER
-
STRING_STRING_OPTIONAL_INTEGER_OPTIONAL_INTEGER
-
STRING_STRING_OPTIONAL_INTEGER_OPTIONAL_INTEGER_OPTIONAL_INTEGER
public static final SqlSingleOperandTypeChecker STRING_STRING_OPTIONAL_INTEGER_OPTIONAL_INTEGER_OPTIONAL_INTEGER -
STRING_INTEGER
-
STRING_INTEGER_INTEGER
-
STRING_INTEGER_OPTIONAL_INTEGER
-
STRING_NUMERIC
-
STRING_NUMERIC_NUMERIC
-
CBSTRING_INTEGER
Operand type-checking strategy where the first operand is a character or binary string (CHAR, VARCHAR, BINARY or VARBINARY), and the second operand is INTEGER. -
STRING_SAME_SAME_INTEGER
Operand type-checking strategy where two operands must both be in the same string type family and last type is INTEGER. -
STRING_SAME_SAME_OR_ARRAY_SAME_SAME
-
ANY
-
ANY_ANY
-
SECOND_THIRD_SAME
Operand type-checking strategy where the second and third operands must be comparable. This is used when the operator has three operands and only the second and third operands need to be comparable. -
ANY_IGNORE
-
IGNORE_ANY
-
ANY_NUMERIC
-
ANY_NUMERIC_ANY
-
ANY_STRING_STRING
-
ANY_STRING_OPTIONAL_STRING
-
ANY_COMPARABLE
Operand type-checking strategy used byARG_MIN(value, comp)
and similar functions, where the first operand can have any type and the second must be comparable. -
CURSOR
-
MEASURE
-
MEASURE_BOOLEAN
-
INTERVAL_SAME_SAME
Parameter type-checking strategy where type must a nullable time interval, nullable time interval. -
NUMERIC_INTERVAL
-
INTERVAL_NUMERIC
-
TIME_INTERVAL
-
TIMESTAMP_INTERVAL
-
DATE_INTERVAL
-
DATE_ANY
-
DATE_CHARACTER
-
DATE_TIME
-
DATETIME_INTERVAL
-
TIMESTAMP_STRING
-
DATETIME_INTERVAL_INTERVAL
-
DATETIME_INTERVAL_INTERVAL_TIME
-
DATETIME_INTERVAL_TIME
-
INTERVAL_DATETIME
-
INTERVALINTERVAL_INTERVALDATETIME
-
PLUS_OPERATOR
-
MULTIPLY_OPERATOR
Type-checking strategy for the "*" operator. -
DIVISION_OPERATOR
Type-checking strategy for the "/" operator. -
MINUS_OPERATOR
-
MINUS_DATE_OPERATOR
-
NUMERIC_OR_INTERVAL
-
NUMERIC_OR_STRING
-
RECORD_COLLECTION
Checker that returns whether a value is a multiset of records or an array of records.- See Also:
-
EXISTS
-
SCALAR_OR_RECORD_COLLECTION
Checker that returns whether a value is a collection (multiset or array) of scalar or record values. -
SCALAR_OR_RECORD_COLLECTION_OR_MAP
-
MULTISET_MULTISET
-
SET_OP
Operand type-checking strategy for a set operator (UNION, INTERSECT, EXCEPT). -
RECORD_TO_SCALAR
-
-
Method Details
-
family
Creates a checker that passes if each operand is a member of a corresponding family. -
family
public static FamilyOperandTypeChecker family(List<SqlTypeFamily> families, Predicate<Integer> optional) Creates a checker that passes if each operand is a member of a corresponding family, and allows specified parameters to be optional. -
family
Creates a checker that passes if each operand is a member of a corresponding family. -
function
public static SqlSingleOperandTypeChecker function(SqlTypeFamily returnTypeFamily, SqlTypeFamily... paramTypeFamilies) Creates a checker that passes if the operand is a function with a given return type and parameter types. This method can be used to check a lambda expression. -
function
public static SqlSingleOperandTypeChecker function(SqlTypeFamily returnTypeFamily, List<SqlTypeFamily> paramTypeFamilies) Creates a checker that passes if the operand is a function with a given return type and parameter types. This method can be used to check a lambda expression. -
typeName
Creates a single-operand checker that passes if the operand's type has a particularSqlTypeName
. -
interval
public static SqlSingleOperandTypeChecker interval(Iterable<org.apache.calcite.avatica.util.TimeUnitRange> ranges) Creates a checker that passes if the operand is an interval appropriate for a given date/time type. For example, the time frame HOUR is appropriate for type TIMESTAMP or DATE but not TIME. -
dateInterval
Creates a checker for DATE intervals (YEAR, WEEK, ISOWEEK, WEEK_WEDNESDAY, etc.) -
timeInterval
Creates a checker for TIME intervals (HOUR, SECOND, etc.) -
timestampInterval
Creates a checker for TIMESTAMP intervals (YEAR, WEEK, ISOWEEK, WEEK_WEDNESDAY, HOUR, SECOND, etc.) -
operandMetadata
public static SqlOperandMetadata operandMetadata(List<SqlTypeFamily> families, Function<RelDataTypeFactory, List<RelDataType>> typesFactory, IntFunction<String> operandName, Predicate<Integer> optional) Creates a checker for user-defined functions (including user-defined aggregate functions, table functions, and table macros).Unlike built-in functions, there is a fixed number of parameters, and the parameters have names. You can ask for the type of a parameter without providing a particular call (and with it actual arguments) but you do need to provide a type factory, and therefore the types are only good for the duration of the current statement.
-
or
Creates a checker that passes if any one of the rules passes. -
and
Creates a checker that passes if all of the rules pass. -
or
Creates a single-operand checker that passes if any one of the rules passes. -
and
Creates a single-operand checker that passes if all of the rules pass. -
sequence
public static SqlOperandTypeChecker sequence(String allowedSignatures, SqlSingleOperandTypeChecker... rules) Creates an operand checker from a sequence of single-operand checkers. -
sequence
public static SqlOperandTypeChecker sequence(BiFunction<SqlOperator, String, String> signatureGenerator, SqlSingleOperandTypeChecker... rules) Creates an operand checker from a sequence of single-operand checkers, generating the signature from the components. -
repeat
public static SqlOperandTypeChecker repeat(SqlOperandCountRange range, SqlSingleOperandTypeChecker... rules) Creates a checker that passes if all of the rules pass for each operand, using a given operand count strategy. -
nth
public static SqlOperandTypeChecker nth(int ordinal, int operandCount, SqlSingleOperandTypeChecker rule) Creates an operand checker that applies a single-operand checker to theordinal
th operand. -
variadic
-
same
Operand type-checking strategy where a given list of operands must all have the same type.
-