Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6EB19200BE2 for ; Wed, 30 Nov 2016 17:24:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6D775160B2A; Wed, 30 Nov 2016 16:24:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B85D1160B19 for ; Wed, 30 Nov 2016 17:23:59 +0100 (CET) Received: (qmail 98925 invoked by uid 500); 30 Nov 2016 16:23:58 -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 98802 invoked by uid 99); 30 Nov 2016 16:23:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2016 16:23:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 8A4192C2A66 for ; Wed, 30 Nov 2016 16:23:58 +0000 (UTC) Date: Wed, 30 Nov 2016 16:23:58 +0000 (UTC) From: "Doug Cutting (JIRA)" To: dev@avro.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AVRO-1965) Reparsing an existing schema mutates the schema MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 30 Nov 2016 16:24:00 -0000 [ https://issues.apache.org/jira/browse/AVRO-1965?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Doug Cutting updated AVRO-1965: ------------------------------- Attachment: AVRO-1965.patch Here's a patch that should fix this. The null namespace was not set correctly for nested schemas when parsing. > Reparsing an existing schema mutates the schema > ----------------------------------------------- > > Key: AVRO-1965 > URL: https://issues.apache.org/jira/browse/AVRO-1965 > Project: Avro > Issue Type: Bug > Components: java > Affects Versions: 1.8.1 > Reporter: David Maughan > Priority: Minor > Fix For: 1.8.2 > > Attachments: AVRO-1965.patch > > > h2. Overview > In certain scenarios re-parsing a schema constructed via {{SchemaBuilder}} or {{Schema.createRecord}} produces a schema that is no longer equal to the original. In the below example, after parsing the existing schema, the namespace of the top level record is cascaded down to the bottom level record. Note that the way the top level record is being created with the namespace as part of the name {{default.a}} is the same way Hive's {{AvroSerDe}} constructs a schema from a Hive table's metadata. > h2. Failing test case > {code} > Schema d = SchemaBuilder.builder().intType(); > Schema c = SchemaBuilder.record("c").fields().name("d").type(d).noDefault().endRecord(); > Schema b = SchemaBuilder.record("b").fields().name("c").type(c).noDefault().endRecord(); > Schema a1 = SchemaBuilder.record("default.a").fields().name("b").type(b).noDefault().endRecord(); > Schema a2 = new Schema.Parser().parse(a1.toString()); > // a1 = {"type":"record","name":"a","namespace":"default","fields":[{"name":"b","type":{"type":"record","name":"b","namespace":"","fields":[{"name":"c","type":{"type":"record","name":"c","fields":[{"name":"d","type":"int"}]}}]}}]} > // a2 = {"type":"record","name":"a","namespace":"default","fields":[{"name":"b","type":{"type":"record","name":"b","namespace":"","fields":[{"name":"c","type":{"type":"record","name":"c","namespace":"default","fields":[{"name":"d","type":"int"}]}}]}}]} > assertThat(a2, is(a1)); > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)