avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Schema Coersion
Date Fri, 27 Jun 2014 16:57:54 GMT
Aliases may help here.  If you have a schema in one namespace and wish
to read data written with a schema in another namespace, potentially
with different field names even, then you can add aliases to your
schema naming the other schema (and its fields, if needed).

For example, if you want to read data written with:

{"type":"record", "name":"org.foo.Frob" ...}

into a class org.bar.Fritz, then you'd generate code from a schema with:

{"type":"record", "name":"org.bar.Fritz", "alias":"org.foo.Frob" ...}

Does that make sense?  Does it apply to your situation?


On Fri, Jun 27, 2014 at 9:22 AM, Hans Uhlig <huhlig@uhlisys.com> wrote:
> Is it possible to coerce the SpecificDatumReader to read a file from a
> different Schema? We use Avro code generation for speed and type enforcement
> in our environment normally but one of the data sources out of our control.
> This other source doesn't use a namespace which means our use of codegen
> isnt possible in java. Is there a way for us to read the data into our
> codegenerated classes (only difference is the namespace) from the
> namespaceless files we receive? Without doing double class allocation?

View raw message