Search in sources :

Example 6 with ArgumentTypeStrategy

use of org.apache.flink.table.types.inference.ArgumentTypeStrategy in project flink by apache.

the class VaryingSequenceInputTypeStrategy method inferInputTypes.

@Override
public Optional<List<DataType>> inferInputTypes(CallContext callContext, boolean throwOnFailure) {
    final List<DataType> dataTypes = callContext.getArgumentDataTypes();
    if (dataTypes.size() < constantArgumentCount) {
        return Optional.empty();
    }
    final List<DataType> inferredDataTypes = new ArrayList<>(dataTypes.size());
    for (int i = 0; i < callContext.getArgumentDataTypes().size(); i++) {
        final ArgumentTypeStrategy argumentTypeStrategy;
        if (i < constantArgumentCount) {
            argumentTypeStrategy = constantArgumentStrategies.get(i);
        } else {
            argumentTypeStrategy = varyingArgumentStrategy;
        }
        final Optional<DataType> inferredDataType = argumentTypeStrategy.inferArgumentType(callContext, i, throwOnFailure);
        if (!inferredDataType.isPresent()) {
            return Optional.empty();
        }
        inferredDataTypes.add(inferredDataType.get());
    }
    return Optional.of(inferredDataTypes);
}
Also used : ArrayList(java.util.ArrayList) DataType(org.apache.flink.table.types.DataType) ArgumentTypeStrategy(org.apache.flink.table.types.inference.ArgumentTypeStrategy)

Aggregations

ArgumentTypeStrategy (org.apache.flink.table.types.inference.ArgumentTypeStrategy)6 DataType (org.apache.flink.table.types.DataType)5 ArrayList (java.util.ArrayList)3 LogicalType (org.apache.flink.table.types.logical.LogicalType)2 InputTypeStrategy (org.apache.flink.table.types.inference.InputTypeStrategy)1