You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Josh Buffum <jb...@gmail.com> on 2014/06/28 02:01:33 UTC

aliasing items in the default namespace

I've searched quite a bit and haven't found an answer to this question.

Is there a way for me to create a new record (with a namespace) using an
old record name (with no namespace) as an alias?

{ "name" : "record1", type="record"... }

{ "namespace" : "some.namespace",
  "name" : "record2",
  "type": "record",
  "aliases: ["record1"]
...
}

The goal is to read .avro files written with the "record1" schema as
objects of type some.namespace.record2.

According to the documentation, the alias of "record1" will automatically
inherit the namespace of "record2" so the alias is really
"some.namespace.record1". How do I make it just "record1" and still have
the second record in a namespace ("some.namespace.record2")?

Thanks.

Josh

Re: aliasing items in the default namespace

Posted by Josh Buffum <jb...@gmail.com>.
This patch works great for me. 



> On Jun 30, 2014, at 3:20 PM, Doug Cutting <cu...@apache.org> wrote:
> 
>> On Fri, Jun 27, 2014 at 5:01 PM, Josh Buffum <jb...@gmail.com> wrote:
>> Is there a way for me to create a new record (with a namespace) using an old
>> record name (with no namespace) as an alias?
> 
> No, but this is easily remedied.
> 
> I filed the following issue & attached a fix:
> 
> https://issues.apache.org/jira/browse/AVRO-1535
> 
> Please let me know if this works for you.
> 
> Cheers,
> 
> Doug

Re: aliasing items in the default namespace

Posted by Doug Cutting <cu...@apache.org>.
On Fri, Jun 27, 2014 at 5:01 PM, Josh Buffum <jb...@gmail.com> wrote:
> Is there a way for me to create a new record (with a namespace) using an old
> record name (with no namespace) as an alias?

No, but this is easily remedied.

I filed the following issue & attached a fix:

https://issues.apache.org/jira/browse/AVRO-1535

Please let me know if this works for you.

Cheers,

Doug

Re: aliasing items in the default namespace

Posted by Eric Wasserman <ew...@247-inc.com>.
Hi Josh,

Sounds like you hit an edge case. From the Avro spec:

A type alias may be specified either as a fully namespace-qualified, or relative to the namespace of the name it is an alias for. For example, if a type named "a.b" has aliases of "c" and "x.y", then the fully qualified names of its aliases are "a.c" and "x.y".

Unless you've got a . in the alias name it looks like Avro is going to assume the relative case.


On Jun 27, 2014, at 5:02 PM, "Josh Buffum" <jb...@gmail.com>> wrote:

I've searched quite a bit and haven't found an answer to this question.

Is there a way for me to create a new record (with a namespace) using an old record name (with no namespace) as an alias?

{ "name" : "record1", type="record"... }

{ "namespace" : "some.namespace",
  "name" : "record2",
  "type": "record",
  "aliases: ["record1"]
...
}

The goal is to read .avro files written with the "record1" schema as objects of type some.namespace.record2.

According to the documentation, the alias of "record1" will automatically inherit the namespace of "record2" so the alias is really "some.namespace.record1". How do I make it just "record1" and still have the second record in a namespace ("some.namespace.record2")?

Thanks.

Josh