You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2014/02/05 01:10:11 UTC

[jira] [Commented] (AVRO-1449) Check default value's type matches union at schema parse time

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

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

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

AVRO-1449. Java: Optionally validate default values while reading schemas.

> Check default value's type matches union at schema parse time
> -------------------------------------------------------------
>
>                 Key: AVRO-1449
>                 URL: https://issues.apache.org/jira/browse/AVRO-1449
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.7.6
>            Reporter: Tom White
>         Attachments: AVRO-1449.patch, AVRO-1449.patch
>
>
> A common Avro mistake is to declare optional fields as follows:
> {noformat}
> "type": ["string", "null"], "default": null
> {noformat}
> This fails at runtime since the default value's type (null) doesn't match the type of the first type in the union (string). The correct declaration is:
> {noformat}
> "type": ["null", "string"], "default": null
> {noformat}
> Doug [suggested|https://groups.google.com/a/cloudera.org/forum/#!msg/cdk-dev/Xgo5YKEcQ1Q/VkyWP2gnOEMJ] that we throw an exception at schema parse time for cases like this. To ensure backwards compatibility we could make it optional; tools could emit a warning.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)