Search code examples
avroconfluent-platformconfluent-schema-registry

Avro / Schema Registry - Make new field that is non-nullable / required


I'm starting to use Avro / Confluent's Schema Registry and .avsc files and want to add a new field that is required in the schema.

The old schema is like this for example:

{
  "name": ...
  "fields": [
    {"name": "one", "type": "string"}
  ]
}

I wanto to change it to:


{
  "one": string,
  "two": string,
}

How do I go about making the two field required / non-nullable when trying to evolve a schema ? Because I have to add a default value to it it will always be able to be one or the other.

Edit

It is worth pointing out that I'm using Confluent's Schema Registry and trying to Evolve a Schema!


Solution

  • I think I just solved my own question. For future reference:

    It is not possible to set an absolutely required field when using Compatibility: BACKWARDS obviously it would break the rest of the schema.

    So the answer to this I guess would be setting it to NONE (in my case).

    Any other answers with insights would be helpful, but I'm going with this solution by now!