avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Percy (JIRA)" <j...@apache.org>
Subject [jira] [Created] (AVRO-1118) Specifying null as default of a union only works if null is specified as first type in the union
Date Wed, 20 Jun 2012 02:48:42 GMT
Mike Percy created AVRO-1118:
--------------------------------

             Summary: 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: 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