rdblue commented on a change in pull request #3186:
URL: https://github.com/apache/iceberg/pull/3186#discussion_r741528067



##########
File path: 
spark/v2.4/spark/src/main/java/org/apache/iceberg/spark/source/BaseDataReader.java
##########
@@ -196,4 +198,40 @@ protected static Object convertConstant(Type type, Object 
value) {
     }
     return value;
   }
+
+  protected void findMoreCompoundConstants(Schema tableSchema, Map<Integer, ?> 
idToConstant) {
+    List<Types.NestedField> columns = tableSchema.columns();
+
+    for (Types.NestedField nestedField : columns) {
+      visitCompoundTypesByDFS(nestedField, (Map<Integer, Object>) 
idToConstant);
+    }
+  }
+
+  protected void visitCompoundTypesByDFS(
+          Types.NestedField nestedField,
+          Map<Integer, Object> idToConstant) {
+    switch (nestedField.type().typeId()) {
+      case STRUCT:
+        List<Types.NestedField> childFieldsInStruct = 
nestedField.type().asStructType().fields();
+        List<Integer> childFieldID = new ArrayList<>();
+        for (Types.NestedField childField : childFieldsInStruct) {
+          visitCompoundTypesByDFS(childField, idToConstant);
+          childFieldID.add(childField.fieldId());
+        }
+        if (idToConstant.keySet().containsAll(childFieldID)) {

Review comment:
       Looks like this is creating any struct that it can when all of the 
struct's children are present in the constants map.
   
   I think this would need to be refactored so that the method is clear about 
what it is doing. Simply "visit" doesn't really describe what is going on here. 
It is updating the constants map.




-- 
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: [email protected]

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