avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Cutting (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AVRO-8) permit default values for record fields
Date Mon, 13 Apr 2009 20:32:14 GMT

    [ https://issues.apache.org/jira/browse/AVRO-8?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12698540#action_12698540
] 

Doug Cutting commented on AVRO-8:
---------------------------------

Here's a proposed syntax for default values.  Note that AVRO-9 is assumed, that map keys are
only strings.

Unions can make default values ambiguous.  An ambiguous union is here defined as one that
has:
 - one or more numeric types;
 - one or more records; or
 - a map and a record

When the type of a field is not an ambiguous union, its default value can be of the following
JSON form:
 - array  [1, 2, 3]
 - string "foo"
 - bytes "a1b2" (hex-encoded)
 - int  1
 - long 1
 - float 1.0
 - double 1.0
 - boolean true
 - null as null

Default values for ambiguous unions must be qualfied as follows:
 - record {code} { "type": "record", "name": <name>, "value": { "a":  1, "b": 2 } }
{code}
 - array {code} { "type": "array", "value": [1, 2, 3] } {code}
 - map  {code}{ "type": "map", "value":  { "a":  1, "b": 2 } } {code}
 - string  { "type": "string", "value": "foo" } 
 - bytes as  { "type": "bytes", "value":  "a1b2" }
 - int as  { "type": "int", "value":  1 } 
 - long as  { "type": "long", "value":  1 }
 - float as  { "type": "float", "value":  1.0 }
 - double as  { "type": "double", "value":  1.0 }
 - boolean as { "type": "boolean", "value" true }
 - null as  {"type": "null" }

The qualified format may always be used.  Note that arrays and maps must always be qualified
so that they may be distinguished.

Comments?


> permit default values for record fields
> ---------------------------------------
>
>                 Key: AVRO-8
>                 URL: https://issues.apache.org/jira/browse/AVRO-8
>             Project: Avro
>          Issue Type: Improvement
>          Components: spec
>            Reporter: Doug Cutting
>
> Record fields should permit the specification of default values in the schema.  When
a record is read, and the written version contains no value for a field, the default value
from the schema is used.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message