voonhous commented on code in PR #17599:
URL: https://github.com/apache/hudi/pull/17599#discussion_r2643567911
##########
hudi-common/src/main/java/org/apache/hudi/avro/AvroRecordContext.java:
##########
@@ -70,22 +70,20 @@ public AvroRecordContext() {
public static Object getFieldValueFromIndexedRecord(
IndexedRecord record,
String fieldName) {
- Schema currentSchema = record.getSchema();
+ HoodieSchema currentSchema =
HoodieSchema.fromAvroSchema(record.getSchema());
IndexedRecord currentRecord = record;
String[] path = fieldName.split("\\.");
for (int i = 0; i < path.length; i++) {
- if (currentSchema.isUnion()) {
- currentSchema = AvroSchemaUtils.getNonNullTypeFromUnion(currentSchema);
- }
- Schema.Field field = currentSchema.getField(path[i]);
- if (field == null) {
+ currentSchema = currentSchema.getNonNullType();
+ Option<HoodieSchemaField> fieldOpt = currentSchema.getField(path[i]);
+ if (fieldOpt.isEmpty()) {
return null;
}
- Object value = currentRecord.get(field.pos());
+ Object value = currentRecord.get(fieldOpt.get().pos());
Review Comment:
Done
--
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]