Search in sources :

Example 1 with TypeTransformation

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

the class DataTypeUtils method transform.

/**
 * Transforms the given data type to a different data type using the given transformations.
 *
 * <p>The transformations will be called in the given order. In case of constructed or composite
 * types, a transformation will be applied transitively to children first.
 *
 * <p>Both the {@link DataType#getLogicalType()} and {@link DataType#getConversionClass()} can
 * be transformed.
 *
 * @param factory {@link DataTypeFactory} if available
 * @param typeToTransform data type to be transformed.
 * @param transformations the transformations to transform data type to another type.
 * @return the new data type
 */
public static DataType transform(@Nullable DataTypeFactory factory, DataType typeToTransform, TypeTransformation... transformations) {
    Preconditions.checkArgument(transformations.length > 0, "transformations should not be empty.");
    DataType newType = typeToTransform;
    for (TypeTransformation transformation : transformations) {
        newType = newType.accept(new DataTypeTransformer(factory, transformation));
    }
    return newType;
}
Also used : TypeTransformation(org.apache.flink.table.types.inference.TypeTransformation) DataType(org.apache.flink.table.types.DataType) AtomicDataType(org.apache.flink.table.types.AtomicDataType) CollectionDataType(org.apache.flink.table.types.CollectionDataType) KeyValueDataType(org.apache.flink.table.types.KeyValueDataType) FieldsDataType(org.apache.flink.table.types.FieldsDataType)

Aggregations

AtomicDataType (org.apache.flink.table.types.AtomicDataType)1 CollectionDataType (org.apache.flink.table.types.CollectionDataType)1 DataType (org.apache.flink.table.types.DataType)1 FieldsDataType (org.apache.flink.table.types.FieldsDataType)1 KeyValueDataType (org.apache.flink.table.types.KeyValueDataType)1 TypeTransformation (org.apache.flink.table.types.inference.TypeTransformation)1