avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Wadsworth (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1118) Specifying null as default of a union only works if null is specified as first type in the union
Date Thu, 09 May 2013 16:19:16 GMT

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

Eric Wadsworth commented on AVRO-1118:

Actually, that seems wrong. There shouldn't be quotes around the default value of null. This
works for me:

"type": ["null", "string"] to set "default": null

--- wad
> Specifying null as default of a union only works if null is specified as first type in
the union
> ------------------------------------------------------------------------------------------------
>                 Key: AVRO-1118
>                 URL: https://issues.apache.org/jira/browse/AVRO-1118
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.6.3
>            Reporter: Mike Percy
> There is some unexpected behavior I am coming across where if I specify a union as such:
> "type": ["string", "null"],
> "default": null
> I get an Exception:
> Exception in thread "main" org.apache.avro.AvroTypeException: Non-string default value
for string: null
> 	at org.apache.avro.io.parsing.ResolvingGrammarGenerator.encode(ResolvingGrammarGenerator.java:363)
> 	at org.apache.avro.io.parsing.ResolvingGrammarGenerator.encode(ResolvingGrammarGenerator.java:350)
> 	at org.apache.avro.io.parsing.ResolvingGrammarGenerator.getBinary(ResolvingGrammarGenerator.java:293)
> 	at org.apache.avro.io.parsing.ResolvingGrammarGenerator.resolveRecords(ResolvingGrammarGenerator.java:271)
> 	at org.apache.avro.io.parsing.ResolvingGrammarGenerator.generate(ResolvingGrammarGenerator.java:118)
> 	at org.apache.avro.io.parsing.ResolvingGrammarGenerator.generate(ResolvingGrammarGenerator.java:50)
> 	at org.apache.avro.io.ResolvingDecoder.resolve(ResolvingDecoder.java:82)
> 	at org.apache.avro.io.ResolvingDecoder.<init>(ResolvingDecoder.java:46)
> 	at org.apache.avro.io.DecoderFactory.resolvingDecoder(DecoderFactory.java:307)
> 	at org.apache.avro.generic.GenericDatumReader.getResolver(GenericDatumReader.java:118)
> 	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:133)
> 	at org.apache.avro.file.DataFileStream.next(DataFileStream.java:233)
> 	at org.apache.avro.file.DataFileStream.next(DataFileStream.java:220)
> ...
> Whereas if I specify the schema as:
> "type": ["null", "string"],
> "default": null
> It works as expected.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message