ZiyaZa commented on code in PR #52557:
URL: https://github.com/apache/spark/pull/52557#discussion_r2441739945


##########
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedParquetRecordReader.java:
##########
@@ -265,7 +265,13 @@ private void initBatch(
       MemoryMode memMode,
       StructType partitionColumns,
       InternalRow partitionValues) {
-    StructType batchSchema = new StructType(sparkSchema.fields());
+    boolean returnNullStructIfAllFieldsMissing = configuration.getBoolean(
+      
SQLConf$.MODULE$.LEGACY_PARQUET_RETURN_NULL_STRUCT_IF_ALL_FIELDS_MISSING().key(),
+      (boolean) 
SQLConf$.MODULE$.LEGACY_PARQUET_RETURN_NULL_STRUCT_IF_ALL_FIELDS_MISSING()
+        .defaultValue().get());
+    StructType batchSchema = !returnNullStructIfAllFieldsMissing
+      ? new StructType(sparkSchema.fields())
+      : (StructType) truncateType(sparkSchema, sparkRequestedSchema);

Review Comment:
   I think I flipped both the condition and the statements when converting the 
flag from default true to default false legacy flag. In legacy mode, we don't 
need `truncateType`. It is used to get rid of the additional field we are 
reading if we are not in the legacy mode.
   
   Added a comment.



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