Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # dev >> [jira] [Commented] (AVRO-1449) Check default value's type matches union at schema parse time


Copy link to this message
-
[jira] [Commented] (AVRO-1449) Check default value's type matches union at schema parse time

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

Hudson commented on AVRO-1449:
------------------------------

FAILURE: Integrated in AvroJava #438 (See [https://builds.apache.org/job/AvroJava/438/])
AVRO-1449. Java: Optionally validate default values while reading schemas. (cutting: rev 1564571)
* /avro/trunk/CHANGES.txt
* /avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java
* /avro/trunk/lang/java/compiler/src/test/idl/input/interop.avdl
* /avro/trunk/lang/java/compiler/src/test/idl/input/simple.avdl
* /avro/trunk/lang/java/compiler/src/test/idl/output/interop.avpr
* /avro/trunk/lang/java/compiler/src/test/idl/output/simple.avpr
* /avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
* /avro/trunk/share/test/data/schema-tests.txt
> Check default value's type matches union at schema parse time
> -------------------------------------------------------------
>
>                 Key: AVRO-1449
>                 URL: https://issues.apache.org/jira/browse/AVRO-1449
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.7.6
>            Reporter: Tom White
>            Assignee: Doug Cutting
>             Fix For: 1.7.7
>
>         Attachments: AVRO-1449.patch, AVRO-1449.patch
>
>
> A common Avro mistake is to declare optional fields as follows:
> {noformat}
> "type": ["string", "null"], "default": null
> {noformat}
> This fails at runtime since the default value's type (null) doesn't match the type of the first type in the union (string). The correct declaration is:
> {noformat}
> "type": ["null", "string"], "default": null
> {noformat}
> Doug [suggested|https://groups.google.com/a/cloudera.org/forum/#!msg/cdk-dev/Xgo5YKEcQ1Q/VkyWP2gnOEMJ] that we throw an exception at schema parse time for cases like this. To ensure backwards compatibility we could make it optional; tools could emit a warning.

--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

 
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB