Return-Path: X-Original-To: apmail-avro-user-archive@www.apache.org Delivered-To: apmail-avro-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 117F5EC44 for ; Wed, 27 Feb 2013 22:53:26 +0000 (UTC) Received: (qmail 65972 invoked by uid 500); 27 Feb 2013 22:53:25 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 65906 invoked by uid 500); 27 Feb 2013 22:53:25 -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 65897 invoked by uid 99); 27 Feb 2013 22:53:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Feb 2013 22:53:25 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of fgaliegue@gmail.com designates 74.125.83.50 as permitted sender) Received: from [74.125.83.50] (HELO mail-ee0-f50.google.com) (74.125.83.50) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Feb 2013 22:53:19 +0000 Received: by mail-ee0-f50.google.com with SMTP id e51so989484eek.9 for ; Wed, 27 Feb 2013 14:52:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=Rf8W0OUJjAHBDhLL7v6uLXAAxTdh8X0Ge5H8QpzNGGY=; b=DTFmP3SVyemFa5xGgyJkc2zEydcs4H19j835SNW1U54ZykCy6lBUkxsObXyuU0ZY7Q DHrgA8HzWnwNPh29Z9Zfp75ohIr1/hPpTxeO3sQAZ5ql3xFYeHqLZUV7y21tf4XeENp1 q0oJebk6MMXniS7TJqU8SurqTFa+3JMnf9Ty9Xs/XMcFcwqkEgtoEj9ErRaQTf+CRP8m FWyf5rIZmXn6JerPj8Kg4i5gngjXl5G8oBGtk0dSldBfYcq4zwbaibqaSgGdzOsP3uOx GnjPBlXCAMz/Ff/KPDwlPmt0FNnXz7hXZclEK1YCp3va2Itniwd6T+uYAZseov6H+2Rc eA7w== MIME-Version: 1.0 X-Received: by 10.14.205.68 with SMTP id i44mr10366503eeo.25.1362005579398; Wed, 27 Feb 2013 14:52:59 -0800 (PST) Received: by 10.14.1.7 with HTTP; Wed, 27 Feb 2013 14:52:59 -0800 (PST) In-Reply-To: References: Date: Wed, 27 Feb 2013 23:52:59 +0100 Message-ID: Subject: Re: Question about Avro "records" From: Francis Galiegue To: user@avro.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org On Wed, Feb 27, 2013 at 11:21 PM, Pankaj Shroff wrote: > Yes thats right, and the default value can be "null" - which is what makes > "b" an "optional" field. > > You can define an optional field by defining it of type "union" in an Avro > schema where the first type in the union is "null" and the second type is > "long" or integer in your case. > > Something like this (.avsc or .avpr file would have the following Json): > > > { > "type": "record", > "name": "OptionalFieldsExample", > "fields": [ > {"name": "a", "type": "long"}, > {"name": "b", "type": ["null", "long"]}, > {"name": "c", "type": ["null", "long"]} > > > ] > } > Is that a reader's or a writer's schema? Sorry for the newbie questions... -- Francis Galiegue, fgaliegue@gmail.com JSON Schema in Java: http://json-schema-validator.herokuapp.com