[ 
https://issues.apache.org/jira/browse/AVRO-1274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tom White updated AVRO-1274:
----------------------------

    Attachment: AVRO-1274.patch


New patch with more tests for all the required/optional methods.

I have a couple of questions too.

Default values for bytes are encoded as {{"bytes" : "A"}}, e.g.:

{noformat}
{
    "name" : "optionalBytesWithDefault",
    "type" : [ "null", "bytes" ],
    "default" : {
      "bytes" : "A"
    }
  }
{noformat}

I couldn't find where this is covered in the spec, since the section on default 
values says "Default values for bytes and fixed fields are JSON strings, where 
Unicode code points 0-255 are mapped to unsigned 8-bit byte values 0-255." and 
doesn't mention the "bytes" part 
(http://avro.apache.org/docs/current/spec.html#schema_record). If this is 
correct, should the fixed default value have "bytes" too?

I'm also confused about how default values work at read time. If I write a 
record with a default optional field without specifying the field value, then 
read it back the value is always null, even though the default is not null. 
E.g. for 

{noformat}
{
  "type" : "record",
  "name" : "r",
  "fields" : [ {
    "name" : "a",
    "type" : [ "string", "null" ],
    "default" : "cat"
  } ]
}
{noformat}

the value read back is {"a":null} not {"a":"cat"} 

What am I missing?
                
> Add a schema builder API
> ------------------------
>
>                 Key: AVRO-1274
>                 URL: https://issues.apache.org/jira/browse/AVRO-1274
>             Project: Avro
>          Issue Type: New Feature
>          Components: java
>            Reporter: Tom White
>            Assignee: Tom White
>         Attachments: AVRO-1274.patch, AVRO-1274.patch, AVRO-1274.patch
>
>
> It would be nice to have a fluent API that made it easier to construct record 
> schemas.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to