You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Joao Antonio (Jira)" <ji...@apache.org> on 2023/12/01 19:13:00 UTC

[jira] [Created] (AVRO-3913) Optional fields should not require a default value set to null

Joao Antonio created AVRO-3913:
----------------------------------

             Summary: 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


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)