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 BB55210AC4 for ; Tue, 4 Mar 2014 17:29:34 +0000 (UTC) Received: (qmail 78619 invoked by uid 500); 4 Mar 2014 17:29:32 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 76894 invoked by uid 500); 4 Mar 2014 17:29:23 -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 76851 invoked by uid 99); 4 Mar 2014 17:29:21 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Mar 2014 17:29:21 +0000 Date: Tue, 4 Mar 2014 17:29:21 +0000 (UTC) From: "Matthew Campbell (JIRA)" To: dev@avro.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AVRO-997) Union of enum and null cannot be serialized 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-997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13919659#comment-13919659 ] Matthew Campbell commented on AVRO-997: --------------------------------------- We're running into this issue as well on Avro 1.7.6. We've got a IDL that imports some enum schemas in JSON format (provided by another tool) and we want to have some optional fields in a record of the enum type. These types can't be serialized, though. Just putting a +1 in for this being a blocker for us. We'll work around it in our model for now, but I wanted to leave a note here since the issue has a patch but hasn't been touched in a while. > Union of enum and null cannot be serialized > ------------------------------------------- > > Key: AVRO-997 > URL: https://issues.apache.org/jira/browse/AVRO-997 > Project: Avro > Issue Type: Bug > Affects Versions: 1.5.1 > Reporter: Aaron Kimball > Assignee: Sean Busbey > Fix For: 1.8.0 > > Attachments: AVRO-997.patch, AVRO-997.patch, AVRO-997.permissive-generic-api.patch > > > I have a schema like: > {code} > [ > { > "type": "enum", > "name": "Gender", > "symbols": ["M", "F"] > }, > { > "type" : "record", > "name" : "Foo", > "fields" : [ > { "type" : ["Gender", "null"], "name" : "gender" }, > ... > ] > } > ] > {code} > I build a record like {{Foo foo = new Foo(); foo.gender = Gender.M;}} > When I go to serialize this, I get: > {code}Not in union [{"type":"enum","name":"Gender","symbols":["M","F"]},"null"]: M > at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:482) > at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:70) > at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:104) > at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65) > at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:57) > {code} -- This message was sent by Atlassian JIRA (v6.2#6252)