You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Benyi Wang <be...@gmail.com> on 2013/06/14 21:07:16 UTC

Is it possible to parse multiple schema definitions in one string?

Is there a way to pass a string to Schema.Parser include multiple schema
definitions?

     { "type": "record",
        "name": "Date",
        "fields" : [ { "name": "date", "type": "long" }]
      }

     { "type": "record",
        "name": "Transaction",
        "fields": [
         { "name": "id", "type": "int" },
         { "name": "tx_date", "type": "Date" } ]
      }

     { "type": "record",
        "name": "Customer",
        "fields": [
         { "name": "id", "type": "int" },
         { "name": "birthday", "type": "Date" } ]
      }

Transaction and Customer refers Date.

Re: Is it possible to parse multiple schema definitions in one string?

Posted by Bertrand Dechoux <de...@gmail.com>.
You might want to look at avro idl.

Bertrand
On 14 Jun 2013 21:07, "Benyi Wang" <be...@gmail.com> wrote:

> Is there a way to pass a string to Schema.Parser include multiple schema
> definitions?
>
>      { "type": "record",
>         "name": "Date",
>         "fields" : [ { "name": "date", "type": "long" }]
>       }
>
>      { "type": "record",
>         "name": "Transaction",
>         "fields": [
>          { "name": "id", "type": "int" },
>          { "name": "tx_date", "type": "Date" } ]
>       }
>
>      { "type": "record",
>         "name": "Customer",
>         "fields": [
>          { "name": "id", "type": "int" },
>          { "name": "birthday", "type": "Date" } ]
>       }
>
> Transaction and Customer refers Date.
>

Re: Is it possible to parse multiple schema definitions in one string?

Posted by Doug Cutting <cu...@apache.org>.
You can put them in square brackets, defining a union, then use
Schema#getTypes() to return the list of schemas defined.

http://avro.apache.org/docs/current/api/java/org/apache/avro/Schema.html#getTypes()

Doug

On Fri, Jun 14, 2013 at 12:07 PM, Benyi Wang <be...@gmail.com> wrote:
> Is there a way to pass a string to Schema.Parser include multiple schema
> definitions?
>
>      { "type": "record",
>         "name": "Date",
>         "fields" : [ { "name": "date", "type": "long" }]
>       }
>
>      { "type": "record",
>         "name": "Transaction",
>         "fields": [
>          { "name": "id", "type": "int" },
>          { "name": "tx_date", "type": "Date" } ]
>       }
>
>      { "type": "record",
>         "name": "Customer",
>         "fields": [
>          { "name": "id", "type": "int" },
>          { "name": "birthday", "type": "Date" } ]
>       }
>
> Transaction and Customer refers Date.