ebyhr commented on code in PR #11874:
URL: https://github.com/apache/iceberg/pull/11874#discussion_r1969078113


##########
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/data/ParquetWithFlinkSchemaVisitor.java:
##########
@@ -51,106 +51,100 @@ public static <T> T visit(
     } else {
       // if not a primitive, the typeId must be a group
       GroupType group = type.asGroupType();
-      OriginalType annotation = group.getOriginalType();
-      if (annotation != null) {
-        switch (annotation) {
-          case LIST:
-            Preconditions.checkArgument(
-                !group.isRepetition(Type.Repetition.REPEATED),
-                "Invalid list: top-level group is repeated: %s",
-                group);
-            Preconditions.checkArgument(
-                group.getFieldCount() == 1,
-                "Invalid list: does not contain single repeated field: %s",
-                group);
-
-            GroupType repeatedElement = group.getFields().get(0).asGroupType();
-            Preconditions.checkArgument(
-                repeatedElement.isRepetition(Type.Repetition.REPEATED),
-                "Invalid list: inner group is not repeated");
-            Preconditions.checkArgument(
-                repeatedElement.getFieldCount() <= 1,
-                "Invalid list: repeated group is not a single field: %s",
-                group);
-
-            Preconditions.checkArgument(
-                sType instanceof ArrayType, "Invalid list: %s is not an 
array", sType);
-            ArrayType array = (ArrayType) sType;
-            RowType.RowField element =
-                new RowField(
-                    "element", array.getElementType(), "element of " + 
array.asSummaryString());
-
-            visitor.fieldNames.push(repeatedElement.getName());
-            try {
-              T elementResult = null;
-              if (repeatedElement.getFieldCount() > 0) {
-                elementResult = visitField(element, 
repeatedElement.getType(0), visitor);
-              }
-
-              return visitor.list(array, group, elementResult);
-
-            } finally {
-              visitor.fieldNames.pop();
-            }
-
-          case MAP:
-            Preconditions.checkArgument(
-                !group.isRepetition(Type.Repetition.REPEATED),
-                "Invalid map: top-level group is repeated: %s",
-                group);
-            Preconditions.checkArgument(
-                group.getFieldCount() == 1,
-                "Invalid map: does not contain single repeated field: %s",
-                group);
-
-            GroupType repeatedKeyValue = group.getType(0).asGroupType();
-            Preconditions.checkArgument(
-                repeatedKeyValue.isRepetition(Type.Repetition.REPEATED),
-                "Invalid map: inner group is not repeated");
-            Preconditions.checkArgument(
-                repeatedKeyValue.getFieldCount() <= 2,
-                "Invalid map: repeated group does not have 2 fields");
-
-            Preconditions.checkArgument(
-                sType instanceof MapType, "Invalid map: %s is not a map", 
sType);
-            MapType map = (MapType) sType;
-            RowField keyField =
-                new RowField("key", map.getKeyType(), "key of " + 
map.asSummaryString());
-            RowField valueField =
-                new RowField("value", map.getValueType(), "value of " + 
map.asSummaryString());
-
-            visitor.fieldNames.push(repeatedKeyValue.getName());
-            try {
-              T keyResult = null;
-              T valueResult = null;
-              switch (repeatedKeyValue.getFieldCount()) {
-                case 2:
-                  // if there are 2 fields, both key and value are projected
-                  keyResult = visitField(keyField, 
repeatedKeyValue.getType(0), visitor);
-                  valueResult = visitField(valueField, 
repeatedKeyValue.getType(1), visitor);
-                  break;
-                case 1:
-                  // if there is just one, use the name to determine what it is
-                  Type keyOrValue = repeatedKeyValue.getType(0);
-                  if (keyOrValue.getName().equalsIgnoreCase("key")) {
-                    keyResult = visitField(keyField, keyOrValue, visitor);
-                    // value result remains null
-                  } else {
-                    valueResult = visitField(valueField, keyOrValue, visitor);
-                    // key result remains null
-                  }
-                  break;
-                default:
-                  // both results will remain null
+      LogicalTypeAnnotation annotation = group.getLogicalTypeAnnotation();
+      if (LogicalTypeAnnotation.listType().equals(annotation)) {

Review Comment:
   @Fokko Thanks for your suggestion, changed to `instanceof`. 



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to