yihua commented on code in PR #13943:
URL: https://github.com/apache/hudi/pull/13943#discussion_r2365365453


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##########
@@ -365,7 +365,16 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath: 
String,
                            storageConf: StorageConfiguration[Configuration]): 
Iterator[InternalRow] = {
     if (remainingPartitionSchema.fields.length == 
partitionSchema.fields.length) {
       //none of partition fields are read from the file, so the reader will do 
the appending for us
-      parquetFileReader.read(file, requiredSchema, partitionSchema, 
internalSchemaOpt, filters, storageConf)
+      val pfileUtils = sparkAdapter.getSparkPartitionedFileUtils
+      try {
+        val modifiedFile = 
pfileUtils.createPartitionedFile(file.partitionValues, 
pfileUtils.getPathFromPartitionedFile(file), file.start, file.length)
+        parquetFileReader.read(modifiedFile, requiredSchema, partitionSchema, 
internalSchemaOpt, filters, storageConf)
+      } catch {
+        case _: ClassCastException =>
+          val typedPartitionValues = 
ensurePartitionValuesTyped(file.partitionValues, partitionSchema)
+          val modifiedFile = 
pfileUtils.createPartitionedFile(typedPartitionValues, 
pfileUtils.getPathFromPartitionedFile(file), file.start, file.length)
+          parquetFileReader.read(modifiedFile, requiredSchema, 
partitionSchema, internalSchemaOpt, filters, storageConf)
+      }

Review Comment:
   Do we need to fix `else if` and `else` branch for type casting?  There are 
cases where some partition values come from parsing the partition path instead 
of reading from the data files, where as other partition values need to be read 
from data files.
   
   Also does this work with timestamp and custom key generator, where the 
partition value is derived by transforming the timestamp value (e.g., 
`1758350857` in long or timestamp type) into String (e.g., `2025-09-19`)?  For 
the example I give here, the String cannot be cast to timestamp or long.



##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##########
@@ -365,7 +365,16 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath: 
String,
                            storageConf: StorageConfiguration[Configuration]): 
Iterator[InternalRow] = {
     if (remainingPartitionSchema.fields.length == 
partitionSchema.fields.length) {
       //none of partition fields are read from the file, so the reader will do 
the appending for us
-      parquetFileReader.read(file, requiredSchema, partitionSchema, 
internalSchemaOpt, filters, storageConf)
+      val pfileUtils = sparkAdapter.getSparkPartitionedFileUtils
+      try {
+        val modifiedFile = 
pfileUtils.createPartitionedFile(file.partitionValues, 
pfileUtils.getPathFromPartitionedFile(file), file.start, file.length)
+        parquetFileReader.read(modifiedFile, requiredSchema, partitionSchema, 
internalSchemaOpt, filters, storageConf)
+      } catch {
+        case _: ClassCastException =>

Review Comment:
   Where is `ClassCastException` thrown? `parquetFileReader.read` should not be 
triggered twice just because of this exception.



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