What I have in my Schema.avdl:
array<string> names = null;
Now instead of null, I want to have the default value as an empty array, so i tried and failed:
array<string> names = []; and array<string> names = {};
Can someone show me how to put an empty list as the default value ?
Thank you.
Default Values and Logical Types Default Values is one of the use case of Union where we can have multiple field value to take different types. And in default every field in avro schema are not nullable. Example : Making middle_name as nullable { "name": "middle_name", "type": ["null", "string"], "default": null }
The date logical type annotates the Avro integer primitive type. The integer type stores the number of days since midnight January 1, 1970 UTC. Load values using the date logical type into target columns using the following Vertica data types: DATE.
Avro schema definitions are JSON records. Because it is a record, it can define multiple fields which are organized in a JSON array. Each such field identifies the field's name as well as its type. The type can be something simple, like an integer, or something complex, like another record.
I'm not sure if this directly helps you, but in an avro schema declaration (.avsc), you could write the following:
{
"type": "record",
"namespace": "my.avro.schemas",
"name": "Schema",
"fields": [ {
"name": "string_arr",
"type": {
"type": "array",
"items": "string"
},
"default": []
}]
}
Note that the "default" field definition is an empty json array. Using the Builder of the parsed avro Schema class would fill the "string_arr" field with an empty array per default.
array<string> names = [];
works in Avro 1.8.2. This will generate the following field in JSON:
{
"name": "names",
"type": {
"type": "array",
"items": "string"
},
"default": []
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With