use of org.apache.flink.table.types.logical.DistinctType in project flink by apache.
the class LogicalTypeUtils method toRowType.
/**
* Converts any logical type to a row type. Composite types are converted to a row type. Atomic
* types are wrapped into a field.
*/
public static RowType toRowType(LogicalType t) {
switch(t.getTypeRoot()) {
case ROW:
return (RowType) t;
case STRUCTURED_TYPE:
final StructuredType structuredType = (StructuredType) t;
final List<RowField> fields = structuredType.getAttributes().stream().map(attribute -> new RowField(attribute.getName(), attribute.getType(), attribute.getDescription().orElse(null))).collect(Collectors.toList());
return new RowType(structuredType.isNullable(), fields);
case DISTINCT_TYPE:
return toRowType(((DistinctType) t).getSourceType());
default:
return RowType.of(t);
}
}
Aggregations