sumitsingh-in commented on code in PR #20183:
URL: https://github.com/apache/hudi/pull/20183#discussion_r4181506398


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetSchemaEvolutionUtils.scala:
##########
@@ -58,7 +58,10 @@ class ParquetSchemaEvolutionUtils(sharedConf: Configuration,
   // Fetch internal schema
   private lazy val querySchemaOption: util.Option[InternalSchema] = 
pruneInternalSchema(internalSchemaOpt, requiredSchema)
 
-  var shouldUseInternalSchema: Boolean = querySchemaOption.isPresent && 
tablePath != null
+  // Empty projections (count(*), select 1) read no column data, so skip 
schema-on-read. Their query
+  // schema is unpruned (see pruneInternalSchema), and merging it would 
request every column, including
+  // a variant as a plain struct that Spark 4.x's vectorized reader rejects.
+  var shouldUseInternalSchema: Boolean = requiredSchema.nonEmpty && 
querySchemaOption.isPresent && tablePath != null

Review Comment:
   we move the check here: 
https://github.com/apache/hudi/pull/20183/changes#r4181503519



##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetSchemaEvolutionUtils.scala:
##########
@@ -58,7 +58,10 @@ class ParquetSchemaEvolutionUtils(sharedConf: Configuration,
   // Fetch internal schema
   private lazy val querySchemaOption: util.Option[InternalSchema] = 
pruneInternalSchema(internalSchemaOpt, requiredSchema)
 
-  var shouldUseInternalSchema: Boolean = querySchemaOption.isPresent && 
tablePath != null
+  // Empty projections (count(*), select 1) read no column data, so skip 
schema-on-read. Their query
+  // schema is unpruned (see pruneInternalSchema), and merging it would 
request every column, including
+  // a variant as a plain struct that Spark 4.x's vectorized reader rejects.
+  var shouldUseInternalSchema: Boolean = requiredSchema.nonEmpty && 
querySchemaOption.isPresent && tablePath != null

Review Comment:
   we move the check from here: 
https://github.com/apache/hudi/pull/20183/changes#r4181503519



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

Reply via email to