linliu-code commented on code in PR #17601:
URL: https://github.com/apache/hudi/pull/17601#discussion_r2743200579
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/io/storage/HoodieSparkParquetReader.java:
##########
@@ -121,35 +129,64 @@ private ClosableIterator<InternalRow>
getInternalRowIterator(Schema readerSchema
if (requestedSchema == null) {
requestedSchema = readerSchema;
}
- StructType readerStructType =
HoodieInternalRowUtils.getCachedSchema(readerSchema);
- StructType requestedStructType =
HoodieInternalRowUtils.getCachedSchema(requestedSchema);
- storage.getConf().set(ParquetReadSupport.PARQUET_READ_SCHEMA,
readerStructType.json());
- storage.getConf().set(ParquetReadSupport.SPARK_ROW_REQUESTED_SCHEMA(),
requestedStructType.json());
+
+ MessageType fileSchema = getFileSchema();
+ Schema nonNullSchema =
AvroSchemaUtils.getNonNullTypeFromUnion(requestedSchema);
+ Option<MessageType> messageSchema =
Option.of(getAvroSchemaConverter(storage.getConf().unwrapAs(Configuration.class)).convert(nonNullSchema));
+ Pair<StructType, StructType> readerSchemas =
+ SparkAdapterSupport$.MODULE$.sparkAdapter().getReaderSchemas(storage,
readerSchema, requestedSchema, fileSchema);
+ storage.getConf().set(ParquetReadSupport.PARQUET_READ_SCHEMA,
readerSchemas.getLeft().json());
+ storage.getConf().set(ParquetReadSupport.SPARK_ROW_REQUESTED_SCHEMA(),
readerSchemas.getRight().json());
storage.getConf().set(SQLConf.PARQUET_BINARY_AS_STRING().key(),
SQLConf.get().getConf(SQLConf.PARQUET_BINARY_AS_STRING()).toString());
storage.getConf().set(SQLConf.PARQUET_INT96_AS_TIMESTAMP().key(),
SQLConf.get().getConf(SQLConf.PARQUET_INT96_AS_TIMESTAMP()).toString());
- ParquetReader<InternalRow> reader =
ParquetReader.<InternalRow>builder((ReadSupport) new ParquetReadSupport(), new
Path(path.toUri()))
+ ParquetReader<InternalRow> reader = ParquetReader.<InternalRow>builder(
+ (ReadSupport)
SparkAdapterSupport$.MODULE$.sparkAdapter().getParquetReadSupport(messageSchema),
Review Comment:
The readerSchema is checked to have timestamp columns, and add the
configuration in the storage accordingly.
--
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]