Package org.apache.calcite.sql.type
Class OperandTypes
- java.lang.Object
-
- org.apache.calcite.sql.type.OperandTypes
-
public abstract class OperandTypes extends java.lang.Object
Strategies for checking operand types.This class defines singleton instances of strategy objects for operand type checking.
ReturnTypes
andInferTypes
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:
SqlOperandTypeChecker
,ReturnTypes
,InferTypes
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
OperandTypes.PeriodOperandTypeChecker
Operand type checker that accepts period types: PERIOD (DATETIME, DATETIME) PERIOD (DATETIME, INTERVAL) [ROW] (DATETIME, DATETIME) [ROW] (DATETIME, INTERVAL)
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description private
OperandTypes()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 FamilyOperandTypeChecker
family(java.util.List<SqlTypeFamily> families)
Creates a checker that passes if each operand is a member of a corresponding family.static FamilyOperandTypeChecker
family(java.util.List<SqlTypeFamily> families, java.util.function.Predicate<java.lang.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 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 SqlOperandTypeChecker
sequence(java.lang.String allowedSignatures, SqlSingleOperandTypeChecker... rules)
Creates an operand checker from a sequence of single-operand checkers.static SqlOperandTypeChecker
variadic(SqlOperandCountRange range)
-
-
-
Field Detail
-
NILADIC
public static final SqlSingleOperandTypeChecker NILADIC
Operand type-checking strategy for an operator which takes no operands.
-
VARIADIC
public static final SqlOperandTypeChecker VARIADIC
Operand type-checking strategy for an operator with no restrictions on number or type of operands.
-
ONE_OR_MORE
public static final SqlOperandTypeChecker ONE_OR_MORE
Operand type-checking strategy that allows one or more operands.
-
BOOLEAN
public static final SqlSingleOperandTypeChecker BOOLEAN
-
BOOLEAN_BOOLEAN
public static final SqlSingleOperandTypeChecker BOOLEAN_BOOLEAN
-
NUMERIC
public static final SqlSingleOperandTypeChecker NUMERIC
-
NUMERIC_OPTIONAL_INTEGER
public static final SqlSingleOperandTypeChecker NUMERIC_OPTIONAL_INTEGER
-
NUMERIC_INTEGER
public static final SqlSingleOperandTypeChecker NUMERIC_INTEGER
-
NUMERIC_NUMERIC
public static final SqlSingleOperandTypeChecker NUMERIC_NUMERIC
-
EXACT_NUMERIC
public static final SqlSingleOperandTypeChecker EXACT_NUMERIC
-
EXACT_NUMERIC_EXACT_NUMERIC
public static final SqlSingleOperandTypeChecker EXACT_NUMERIC_EXACT_NUMERIC
-
BINARY
public static final SqlSingleOperandTypeChecker BINARY
-
STRING
public static final SqlSingleOperandTypeChecker STRING
-
STRING_STRING
public static final FamilyOperandTypeChecker STRING_STRING
-
STRING_STRING_STRING
public static final FamilyOperandTypeChecker STRING_STRING_STRING
-
CHARACTER
public static final SqlSingleOperandTypeChecker CHARACTER
-
DATETIME
public static final SqlSingleOperandTypeChecker DATETIME
-
INTERVAL
public static final SqlSingleOperandTypeChecker INTERVAL
-
PERIOD
public static final SqlSingleOperandTypeChecker PERIOD
-
PERIOD_OR_DATETIME
public static final SqlSingleOperandTypeChecker PERIOD_OR_DATETIME
-
INTERVAL_INTERVAL
public static final FamilyOperandTypeChecker INTERVAL_INTERVAL
-
MULTISET
public static final SqlSingleOperandTypeChecker MULTISET
-
ARRAY
public static final SqlSingleOperandTypeChecker ARRAY
-
COLLECTION
public static final SqlSingleOperandTypeChecker 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
public static final SqlSingleOperandTypeChecker COLLECTION_OR_MAP
-
NULLABLE_LITERAL
public static final SqlSingleOperandTypeChecker NULLABLE_LITERAL
Operand type-checking strategy where type must be a literal or NULL.
-
LITERAL
public static final SqlSingleOperandTypeChecker LITERAL
Operand type-checking strategy type must be a non-NULL literal.
-
POSITIVE_INTEGER_LITERAL
public static final SqlSingleOperandTypeChecker POSITIVE_INTEGER_LITERAL
Operand type-checking strategy type must be a positive integer non-NULL literal.
-
SAME_SAME
public static final SqlSingleOperandTypeChecker SAME_SAME
Operand type-checking strategy where two operands must both be in the same type family.
-
SAME_SAME_INTEGER
public static final SqlSingleOperandTypeChecker SAME_SAME_INTEGER
-
SAME_SAME_SAME
public static final SqlSingleOperandTypeChecker SAME_SAME_SAME
Operand type-checking strategy where three operands must all be in the same type family.
-
SAME_VARIADIC
public static final SqlOperandTypeChecker SAME_VARIADIC
Operand type-checking strategy where any number of operands must all be in the same type family.
-
COMPARABLE_ORDERED_COMPARABLE_ORDERED
public static final SqlOperandTypeChecker COMPARABLE_ORDERED_COMPARABLE_ORDERED
Operand type-checking strategy where operand types must allow ordered comparisons.
-
COMPARABLE_ORDERED
public static final SqlOperandTypeChecker 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
public static final SqlOperandTypeChecker COMPARABLE_UNORDERED_COMPARABLE_UNORDERED
Operand type-checking strategy where operand types must allow unordered comparisons.
-
STRING_SAME_SAME
public static final SqlSingleOperandTypeChecker STRING_SAME_SAME
Operand type-checking strategy where two operands must both be in the same string type family.
-
STRING_SAME_SAME_SAME
public static final SqlSingleOperandTypeChecker STRING_SAME_SAME_SAME
Operand type-checking strategy where three operands must all be in the same string type family.
-
STRING_STRING_INTEGER
public static final SqlSingleOperandTypeChecker STRING_STRING_INTEGER
-
STRING_STRING_INTEGER_INTEGER
public static final SqlSingleOperandTypeChecker STRING_STRING_INTEGER_INTEGER
-
STRING_SAME_SAME_INTEGER
public static final SqlSingleOperandTypeChecker 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.
-
ANY
public static final SqlSingleOperandTypeChecker ANY
-
ANY_ANY
public static final SqlSingleOperandTypeChecker ANY_ANY
-
ANY_NUMERIC
public static final SqlSingleOperandTypeChecker ANY_NUMERIC
-
INTERVAL_SAME_SAME
public static final SqlSingleOperandTypeChecker INTERVAL_SAME_SAME
Parameter type-checking strategy type must a nullable time interval, nullable time interval
-
NUMERIC_INTERVAL
public static final SqlSingleOperandTypeChecker NUMERIC_INTERVAL
-
INTERVAL_NUMERIC
public static final SqlSingleOperandTypeChecker INTERVAL_NUMERIC
-
DATETIME_INTERVAL
public static final SqlSingleOperandTypeChecker DATETIME_INTERVAL
-
DATETIME_INTERVAL_INTERVAL
public static final SqlSingleOperandTypeChecker DATETIME_INTERVAL_INTERVAL
-
DATETIME_INTERVAL_INTERVAL_TIME
public static final SqlSingleOperandTypeChecker DATETIME_INTERVAL_INTERVAL_TIME
-
DATETIME_INTERVAL_TIME
public static final SqlSingleOperandTypeChecker DATETIME_INTERVAL_TIME
-
INTERVAL_DATETIME
public static final SqlSingleOperandTypeChecker INTERVAL_DATETIME
-
INTERVALINTERVAL_INTERVALDATETIME
public static final SqlSingleOperandTypeChecker INTERVALINTERVAL_INTERVALDATETIME
-
PLUS_OPERATOR
public static final SqlSingleOperandTypeChecker PLUS_OPERATOR
-
MULTIPLY_OPERATOR
public static final SqlSingleOperandTypeChecker MULTIPLY_OPERATOR
Type checking strategy for the "*" operator
-
DIVISION_OPERATOR
public static final SqlSingleOperandTypeChecker DIVISION_OPERATOR
Type checking strategy for the "/" operator
-
MINUS_OPERATOR
public static final SqlSingleOperandTypeChecker MINUS_OPERATOR
-
MINUS_DATE_OPERATOR
public static final FamilyOperandTypeChecker MINUS_DATE_OPERATOR
-
NUMERIC_OR_INTERVAL
public static final SqlSingleOperandTypeChecker NUMERIC_OR_INTERVAL
-
NUMERIC_OR_STRING
public static final SqlSingleOperandTypeChecker NUMERIC_OR_STRING
-
RECORD_COLLECTION
public static final SqlSingleOperandTypeChecker RECORD_COLLECTION
Checker that returns whether a value is a multiset of records or an array of records.- See Also:
COLLECTION
-
SCALAR_OR_RECORD_COLLECTION
public static final SqlSingleOperandTypeChecker 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
public static final SqlSingleOperandTypeChecker SCALAR_OR_RECORD_COLLECTION_OR_MAP
-
MULTISET_MULTISET
public static final SqlOperandTypeChecker MULTISET_MULTISET
-
SET_OP
public static final SqlOperandTypeChecker SET_OP
Operand type-checking strategy for a set operator (UNION, INTERSECT, EXCEPT).
-
RECORD_TO_SCALAR
public static final SqlOperandTypeChecker RECORD_TO_SCALAR
-
-
Method Detail
-
family
public static FamilyOperandTypeChecker family(SqlTypeFamily... families)
Creates a checker that passes if each operand is a member of a corresponding family.
-
family
public static FamilyOperandTypeChecker family(java.util.List<SqlTypeFamily> families, java.util.function.Predicate<java.lang.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
public static FamilyOperandTypeChecker family(java.util.List<SqlTypeFamily> families)
Creates a checker that passes if each operand is a member of a corresponding family.
-
or
public static SqlOperandTypeChecker or(SqlOperandTypeChecker... rules)
Creates a checker that passes if any one of the rules passes.
-
and
public static SqlOperandTypeChecker and(SqlOperandTypeChecker... rules)
Creates a checker that passes if all of the rules pass.
-
or
public static SqlSingleOperandTypeChecker or(SqlSingleOperandTypeChecker... rules)
Creates a single-operand checker that passes if any one of the rules passes.
-
and
public static SqlSingleOperandTypeChecker and(SqlSingleOperandTypeChecker... rules)
Creates a single-operand checker that passes if all of the rules pass.
-
sequence
public static SqlOperandTypeChecker sequence(java.lang.String allowedSignatures, SqlSingleOperandTypeChecker... rules)
Creates an operand checker from a sequence of single-operand checkers.
-
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.
-
variadic
public static SqlOperandTypeChecker variadic(SqlOperandCountRange range)
-
-