Return-Path: Delivered-To: apmail-avro-dev-archive@www.apache.org Received: (qmail 20146 invoked from network); 4 Jan 2011 22:39:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Jan 2011 22:39:18 -0000 Received: (qmail 67164 invoked by uid 500); 4 Jan 2011 22:30:12 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 67107 invoked by uid 500); 4 Jan 2011 22:30:11 -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 67075 invoked by uid 99); 4 Jan 2011 22:30:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jan 2011 22:30:09 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jan 2011 22:30:08 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id p04MTmJW013300 for ; Tue, 4 Jan 2011 22:29:48 GMT Message-ID: <10188270.146251294180188236.JavaMail.jira@thor> Date: Tue, 4 Jan 2011 17:29:48 -0500 (EST) From: "Doug Cutting (JIRA)" To: dev@avro.apache.org Subject: [jira] Updated: (AVRO-717) SpecificDatumWriter is using GenericData.resolveUnion sometimes In-Reply-To: <13825414.250011292962503031.JavaMail.jira@thor> 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-717?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Doug Cutting updated AVRO-717: ------------------------------ Resolution: Fixed Hadoop Flags: [Reviewed] Status: Resolved (was: Patch Available) I committed this. Thanks, Joe! > SpecificDatumWriter is using GenericData.resolveUnion sometimes > --------------------------------------------------------------- > > Key: AVRO-717 > URL: https://issues.apache.org/jira/browse/AVRO-717 > Project: Avro > Issue Type: Bug > Components: java > Affects Versions: 1.4.1 > Environment: Mac, Java 6. > Reporter: Joe Crobak > Assignee: Joe Crobak > Fix For: 1.5.0 > > Attachments: AVRO-717.patch, AVRO-717.patch > > > From: [avro-user|http://mail-archives.apache.org/mod_mbox/avro-user/201012.mbox/%3CAANLkTin4kEN9m-YXyRH7TLLYF-e_E2TczHca6BazO9ch@mail.gmail.com%3E] > I've tried to use union of null and the enum-type, but I've run into an issue with this approach when using the AvroOutputFormat. The following code summarizes my issue: > {code} > public void testDataWriteWithSchema() throws IOException { > final DataFileWriter new DataFileWriter(new SpecificDatumWriter()); > writer.create(Event.SCHEMA$, new File("target/datafile-test.avro")); > writer.append(getEvent()); > writer.close(); > } > public void testDataWriteWithSchemaWithClass() throws IOException { > final DataFileWriter new DataFileWriter(new SpecificDatumWriter(Event.class)); > writer.create(Event.SCHEMA$, new File("target/datafile-test.avro")); > writer.append(getEvent()); > writer.close(); > } > {code} > When I don't pass in the Event.class to SpecificDatumWriter (the first test method), the above test fails with the following exception: > {noformat} > Not in union ["null", {"type":"enum","name":"Suit","namespace":"foo","symbols":["SPADES","CLUBS","HEARS","DIAMONDS"]}]: SPADES > at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:382) > at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:67) > at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:100) > at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:62) > at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:54) > at org.apache.avro.file.DataFileWriter.append(DataFileWriter.java:245) > {noformat} > Scott Carey's reply: > {quote} > This looks like a bug. Can you file a ticket? In the first case, the constructor is not > initializing the SpecificData object, which means that it is using GenericData.resolveUnion() > instead of SpecificData.resolveUnion(). > The empty param constructor in SpecificDatumWriter should be > public SpecificDatumWriter() \{ super(SpecificData.get()); } > public SpecificDatumWriter() { } > {quote} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.