twalthr commented on a change in pull request #12887:
URL: https://github.com/apache/flink/pull/12887#discussion_r454174539
##########
File path:
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/utils/DataTypeUtils.java
##########
@@ -217,29 +221,52 @@ public DataType visit(CollectionDataType
collectionDataType) {
@Override
public DataType visit(FieldsDataType fieldsDataType) {
- final List<DataType> newFields =
fieldsDataType.getChildren().stream()
+ final List<DataType> newDataTypes =
fieldsDataType.getChildren().stream()
.map(dt -> dt.accept(this))
.collect(Collectors.toList());
final LogicalType logicalType =
fieldsDataType.getLogicalType();
final LogicalType newLogicalType;
if (logicalType instanceof RowType) {
- final List<RowType.RowField> oldFields =
((RowType) logicalType).getFields();
- final List<RowType.RowField> newRowFields =
IntStream.range(0, oldFields.size())
+ final List<RowField> oldFields = ((RowType)
logicalType).getFields();
+ final List<RowField> newFields =
IntStream.range(0, oldFields.size())
.mapToObj(i ->
- new RowType.RowField(
+ new RowField(
oldFields.get(i).getName(),
-
newFields.get(i).getLogicalType(),
+
newDataTypes.get(i).getLogicalType(),
oldFields.get(i).getDescription().orElse(null)))
.collect(Collectors.toList());
newLogicalType = new RowType(
logicalType.isNullable(),
- newRowFields);
+ newFields);
+ } else if (logicalType instanceof StructuredType) {
Review comment:
I will try to improve the documentation for this a little bit. The
transformation needs to be applied transitively to adapt e.g. conversion
classes or precision throughout a data type and its fields.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]