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 7EEE6200AE3 for ; Wed, 4 May 2016 17:02:38 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7D5B01609FC; Wed, 4 May 2016 15:02:38 +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 A0F0F1609A1 for ; Wed, 4 May 2016 17:02:37 +0200 (CEST) Received: (qmail 28570 invoked by uid 500); 4 May 2016 15:02:36 -0000 Mailing-List: contact user-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@avro.apache.org Delivered-To: mailing list user@avro.apache.org Received: (qmail 28558 invoked by uid 99); 4 May 2016 15:02:36 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 May 2016 15:02:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 19B4B180177 for ; Wed, 4 May 2016 15:02:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.879 X-Spam-Level: * X-Spam-Status: No, score=1.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 1TZY2fkLP8eD for ; Wed, 4 May 2016 15:02:35 +0000 (UTC) Received: from mail-yw0-f181.google.com (mail-yw0-f181.google.com [209.85.161.181]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id 840505FBC0 for ; Wed, 4 May 2016 15:02:34 +0000 (UTC) Received: by mail-yw0-f181.google.com with SMTP id t10so96933083ywa.0 for ; Wed, 04 May 2016 08:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=k0zIrdOILS4jMD5cNM7RzipYHjG8rxbXmaJO7SfSYhg=; b=aM/39e+xLZK70Ci95eHhO/z5jFLRc6Gj14uDARGlWxQh33U9oUgaIKL/13OqEw7s8E bClCwx4ZyYcEaGRtibovaws5jCANgOrfIoQVpoH8WBetb8vF2OSer1YpcUd2KRZ7Ef7p tAhz5ekJTVH8arueSsfzKjH8Xekt5kM09Wvhb6JHsivT9139Vkv5tAnjlwTVwlJ57CtK 0kBub+RnhssREyaxpKFdoBdlxzab7WMiY/OKBiDms47LwYzNOVXfR6Ks/Rs2ftPTVJM5 ffOH6ZHmZ0JrQaoJMVUH0f9QM3pGZaCt7jeATgLNzDadrK3t0GFUuJnJQ+xGzwvk8m1t MPMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=k0zIrdOILS4jMD5cNM7RzipYHjG8rxbXmaJO7SfSYhg=; b=X1BdCyobmmUKhfDk6ue2HKKGOujokRAksYLipBxyRWvcIz0u1LgzP+v1tHtHb5Y2Qz FF6ncgEXhsUqxotGuQpnuSbI8Zhv0+Z9DWnCE4isRFtFWBRFvvT41WhnXUz0M5w+pRZq qCWBY1R925lAPBnuSEgs5+fujM1uvE6L5ol8vGlatGCym+Jrj7nLjepTovjaSTQgUvSm t1aMrL7jaY4a/7jgWakYjnkiUGq2maQoNKq54z36dTYtkeS5L8nCCL3mEAROIc6SAvWn T7KboQkepkOjMbYnjLj1aHSbJYKHN0kfWLiZ2naxtj57RM/hBzDcNS/MDiVcwOH4oJKt DHRQ== X-Gm-Message-State: AOPr4FXxvvZm47N9tp0gKPU5mjNhxLLV6xx/ZHs3H0WpkFnlgCfVVveDBDcJ4qTaBtZSwwGOOfeSkVgbg4Rxsg== X-Received: by 10.37.196.71 with SMTP id u68mr4865278ybf.51.1462374153503; Wed, 04 May 2016 08:02:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.5.138 with HTTP; Wed, 4 May 2016 08:02:14 -0700 (PDT) From: Vinicius Carvalho Date: Wed, 4 May 2016 11:02:14 -0400 Message-ID: Subject: Schema resolution question To: user@avro.apache.org Content-Type: multipart/alternative; boundary=94eb2c053b64f2c8550532058381 archived-at: Wed, 04 May 2016 15:02:38 -0000 --94eb2c053b64f2c8550532058381 Content-Type: text/plain; charset=UTF-8 Hi there, I'm using Avro 1.8.0, and I'm not sure why one of my compatibility tests is failing. I have two schemas: V1: { "namespace" : "io.igx.android", "type" : "record", "name" : "Sensor", "fields" : [ {"name":"id","type":"string"}, {"name":"temperature", "type":"float"}, {"name":"acceleration", "type":"float","default":0.0}, {"name":"velocity","type":"float","default":0.0}, {"name":"accelerometer","type":[ "null",{ "type":"array", "items":"float" } ]}, {"name":"magneticField","type":[ "null",{ "type":"array", "items":"float" } ]}, {"name":"orientation","type":[ "null",{ "type":"array", "items":"float" } ],"default":"null"} ] } V2: { "namespace" : "io.igx.android", "type" : "record", "name" : "Sensor", "fields" : [ {"name":"id","type":"string"}, {"name":"temperature", "type":"float", "default":0.0}, {"name":"acceleration", "type":"float","default":0.0}, {"name":"velocity","type":"float","default":0.0}, {"name":"accelerometer","type":[ "null",{ "type":"array", "items":"float" } ]}, {"name":"magneticField","type":[ "null",{ "type":"array", "items":"float" } ]} ] } As you can see the only difference between those two is that one of the arrays is removed from V2, and I've added a default value to a property on V2. If I run: SchemaCompatibility.checkReaderWriterCompatibility(load("schemas/sensor_v2.avsc"),load("schemas/sensor_v1.avsc")).getType() It prints out that data written in v2 should be able to be read by v1, which seems logical But when I try to deserialize data from v2 using v1 reader I get an error: Sensor v1Fromv2 = deserialize(v2Bytes,v1.getSchema(),v2.getSchema()); private T deserialize(byte[] bytes, Schema reader, Schema writer) throws Exception{ DatumReader datumReader = new SpecificDatumReader<>(writer,reader); Decoder decoder = DecoderFactory.get().binaryDecoder(bytes,null); return (T) datumReader.read(null,decoder); } org.apache.avro.AvroTypeException: Non-null default value for null type: "null" Not sure why is the deserialization not working if the compatibility check passes Any ideas? Regards --94eb2c053b64f2c8550532058381 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi there, I'm using Avro 1.8.0, and I'm not sure w= hy one of my compatibility tests is failing.

I have two = schemas:

V1:

{
=
=C2=A0 "namespace" : "io.igx.android",
= =C2=A0 "type" : "record",
=C2=A0 "name&q= uot; : "Sensor",
=C2=A0 "fields" : [
=C2=A0 =C2=A0 {"name":"id","type":"str= ing"},
=C2=A0 =C2=A0 {"name":"temperature&quo= t;, "type":"float"},
=C2=A0 =C2=A0 {"nam= e":"acceleration", "type":"float","= default":0.0},
=C2=A0 =C2=A0 {"name":"velocit= y","type":"float","default":0.0},
<= div>=C2=A0 =C2=A0 {"name":"accelerometer","type&qu= ot;:[
=C2=A0 =C2=A0 =C2=A0 "null",{
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 "type":"array",
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 "items":"float"
=C2=A0 = =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 ]},
=C2=A0 =C2=A0 {"= name":"magneticField","type":[
=C2=A0 = =C2=A0 =C2=A0 "null",{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 &quo= t;type":"array",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "= ;items":"float"
=C2=A0 =C2=A0 =C2=A0 }
= =C2=A0 =C2=A0 ]},
=C2=A0 =C2=A0 {"name":"orientati= on","type":[
=C2=A0 =C2=A0 =C2=A0 "null"= ,{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "type":"array"= ,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "items":"float"=
=C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 ],"default&q= uot;:"null"}

=C2=A0 ]

}

V2:
{
=C2= =A0 "namespace" : "io.igx.android",
=C2=A0 &q= uot;type" : "record",
=C2=A0 "name" : &q= uot;Sensor",
=C2=A0 "fields" : [
=C2=A0 = =C2=A0 {"name":"id","type":"string"= },
=C2=A0 =C2=A0 {"name":"temperature", "= ;type":"float", "default":0.0},
=C2=A0 = =C2=A0 {"name":"acceleration", "type":"f= loat","default":0.0},
=C2=A0 =C2=A0 {"name&qu= ot;:"velocity","type":"float","default&q= uot;:0.0},
=C2=A0 =C2=A0 {"name":"accelerometer&qu= ot;,"type":[
=C2=A0 =C2=A0 =C2=A0 "null",{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "type":"array",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "items":"float"
=C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 ]},
=C2=A0 = =C2=A0 {"name":"magneticField","type":[
=
=C2=A0 =C2=A0 =C2=A0 "null",{
=C2=A0 =C2=A0 =C2=A0= =C2=A0 "type":"array",
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 "items":"float"
=C2=A0 =C2=A0 =C2=A0 }=
=C2=A0 =C2=A0 ]}

=C2=A0 ]
}

As you can see the only differ= ence between those two is that one of the arrays is removed from V2, and I&= #39;ve added a default value to a property on V2.

= If I run:=C2=A0
SchemaCompatibility.checkReaderWriterCompatibilit= y(load("schemas/sensor_v2.avsc"),load("schemas/sensor_v1.avs= c")).getType()

It prints out that data wr= itten in v2 should be able to be read by v1, which seems logical
=
But when I try to deserialize data from v2 using v1 reader I= get an error:

Sensor v1Fromv2 =3D deserialize(v2B= ytes,v1.getSchema(),v2.getSchema());

priv= ate <T> T deserialize(byte[] bytes, Schema reader, Schema writer) thr= ows Exception{
DatumReader datumReader =3D new SpecificDatumReader<>(writer,reader= );
Decoder de= coder =3D DecoderFactory.get().binaryDecoder(bytes,null);
return (T) datumReader.read(nu= ll,decoder);
}=
org.apache.avro.AvroTypeException: Non-null default value = for null type: "null"

Not sure why i= s the deserialization not working if the compatibility check passes

Any ideas?

Regards
--94eb2c053b64f2c8550532058381--