Class InputTypeStrategies
- java.lang.Object
-
- org.apache.flink.table.types.inference.InputTypeStrategies
-
@Internal public final class InputTypeStrategies extends Object
Strategies for inferring and validating input arguments in a function call.- See Also:
InputTypeStrategy,ArgumentTypeStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static AnyArgumentTypeStrategyANYStrategy for an argument that can be of any type.static ArgumentTypeStrategyCOMMON_ARGArgument type strategy that checks and casts for a common, least restrictive type of all arguments.static ArgumentTypeStrategyCOMMON_ARG_NULLABLEArgument type strategy that checks and casts for a common, least restrictive type of all arguments.static ArgumentTypeStrategyCOMPOSITEStrategy that checks that the argument has a composite type.static ArgumentTypeStrategyITEM_AT_INDEXstatic LiteralArgumentTypeStrategyLITERALStrategy that checks if an argument is a literal.static LiteralArgumentTypeStrategyLITERAL_OR_NULLStrategy that checks if an argument is a literal or NULL.static InputTypeStrategyNO_ARGSStrategy that does not expect any arguments.static OutputArgumentTypeStrategyOUTPUT_IF_NULLStrategy for inferring an unknown argument type from the function's outputDataTypeif available.static TypeLiteralArgumentTypeStrategyTYPE_LITERALStrategy that checks if an argument is a type literal.static WildcardInputTypeStrategyWILDCARDStrategy that does not perform any modification or validation of the input.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AndArgumentTypeStrategyand(ArgumentTypeStrategy... strategies)Strategy for a conjunction of multipleArgumentTypeStrategys into one likef(NUMERIC && LITERAL).static InputTypeStrategycommonArrayType(int count)AnInputTypeStrategythat expectscountarguments that have a common array type.static InputTypeStrategycommonMapType(int minCount)AnInputTypeStrategythat expectsminCountarguments that have a common map type.static InputTypeStrategycommonMultipleArrayType(int minCount)AnInputTypeStrategythat expectsminCountarguments that have a common array type.static InputTypeStrategycommonType(int count)AnInputTypeStrategythat expectscountarguments that have a common type.static InputTypeStrategycomparable(ConstantArgumentCount argumentCount, StructuredType.StructuredComparison requiredComparison)Strategy that checks all types are comparable with each other.static SubsequenceInputTypeStrategy.SubsequenceStrategyBuildercompositeSequence()An strategy that lets you apply other strategies for subsequences of the actual arguments.static ConstraintArgumentTypeStrategyconstraint(String constraintMessage, Predicate<List<DataType>> evaluator)Strategy for an argument that must fulfill a given constraint.static ExplicitArgumentTypeStrategyexplicit(DataType expectedDataType)Strategy for an argument that corresponds to an explicitly defined type casting.static InputTypeStrategyexplicitSequence(String[] argumentNames, DataType[] expectedDataTypes)Strategy for a named function signature of explicitly defined types likef(s STRING, i INT).static InputTypeStrategyexplicitSequence(DataType... expectedDataTypes)Strategy for a function signature of explicitly defined types likef(STRING, INT).static FamilyArgumentTypeStrategylogical(LogicalTypeFamily expectedFamily)Strategy for an argument that corresponds to a givenLogicalTypeFamily.static FamilyArgumentTypeStrategylogical(LogicalTypeFamily expectedFamily, boolean expectedNullability)Strategy for an argument that corresponds to a givenLogicalTypeFamilyand nullability.static RootArgumentTypeStrategylogical(LogicalTypeRoot expectedRoot)Strategy for an argument that corresponds to a givenLogicalTypeRoot.static RootArgumentTypeStrategylogical(LogicalTypeRoot expectedRoot, boolean expectedNullability)Strategy for an argument that corresponds to a givenLogicalTypeRootand nullability.static OrArgumentTypeStrategyor(ArgumentTypeStrategy... strategies)Strategy for a disjunction of multipleArgumentTypeStrategys into one likef(NUMERIC || STRING).static InputTypeStrategyor(InputTypeStrategy... strategies)Strategy for a disjunction of multipleInputTypeStrategys into one likef(NUMERIC) || f(STRING).static InputTypeStrategyrepeatingSequence(ArgumentTypeStrategy... strategies)Arbitrarily often repeating sequence of argument type strategies.static InputTypeStrategysequence(String[] argumentNames, ArgumentTypeStrategy[] strategies)Strategy for a named function signature likef(s STRING, n NUMERIC)using a sequence ofArgumentTypeStrategys.static InputTypeStrategysequence(List<String> argumentNames, List<ArgumentTypeStrategy> strategies)Strategy for a named function signature likef(s STRING, n NUMERIC)using a sequence ofArgumentTypeStrategys.static InputTypeStrategysequence(ArgumentTypeStrategy... strategies)Strategy for a function signature likef(STRING, NUMERIC)using a sequence ofArgumentTypeStrategys.static SymbolArgumentTypeStrategy<?>symbol(Class<? extends Enum<? extends TableSymbol>> clazz)Strategy for a symbol argument of a specificTableSymbolenum.static <T extends Enum<? extends TableSymbol>>
SymbolArgumentTypeStrategy<T>symbol(T firstAllowedVariant, T... otherAllowedVariants)Strategy for a symbol argument of a specificTableSymbolenum, with value being one of the provided variants.static InputTypeStrategyvaryingSequence(String[] argumentNames, ArgumentTypeStrategy[] strategies)Strategy for a varying named function signature likef(i INT, str STRING, num NUMERIC...)using a sequence ofArgumentTypeStrategys.static InputTypeStrategyvaryingSequence(List<String> argumentNames, List<ArgumentTypeStrategy> strategies)Strategy for a varying named function signature likef(i INT, str STRING, num NUMERIC...)using a sequence ofArgumentTypeStrategys.static InputTypeStrategyvaryingSequence(ArgumentTypeStrategy... strategies)Strategy for a varying function signature likef(INT, STRING, NUMERIC...)using a sequence ofArgumentTypeStrategys.static InputTypeStrategywildcardWithCount(ArgumentCount argumentCount)Strategy that does not perform any modification or validation of the input.
-
-
-
Field Detail
-
WILDCARD
public static final WildcardInputTypeStrategy WILDCARD
Strategy that does not perform any modification or validation of the input.
-
NO_ARGS
public static final InputTypeStrategy NO_ARGS
Strategy that does not expect any arguments.
-
OUTPUT_IF_NULL
public static final OutputArgumentTypeStrategy OUTPUT_IF_NULL
Strategy for inferring an unknown argument type from the function's outputDataTypeif available.
-
ANY
public static final AnyArgumentTypeStrategy ANY
Strategy for an argument that can be of any type.
-
LITERAL
public static final LiteralArgumentTypeStrategy LITERAL
Strategy that checks if an argument is a literal.
-
LITERAL_OR_NULL
public static final LiteralArgumentTypeStrategy LITERAL_OR_NULL
Strategy that checks if an argument is a literal or NULL.
-
TYPE_LITERAL
public static final TypeLiteralArgumentTypeStrategy TYPE_LITERAL
Strategy that checks if an argument is a type literal.
-
COMPOSITE
public static final ArgumentTypeStrategy COMPOSITE
Strategy that checks that the argument has a composite type.
-
COMMON_ARG
public static final ArgumentTypeStrategy COMMON_ARG
Argument type strategy that checks and casts for a common, least restrictive type of all arguments.
-
COMMON_ARG_NULLABLE
public static final ArgumentTypeStrategy COMMON_ARG_NULLABLE
Argument type strategy that checks and casts for a common, least restrictive type of all arguments. But leaves nullability untouched.
-
ITEM_AT_INDEX
public static final ArgumentTypeStrategy ITEM_AT_INDEX
- See Also:
ItemAtIndexArgumentTypeStrategy
-
-
Method Detail
-
sequence
public static InputTypeStrategy sequence(ArgumentTypeStrategy... strategies)
Strategy for a function signature likef(STRING, NUMERIC)using a sequence ofArgumentTypeStrategys.
-
sequence
public static InputTypeStrategy sequence(String[] argumentNames, ArgumentTypeStrategy[] strategies)
Strategy for a named function signature likef(s STRING, n NUMERIC)using a sequence ofArgumentTypeStrategys.
-
sequence
public static InputTypeStrategy sequence(List<String> argumentNames, List<ArgumentTypeStrategy> strategies)
Strategy for a named function signature likef(s STRING, n NUMERIC)using a sequence ofArgumentTypeStrategys.
-
varyingSequence
public static InputTypeStrategy varyingSequence(ArgumentTypeStrategy... strategies)
Strategy for a varying function signature likef(INT, STRING, NUMERIC...)using a sequence ofArgumentTypeStrategys. The first n - 1 arguments must be constant. The n-th argument can occur 0, 1, or more times.
-
varyingSequence
public static InputTypeStrategy varyingSequence(String[] argumentNames, ArgumentTypeStrategy[] strategies)
Strategy for a varying named function signature likef(i INT, str STRING, num NUMERIC...)using a sequence ofArgumentTypeStrategys. The first n - 1 arguments must be constant. The n-th argument can occur 0, 1, or more times.
-
varyingSequence
public static InputTypeStrategy varyingSequence(List<String> argumentNames, List<ArgumentTypeStrategy> strategies)
Strategy for a varying named function signature likef(i INT, str STRING, num NUMERIC...)using a sequence ofArgumentTypeStrategys. The first n - 1 arguments must be constant. The n-th argument can occur 0, 1, or more times.
-
repeatingSequence
public static InputTypeStrategy repeatingSequence(ArgumentTypeStrategy... strategies)
Arbitrarily often repeating sequence of argument type strategies.
-
explicitSequence
public static InputTypeStrategy explicitSequence(DataType... expectedDataTypes)
Strategy for a function signature of explicitly defined types likef(STRING, INT). Implicit casts will be inserted if possible.This is equivalent to using
sequence(ArgumentTypeStrategy...)andexplicit(DataType).
-
explicitSequence
public static InputTypeStrategy explicitSequence(String[] argumentNames, DataType[] expectedDataTypes)
Strategy for a named function signature of explicitly defined types likef(s STRING, i INT). Implicit casts will be inserted if possible.This is equivalent to using
sequence(String[], ArgumentTypeStrategy[])andexplicit(DataType).
-
compositeSequence
public static SubsequenceInputTypeStrategy.SubsequenceStrategyBuilder compositeSequence()
An strategy that lets you apply other strategies for subsequences of the actual arguments.The
sequence(ArgumentTypeStrategy...)should be preferred in most of the cases. Use this strategy only if you need to apply a common logic to a subsequence of the arguments.
-
or
public static InputTypeStrategy or(InputTypeStrategy... strategies)
Strategy for a disjunction of multipleInputTypeStrategys into one likef(NUMERIC) || f(STRING).This strategy aims to infer a list of types that are equal to the input types (to prevent unnecessary casting) or (if this is not possible) the first more specific, casted types.
-
wildcardWithCount
public static InputTypeStrategy wildcardWithCount(ArgumentCount argumentCount)
Strategy that does not perform any modification or validation of the input. It checks the argument count though.
-
comparable
public static InputTypeStrategy comparable(ConstantArgumentCount argumentCount, StructuredType.StructuredComparison requiredComparison)
Strategy that checks all types are comparable with each other. Requires at least one argument.
-
explicit
public static ExplicitArgumentTypeStrategy explicit(DataType expectedDataType)
Strategy for an argument that corresponds to an explicitly defined type casting. Implicit casts will be inserted if possible.
-
logical
public static RootArgumentTypeStrategy logical(LogicalTypeRoot expectedRoot)
Strategy for an argument that corresponds to a givenLogicalTypeRoot. Implicit casts will be inserted if possible.
-
logical
public static RootArgumentTypeStrategy logical(LogicalTypeRoot expectedRoot, boolean expectedNullability)
Strategy for an argument that corresponds to a givenLogicalTypeRootand nullability. Implicit casts will be inserted if possible.
-
logical
public static FamilyArgumentTypeStrategy logical(LogicalTypeFamily expectedFamily)
Strategy for an argument that corresponds to a givenLogicalTypeFamily. Implicit casts will be inserted if possible.
-
logical
public static FamilyArgumentTypeStrategy logical(LogicalTypeFamily expectedFamily, boolean expectedNullability)
Strategy for an argument that corresponds to a givenLogicalTypeFamilyand nullability. Implicit casts will be inserted if possible.
-
constraint
public static ConstraintArgumentTypeStrategy constraint(String constraintMessage, Predicate<List<DataType>> evaluator)
Strategy for an argument that must fulfill a given constraint.
-
and
public static AndArgumentTypeStrategy and(ArgumentTypeStrategy... strategies)
Strategy for a conjunction of multipleArgumentTypeStrategys into one likef(NUMERIC && LITERAL).Some
ArgumentTypeStrategys cannot contribute an inferred type that is different from the input type (e.g.LITERAL). Therefore, the orderf(X && Y)orf(Y && X)matters as it defines the precedence in case the result must be casted to a more specific type.This strategy aims to infer the first more specific, casted type or (if this is not possible) a type that has been inferred from all
ArgumentTypeStrategys.
-
or
public static OrArgumentTypeStrategy or(ArgumentTypeStrategy... strategies)
Strategy for a disjunction of multipleArgumentTypeStrategys into one likef(NUMERIC || STRING).Some
ArgumentTypeStrategys cannot contribute an inferred type that is different from the input type (e.g.LITERAL). Therefore, the orderf(X || Y)orf(Y || X)matters as it defines the precedence in case the result must be casted to a more specific type.This strategy aims to infer a type that is equal to the input type (to prevent unnecessary casting) or (if this is not possible) the first more specific, casted type.
-
symbol
public static SymbolArgumentTypeStrategy<?> symbol(Class<? extends Enum<? extends TableSymbol>> clazz)
Strategy for a symbol argument of a specificTableSymbolenum.A symbol is implied to be a literal argument.
-
symbol
@SafeVarargs public static <T extends Enum<? extends TableSymbol>> SymbolArgumentTypeStrategy<T> symbol(T firstAllowedVariant, T... otherAllowedVariants)
Strategy for a symbol argument of a specificTableSymbolenum, with value being one of the provided variants.A symbol is implied to be a literal argument.
-
commonType
public static InputTypeStrategy commonType(int count)
AnInputTypeStrategythat expectscountarguments that have a common type.
-
commonArrayType
public static InputTypeStrategy commonArrayType(int count)
AnInputTypeStrategythat expectscountarguments that have a common array type.
-
commonMultipleArrayType
public static InputTypeStrategy commonMultipleArrayType(int minCount)
AnInputTypeStrategythat expectsminCountarguments that have a common array type.
-
commonMapType
public static InputTypeStrategy commonMapType(int minCount)
AnInputTypeStrategythat expectsminCountarguments that have a common map type.
-
-