avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Cutting (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (AVRO-1449) Check default value's type matches union at schema parse time
Date Wed, 05 Feb 2014 00:12:09 GMT

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

Doug Cutting resolved AVRO-1449.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 1.7.7
         Assignee: Doug Cutting

I committed this.

> 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
>            Assignee: Doug Cutting
>             Fix For: 1.7.7
>
>         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)

Mime
View raw message