the-other-tim-brown commented on code in PR #13208:
URL: https://github.com/apache/hudi/pull/13208#discussion_r2059323105
##########
hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroReaderContext.java:
##########
@@ -231,14 +193,23 @@ public UnaryOperator<IndexedRecord> projectRecord(Schema
from, Schema to, Map<St
private Object getFieldValueFromIndexedRecord(
IndexedRecord record,
Schema recordSchema,
- String fieldName
- ) {
- Schema.Field field = recordSchema.getField(fieldName);
- if (field == null) {
- return null;
+ String fieldName) {
+ Schema currentSchema = recordSchema;
+ IndexedRecord currentRecord = record;
+ String[] path = fieldName.split("\\.");
+ for (int i = 0; i < path.length; i++) {
+ Schema.Field field = currentSchema.getField(path[i]);
+ if (field == null) {
+ return null;
+ }
+ Object value = currentRecord.get(field.pos());
+ if (i == path.length - 1) {
+ return value;
+ }
+ currentSchema = field.schema();
+ currentRecord = (IndexedRecord) value;
}
- int pos = field.pos();
- return record.get(pos);
+ return null;
Review Comment:
We could also consider switching to GenericRecord for reader context
--
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]