shardulm94 commented on code in PR #4242:
URL: https://github.com/apache/iceberg/pull/4242#discussion_r864790627
##########
core/src/main/java/org/apache/iceberg/avro/BuildAvroProjection.java:
##########
@@ -154,13 +154,13 @@ public Schema.Field field(Schema.Field field,
Supplier<Schema> fieldResult) {
@Override
public Schema union(Schema union, Iterable<Schema> options) {
- Preconditions.checkState(AvroSchemaUtil.isOptionSchema(union),
- "Invalid schema: non-option unions are not supported: %s", union);
- Schema nonNullOriginal = AvroSchemaUtil.fromOption(union);
- Schema nonNullResult =
AvroSchemaUtil.fromOptions(Lists.newArrayList(options));
+ if (AvroSchemaUtil.isOptionSchema(union)) {
+ Schema nonNullOriginal = AvroSchemaUtil.fromOption(union);
+ Schema nonNullResult =
AvroSchemaUtil.fromOptions(Lists.newArrayList(options));
- if (!Objects.equals(nonNullOriginal, nonNullResult)) {
- return AvroSchemaUtil.toOption(nonNullResult);
+ if (!Objects.equals(nonNullOriginal, nonNullResult)) {
+ return AvroSchemaUtil.toOption(nonNullResult);
+ }
}
return union;
Review Comment:
Can we add a test case for these scenarios? Given that the issue here is
nuanced and not already being tested elsewhere, we should add test cases to
avoid future regressions.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]