avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Blue (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, 21 Apr 2016 16:31:25 GMT

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

Ryan Blue commented on AVRO-1118:
---------------------------------

Ivan, the default is the one without quotes. {{"null"}} is a type name, while {{null}} is
a null value in JSON that gets interpreted as a value.

> 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 was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message