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;
}
Aggregations