szehon-ho commented on a change in pull request #2877:
URL: https://github.com/apache/iceberg/pull/2877#discussion_r677735298



##########
File path: 
spark/src/main/java/org/apache/iceberg/spark/source/RowDataReader.java
##########
@@ -194,20 +194,32 @@ protected Schema tableSchema() {
   }
 
   private static UnsafeProjection projection(Schema finalSchema, Schema 
readSchema) {
-    StructType struct = SparkSchemaUtil.convert(readSchema);
+    StructType readStruct = SparkSchemaUtil.convert(readSchema);
 
-    List<AttributeReference> refs = 
JavaConverters.seqAsJavaListConverter(struct.toAttributes()).asJava();
-    List<Attribute> attrs = 
Lists.newArrayListWithExpectedSize(struct.fields().length);
+    List<AttributeReference> readReferences = 
JavaConverters.seqAsJavaListConverter(readStruct.toAttributes()).asJava();
+    List<Attribute> attrs = 
Lists.newArrayListWithExpectedSize(readStruct.fields().length);
     List<org.apache.spark.sql.catalyst.expressions.Expression> exprs =
-        Lists.newArrayListWithExpectedSize(struct.fields().length);
+        Lists.newArrayListWithExpectedSize(readStruct.fields().length);
 
-    for (AttributeReference ref : refs) {
+    for (AttributeReference ref : readReferences) {
       attrs.add(ref.toAttribute());
     }
 
     for (Types.NestedField field : finalSchema.columns()) {
-      int indexInReadSchema = struct.fieldIndex(field.name());
-      exprs.add(refs.get(indexInReadSchema));
+      int indexInReadSchema = readStruct.fieldIndex(field.name());
+      if (field.type().isStructType()) {
+        // We may need to prune this attribute to only refer to our expected 
schema

Review comment:
       Curious question: probably don't have this in our case, but if we have 
another layer of nesting does it capture it?




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