avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Parsing Anonymous Schema
Date Wed, 24 Nov 2010 18:16:11 GMT
On 11/24/2010 06:53 AM, Harsh J wrote:
> Is it possible to parse an "anonymous" record schema (back into a
> proper Schema object)?
> If I've created an anonymous record schema, I'm getting an error (No
> "name" found, via Schema.parse() of Java API) when I de-serialize its
> JSON to form a Schema object again.
> Is this the intended behavior or is it a bug?

Anonymous records are not permitted, according to the specification:


This was done to simplify the specification and implementation of union 
dispatch and schema resolution.

The Java implementation will let one programatically create and operate 
on anonymous record schemas.  This is done to share implementation with 
protocol messages.  But when such records are printed the generated JSON 
is not parseable as a record schema.

Perhaps messages shouldn't be anonymous.  Perhaps they should be a 
record named with the protocol's namespace and the message name.  But 
that would prevent users from defining a record "foo" and also having a 
message named "foo" and would not be back-compatible.

In summary, some possible ways we might address this:
  - remove the ability to create anonymous records from the public API
  - add javadoc warning that anonymous records cannot be parsed
  - throw an exception when trying to print an anonymous record
  - change messages to not be anonymous (incompatible)
  - permit anonymous records in the specification (incompatible, complex)


View raw message