Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the default value of an union in avro Idl?

For unions in avro Idl something like below what would be the default values?
1. union {null, string} var = null;
2. union {string, null} = "xyz";
3. union {null, string} = "xyz";
4. union {null, string, array} = [];

My assumption is the default values would be always the first item in the union. Is my understand correct?

like image 267
barath Avatar asked Sep 30 '22 11:09

barath


1 Answers

okay, I found the answer (from the apache user guide).
The default type of an union will be always it's first value. So, here the default types for the above examples would be NULL, STRING, NULL and NULL. And the default values would be the ones those assigned to the union.

So, in the above unions only the first and second unions are syntactically correct and I think all other (3 and 4) unions are syntactically wrong because defaultValues assigned to them doesn't match the union's defaultType.

like image 69
barath Avatar answered Oct 13 '22 01:10

barath