avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Cutting (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1057) Java builder API fails when default value does not match the first type in a union
Date Fri, 13 Apr 2012 19:24:16 GMT

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

Doug Cutting commented on AVRO-1057:
------------------------------------

I think this is correct.  The specification says, "Default values for union fields correspond
to the first schema in the union"  (http://avro.apache.org/docs/current/spec.html).  So the
default value for {boolean null} must be a boolean.
                
> Java builder API fails when default value does not match the first type in a union
> ----------------------------------------------------------------------------------
>
>                 Key: AVRO-1057
>                 URL: https://issues.apache.org/jira/browse/AVRO-1057
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.6.3
>            Reporter: Christophe Taton
>            Priority: Minor
>
> The following definition works fine with the builder:
> record Rec {
>   union { boolean, null } field = false;
> }
> but this one fails:
> record Rec {
>   union { boolean, null } field = null;
> }
> Rec.newBuilder().build() fails with this error:
> org.apache.avro.AvroRuntimeException: org.apache.avro.AvroTypeException: Non-boolean
default for boolean: null
> 	at Rec$Builder.build
> Caused by: org.apache.avro.AvroTypeException: Non-boolean default for boolean: null
> 	at org.apache.avro.io.parsing.ResolvingGrammarGenerator.encode(ResolvingGrammarGenerator.java:393)
> 	at org.apache.avro.io.parsing.ResolvingGrammarGenerator.encode(ResolvingGrammarGenerator.java:350)
> 	at org.apache.avro.data.RecordBuilderBase.defaultValue(RecordBuilderBase.java:178)
> 	at Rec$Builder.build

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message