You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by hiteshpahuja <hi...@gmail.com> on 2014/06/04 00:36:40 UTC
Can Nested or Child Record has same namespace as of parent record?
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.
Re: Can Nested or Child Record has same namespace as of parent record?
Posted by Doug Cutting <cu...@apache.org>.
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 <hi...@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.