in src/main/java/com/google/cloud/solutions/autotokenize/common/AvroSchemaToCatalogSchema.java [207:226]
private ColumnSchemaFlatKeys processUnion() {
var unionTypes = schema().getTypes();
checkArgument(
unionTypes.size() == 2 && unionTypes.get(0).getType().equals(Schema.Type.NULL),
"Only nullable union with one type is supported. found " + unionTypes);
var unionSchemaPair =
SchemaProcessor.builder()
.setSchema(unionTypes.get(1))
.setAvroParentFlatKey(avroParentFlatKey())
.setCatalogParentFlatKey(catalogParentFlatKey())
.setIgnoreTopRecordNameKey(true)
.build()
.process();
var unionSchema =
schemaBuilder().mergeFrom(unionSchemaPair.columnSchema()).setMode("NULLABLE").build();
return ColumnSchemaFlatKeys.of(unionSchema, unionSchemaPair.flatKeys());
}