You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Ben Weaver <be...@orangesoda.net> on 2011/02/26 19:42:51 UTC

extra schema attributes?

Hi,

I'm making a data mapper that stores Avro documents in a database. I want to
track extra configuration details with each schema. Are application-specific
attributes allowed in Avro schema?

For example:

{
  type: "record",
  name: "User",
  fields: [
    { type: "string", name: "username" },
    { type: "string", name: "email" },
    { type: "string", name: "password", hidden: true }
  ],
  unique: ["username", "email"]
}

This hypothetical record might be used to keep track of user accounts. It
uses a nonstandard `hidden` attribute of the "password" field to indicate
the password shouldn't be exposed in certain circumstances. The `unique`
attribute of the record indicates the "username" and "email" fields are
constrained to be unique across all User records and implies the database
should index these fields.

Is it OK to add these kinds of attributes? Will Avro implementations throw
errors or ignore them if present?

Many thanks,

-Ben

Re: extra schema attributes?

Posted by Chase Bradford <ch...@gmail.com>.
Yep, they are.  We used them to mark fields needing encryption with a special encoder.

Sent from phnoe

On Feb 26, 2011, at 10:42 AM, Ben Weaver <be...@orangesoda.net> wrote:

> Hi,
> 
> I'm making a data mapper that stores Avro documents in a database. I want to track extra configuration details with each schema. Are application-specific attributes allowed in Avro schema?
> 
> For example:
> 
> {
>   type: "record",
>   name: "User",
>   fields: [
>     { type: "string", name: "username" },
>     { type: "string", name: "email" },
>     { type: "string", name: "password", hidden: true }
>   ],
>   unique: ["username", "email"]
> }
> 
> This hypothetical record might be used to keep track of user accounts. It uses a nonstandard `hidden` attribute of the "password" field to indicate the password shouldn't be exposed in certain circumstances. The `unique` attribute of the record indicates the "username" and "email" fields are constrained to be unique across all User records and implies the database should index these fields.
> 
> Is it OK to add these kinds of attributes? Will Avro implementations throw errors or ignore them if present?
> 
> Many thanks,
> 
> -Ben