You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Arvind Kalyan <ba...@gmail.com> on 2014/06/28 02:53:20 UTC

Partial deserialization with schemas of different names

Hey folks,

How do we handle cases where the reader and writer record schemas have
different record names but their fields are in a is-a relationship with
slight differences in their fields.

For example:

{
    "type": "record",
    "name": "RecordA",
    "fields": [
        {"name": "a", "type": "string"},
        {"name": "b", "type": ["null", "long"]},
        {"name": "c", "type": {"type": "array", "items": "string"}}
    ]
}

{
    "type": "record",
    "name": "RecordB",
    "fields": [
        {"name": "a", "type": "string"}
    ]
}

In the above case, what's the best way to use RecordB for reading what was
written using RecordA?

-- 
Arvind Kalyan
http://www.linkedin.com/in/base16
cell: (408) 761-2030

Re: Partial deserialization with schemas of different names

Posted by Eric Wasserman <ew...@247-inc.com>.
I believe you can just add an alias in the second schema such RecordB is also known as RecordA and the second schema will then work as a reader's schema for  records written in the former (RecordA) schema.

Of course your parser must be provided with *both* schemas the one for RecordA as the writer's schema and the one for RecordB as the reader's schema.

On Jun 27, 2014, at 5:53 PM, "Arvind Kalyan" <ba...@gmail.com>> wrote:

Hey folks,

How do we handle cases where the reader and writer record schemas have different record names but their fields are in a is-a relationship with slight differences in their fields.

For example:

{
    "type": "record",
    "name": "RecordA",
    "fields": [
        {"name": "a", "type": "string"},
        {"name": "b", "type": ["null", "long"]},
        {"name": "c", "type": {"type": "array", "items": "string"}}
    ]
}

{
    "type": "record",
    "name": "RecordB",
    "fields": [
        {"name": "a", "type": "string"}
    ]
}

In the above case, what's the best way to use RecordB for reading what was written using RecordA?

--
Arvind Kalyan
http://www.linkedin.com/in/base16
cell: (408) 761-2030