[ 
https://issues.apache.org/jira/browse/AVRO-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joao Antonio updated AVRO-3913:
-------------------------------
    Status: Open  (was: Patch Available)

> Optional fields should not require a default value set to null
> --------------------------------------------------------------
>
>                 Key: AVRO-3913
>                 URL: https://issues.apache.org/jira/browse/AVRO-3913
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>            Reporter: Joao Antonio
>            Priority: Major
>         Attachments: AVRO-3913.patch
>
>
> The Avro Schema Specification states that when a field has type Union, the 
> type of its default value must match the first type in the Union. This quite 
> useful when defining optional fields, we just need to define the Field type 
> as Union and place the null type in the first index of the type array.
> When parsing an Avro Schema represented in JSON with the Schema.Parser class, 
> one has to set the field _default_ to {_}null{_}, even with the type is 
> defined as Union and _null_ is in the first index of the type array.
> The Schema.Parser should handle this corner case gracefully and allow 
> omitting the default value key for fields with type Union and its first type 
> {_}null{_}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to