avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: How to add optional new record fields and/or new methods in avro-ipc?
Date Tue, 18 Oct 2011 21:36:07 GMT
On 10/18/2011 11:40 AM, Scott Carey wrote:
> I'm not sure that I understand "The default value for a union is the
> default value for its first branch."
> Defaults don't apply to any types in a union, only to fields on a record.
> So the Schema ["Foo", "Bar"] can have no default, nor can any of its
> branches.

>From the spec's definition of default values:

"Permitted values depend on the field's schema type, according to the
table below. Default values for union fields correspond to the first
schema in the union."

So the default value for a field with a union type as its value is
assumed to be of the type of the first element of that union.  If the
first element of that union is "null", then the type of the default
value must be "null" hence the default value itself can only be "null".
 So the question is whether we require that to be stated explicitly in
the schema.  I assumed that we did not.  Either way, we should clarify
the spec around this.

We could continue to insist that, if no default value is explicitly
specified in the reader's schema, and the writer's schema lacks a field,
then an error is thrown.  Or we could say that the default value for
default values is null, so that if the reader adds a field that's a
union with "null" as its first branch then no default value need be present.

Doug

Mime
View raw message