Return-Path: X-Original-To: apmail-avro-dev-archive@www.apache.org Delivered-To: apmail-avro-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 19D4D10694 for ; Thu, 30 Jan 2014 19:08:21 +0000 (UTC) Received: (qmail 81808 invoked by uid 500); 30 Jan 2014 19:08:09 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 81712 invoked by uid 500); 30 Jan 2014 19:08:09 -0000 Mailing-List: contact dev-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list dev@avro.apache.org Received: (qmail 81698 invoked by uid 99); 30 Jan 2014 19:08:09 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jan 2014 19:08:09 +0000 Date: Thu, 30 Jan 2014 19:08:09 +0000 (UTC) From: "Doug Cutting (JIRA)" To: dev@avro.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AVRO-1449) Check default value's type matches union at schema parse time MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AVRO-1449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13886928#comment-13886928 ] Doug Cutting commented on AVRO-1449: ------------------------------------ Your improvements look great. +1 I'll commit this soon unless someone objects or commits it first. > 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 > 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)