Replace a field of enum value in AVRO schema to string

757 views Asked by At

I need a little help in removing an ENUM and replacing it with String in an AVRO schema.

I have an avro schema file which has something like this among other entries:

{
                  "name": "anonymizedLanguage",
                  "type": [
                    "null",
                    "com.publicevents.common.LanguageCode"
                  ],
                  "default": null
}

The LanguageCode is also an avsc file with entries as below:

{
  "name": "LanguageCode",
  "type": "enum",
  "namespace": "com.publicevents.common",
  "symbols": [
    "EN",
    "NL",
    "FR",
    "ES"
  ]
}

I want to remove the language enum and move it to a string having the language code. How would I go about doing that ?

1

There are 1 answers

0
OneCricketeer On BEST ANSWER

You can only do "type": ["null", "string"]. You cannot make it "have" anything specific to a language within the schema, that's what an enum is for. Once it is a plain string, that would be app-specific validation logic to enforce it have specific values.