edgarRd commented on a change in pull request #1140:
URL: https://github.com/apache/iceberg/pull/1140#discussion_r448685626



##########
File path: orc/src/main/java/org/apache/iceberg/orc/ORCSchemaUtil.java
##########
@@ -214,10 +213,13 @@ public static Schema convert(TypeDescription orcSchema) {
         "Error in ORC file, children fields and names do not match.");
 
     List<Types.NestedField> icebergFields = 
Lists.newArrayListWithExpectedSize(children.size());
-    AtomicInteger lastColumnId = new AtomicInteger(getMaxIcebergId(orcSchema));
-    for (int i = 0; i < children.size(); i++) {
-      icebergFields.add(convertOrcToIceberg(children.get(i), 
childrenNames.get(i),
-          lastColumnId::incrementAndGet));
+    OrcToIcebergVisitor schemaConverter = new 
OrcToIcebergVisitor(icebergToOrcMapping("root", orcSchema));
+    for (TypeDescription child : orcSchema.getChildren()) {
+      OrcToIcebergVisitor.visit(child, 
schemaConverter).ifPresent(icebergFields::add);

Review comment:
       The root struct of ORC does not have an Iceberg ID, hence this looping. 
I've moved this to a `visitSchema` method in the visitor that reuses the code 
of `visitRecord`.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to