avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Can Nested or Child Record has same namespace as of parent record?
Date Fri, 06 Jun 2014 21:21:09 GMT
If a nested schema specifies no namespace then the namespace of its
parent is used.  A nested schema's namespace is not printed unless it
differs from its parent's.  If you extract only the nested
"productRecord" schema and print it un-nested then the namespace will
be shown.  E.g.,

transactionSchema.getField("productRecord").schema().toString()

Doug

On Tue, Jun 3, 2014 at 3:36 PM, hiteshpahuja <hitesh.pahuja@gmail.com> wrote:
> I have this schema fragment where child record elements have same namespace
> as of parent record. When I do schema.toString(), output string don't honor
> child record namespace and discard this. In output I only have parent record
> namespace only.
>
>
> {
>     "namespace": "com.vendavo.dataModel",
>     "name": "Transaction",
>     "type": "record",
>     "doc" : "Transaction for customer",
>     "fields":
>     [
>         {
>             "name": "id",
>             "type": "string",
>             "doc": "Unique Id for Transaction.",
>             "label": "Transaction GUID",
>             "fieldType": "calculatedField",
>             "sqlType": "varchar",
>             "category": "UUID"
>         },
>         {
>             "name": "productRecord",
>             "type":
>             {
>                 "namespace": "com.vendavo.dataModel",
>                 "type": "record",
>                 "name": "ProductDetails",
>                 "fields":
>                 [
>                     {
>                          "name": "id",
>                          "type": "string",
>                          "doc": "Unique Id for Product.",
>                          "category": "UUID",
>                          "fieldType": "calculatedField",
>                          "sqlType": "varchar"
>                     }
>                 ]
>             }
>         },
>         {
>             "name": "customer",
>             "type":
>             {
>                 "namespace": "com.vendavo.dataModel",
>                 "type": "record",
>                 "name": "Customer",
>                 "doc": "Customer specific data",
>                 "fields":
>                 [
>                     {
>                         "name": "id",
>                         "type": "string",
>                         "doc": "Unique Id for Customer.",
>                         "category": "UUID",
>                         "fieldType": "calculatedField",
>                         "sqlType": "varchar"
>                     }
>                 ]
>             }
>         }
>     ]
> }
>
>
> Couple of questions
>
> 1.Can't child or nested record have same namespace as of parent?
> 2. How schema parser handles namespace details?
>
>
>
>
>
> --
> View this message in context: http://apache-avro.679487.n3.nabble.com/Can-Nested-or-Child-Record-has-same-namespace-as-of-parent-record-tp4030139.html
> Sent from the Avro - Developers mailing list archive at Nabble.com.

Mime
View raw message