UserBSS1
UserBSS1

Reputation: 2211

Update avdl (avro schema) field from required to optional (NULL) value

My avdl is defined like this,

@namespace("my.event")
protocol Customer {

 record Address { 
  string street;
 }
}

But after the event is published and schema is registered, I want to make the street type to allow null value as well. I want the change to be forward/backward compatible. How can I do that? Will defining a new namespace before record can do that? (https://github.com/ga4gh/ga4gh-schemas/issues/344#unions or https://docs.oracle.com/database/nosql-12.2.4.4/GettingStartedGuide/schemaevolution.html) What about,

union{null, string} street  = null;

Upvotes: 2

Views: 4056

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191743

Yes, if you want to make a field a no-longer required, you can wrap it in a null, with its existing type. I work with people that I see doing this quite often and the Confluent Schema Registry is set to BACKWARDS configuration for those topics.

Note: You can (and should) always check the compatiblity of your new schema before you publish events

Upvotes: 1

Related Questions