avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1482) in specification, put "null" first in unions
Date Fri, 14 Mar 2014 19:42:45 GMT

    [ https://issues.apache.org/jira/browse/AVRO-1482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13935527#comment-13935527
] 

ASF subversion and git services commented on AVRO-1482:
-------------------------------------------------------

Commit 1577673 from [~cutting] in branch 'avro/trunk'
[ https://svn.apache.org/r1577673 ]

AVRO-1482. In specification, place null first in unions as best practice.

> in specification, put "null" first in unions
> --------------------------------------------
>
>                 Key: AVRO-1482
>                 URL: https://issues.apache.org/jira/browse/AVRO-1482
>             Project: Avro
>          Issue Type: Improvement
>          Components: doc
>            Reporter: Doug Cutting
>             Fix For: 1.7.7
>
>         Attachments: AVRO-1482.patch
>
>
> Unions with null are a common schema idiom.  When a default-value is specified, it is
most often null.  Default values for unions must be of the type of the first element in the
union.  So normally, when specifying a union with null, one places the null first so that
one can use null as the default value.  Folks often make the mistake of specifying null as
the default value when it is not the first value in the union.  Thus the best practice is
to put null as the first element when it is in a union unless you specify a non-null default
value.
> Several example schemas in the specification do not put the null first in the union schema.
 The specification should set a better example, to help folks to avoid this potential confusion.
 It might also mention this issue more explicitly.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message