Is it possible to have an optional field in the Avro schema (i.e. the field does not appear at all in the .JSON file)?
In my Avro scheme, I have two fields:
{"name": "author", "type": ["null", "string"], "default": null}, {"name": "importance", "type": ["null", "string"], "default": null},
And in my JSON files, these two fields can exist or not.
However, when they do not exist, I get an error message (for example, when I test such a JSON file using the avro-tools command-line client):
Expected field name not found: author
I understand that as long as the name field name exists in JSON, it can be null or a string value, but what I'm trying to express is that JSON is valid if the names of these fields do not exist , OR if they exist, and they are null or string. "
Can this be expressed in the Avro scheme? If so, how?
json avro
Emre sevinΓ§
source share