[prev in list] [next in list] [prev in thread] [next in thread] 

List:       avro-dev
Subject:    [jira] [Commented] (AVRO-2035) default value for boolean field cannot be a string
From:       "Doug Cutting (JIRA)" <jira () apache ! org>
Date:       2017-06-21 17:03:01
Message-ID: JIRA.13072650.1494984454000.71656.1498064581685 () Atlassian ! JIRA
[Download RAW message or body]


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

Doug Cutting commented on AVRO-2035:
------------------------------------

Turning default value validation on would be an incompatible change, so it would need \
to come in a major release, i.e., 1.9.  There are probably applications which have \
invalid default values that are never used which validation would break.

For reference, this was added in AVRO-1449 and is discussed further there.  The \
intention was to turn it on in some future release, but that seems to have been \
forgotten.

> default value for boolean field cannot be a string
> --------------------------------------------------
> 
> Key: AVRO-2035
> URL: https://issues.apache.org/jira/browse/AVRO-2035
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.8.1
> Reporter: radai rosenblatt
> 
> suppose i have the following schema evolution:
> {code}
> {
> "name": "Bob",
> "type": "record",
> "fields": [
> {"name": "f1", "type": "int"}
> ]
> }
> {code}
> and then:
> {code}
> {
> "name": "Bob",
> "type": "record",
> "fields": [
> {"name": "f1", "type": "int"},
> {"name": "f2", "type": "boolean", "default": "true"}
> ]
> }
> {code}
> the default value for "f2" is specified as the _STRING_ "true" (and not the literal \
> boolean true).  if this default value is ever accessed (when reading a \
> gen1-serialized object as a gen2) we get this: {code}
> org.apache.avro.AvroTypeException: Non-boolean default for boolean: "true"
> 	at org.apache.avro.io.parsing.ResolvingGrammarGenerator.encode(ResolvingGrammarGenerator.java:408)
>   at org.apache.avro.io.parsing.ResolvingGrammarGenerator.getBinary(ResolvingGrammarGenerator.java:307)
>   at org.apache.avro.io.parsing.ResolvingGrammarGenerator.resolveRecords(ResolvingGrammarGenerator.java:285)
>   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:85)
> 	at org.apache.avro.io.ResolvingDecoder.<init>(ResolvingDecoder.java:49)
> 	at org.apache.avro.io.DecoderFactory.resolvingDecoder(DecoderFactory.java:307)
> 	at org.apache.avro.generic.GenericDatumReader.getResolver(GenericDatumReader.java:127)
>   at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:142)
> {code}
> yet Schema.parse() passes for this



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic