lokeshj1703 commented on code in PR #12127:
URL: https://github.com/apache/hudi/pull/12127#discussion_r1807311858
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/utils/SparkMetadataWriterUtils.java:
##########
@@ -194,66 +207,21 @@ private static List<HoodieRecord>
getBaseFileRecords(HoodieBaseFile baseFile, Ho
}
}
- private static Dataset<Row> toDataset(List<HoodieRecord> records, Schema
schema, SQLContext sqlContext, boolean isBaseFile) {
- List<GenericRecord> avroRecords = records.stream()
+ private static List<Row> toRows(List<HoodieRecord> records, Schema schema,
SQLContext sqlContext, String path) {
+ StructType structType =
AvroConversionUtils.convertAvroSchemaToStructType(schema);
+ Function1<GenericRecord, Row> converterToRow =
AvroConversionUtils.createConverterToRow(schema, structType);
+ List<Row> avroRecords = records.stream()
.map(r -> {
- if (isBaseFile) {
- return (GenericRecord) r.getData();
- }
- HoodieRecordPayload payload = (HoodieRecordPayload) r.getData();
try {
- return (GenericRecord) payload.getInsertValue(schema).get();
+ return (GenericRecord) (r.getData() instanceof GenericRecord ?
r.getData()
+ : ((HoodieRecordPayload) r.getData()).getInsertValue(schema,
new Properties()).get());
Review Comment:
Fixed 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]