rdblue commented on code in PR #12238: URL: https://github.com/apache/iceberg/pull/12238#discussion_r1980206785
########## core/src/main/java/org/apache/iceberg/avro/AvroSchemaVisitor.java: ########## @@ -33,21 +36,30 @@ public static <T> T visit(Schema schema, AvroSchemaVisitor<T> visitor) { Preconditions.checkState( !visitor.recordLevels.contains(name), "Cannot process recursive Avro record %s", name); - visitor.recordLevels.push(name); + if (schema.getLogicalType() instanceof VariantLogicalType) { + Preconditions.checkArgument( + AvroSchemaUtil.isVariantSchema(schema), "Invalid variant record: %s", schema); - List<Schema.Field> fields = schema.getFields(); - List<String> names = Lists.newArrayListWithExpectedSize(fields.size()); - List<T> results = Lists.newArrayListWithExpectedSize(fields.size()); - for (Schema.Field field : schema.getFields()) { - names.add(field.name()); - T result = visitWithName(field.name(), field.schema(), visitor); - results.add(result); + return visitor.variant( + schema, + visit(schema.getField(METADATA).schema(), visitor), + visit(schema.getField(VALUE).schema(), visitor)); Review Comment: Should this be `visitWithName(METADATA, schema, visitor)`? -- 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