wmoustafa commented on code in PR #9502: URL: https://github.com/apache/iceberg/pull/9502#discussion_r1671302722
########## core/src/main/java/org/apache/iceberg/avro/GenericAvroReader.java: ########## @@ -155,6 +162,41 @@ public ValueReader<?> record(Type partner, Schema record, List<ValueReader<?>> f return recordReader(readPlan, avroSchemas.get(partner), record.getFullName()); } + Object toGenericRecord(Type type, Object data) { + // Recursively convert data to GenericRecord if type is a StructType. + // TODO: Rewrite this as a visitor. + if (type instanceof Types.StructType) { + Types.StructType structType = (Types.StructType) type; + GenericData.Record genericRecord = new GenericData.Record(AvroSchemaUtil.convert(type)); + int index = 0; + for (Types.NestedField field : structType.fields()) { + genericRecord.put( + field.name(), toGenericRecord(field.type(), ((GenericRecord) data).get(index))); + index++; Review Comment: This will be converting actual data (some constant) coming from the schema. The data is represented in a JSON representation denoting the default value. Not sure if there will be a notion of field ID here. Further, since this is converting data from one representation to another, the target object is created from scratch and we are just reformatting the input object so not sure if field ID comparison applies here. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org