You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by John Smith <le...@gmail.com> on 2015/12/17 12:13:25 UTC

add new attributes into avro schema

Hi,

is it possible to extend avro schema with custom attributes, for example

{
 "type":"record",
  "name":"X",
   "fields":[
          {"name":"b3","type":"int","doc":"blabla",*"newField1"*:"test",
*"newField2"*:"test2"}
]}');



Thank you!

RE: add new attributes into avro schema

Posted by David Newberger <da...@wandcorp.com>.
Hi,

I’m fairly new to working with avro so I could be wrong however this:

https://avro.apache.org/docs/1.7.7/api/java/org/apache/avro/SchemaBuilder.html

“Primitive Types
All Avro primitive types are trivial to configure. A primitive type in Avro JSON can be declared two ways, one that supports custom properties and one that does not:
{"type":"int"}
{"type":{"name":"int"}}
{"type":{"name":"int", "customProp":"val"}}
The analogous code form for the above three JSON lines are the below three lines:
  .intType()
  .intBuilder().endInt()
  .intBuilder().prop("customProp", "val").endInt()
Every primitive type has a shortcut to create the trivial type, and a builder when custom properties are required. The first line above is a shortcut for the second, analogous to the JSON case.”

makes it look like you can.

David Newberger

From: John Smith [mailto:lenovomi@gmail.com]
Sent: Thursday, December 17, 2015 5:13 AM
To: user@avro.apache.org
Subject: add new attributes into avro schema

Hi,
is it possible to extend avro schema with custom attributes, for example

{
 "type":"record",
  "name":"X",
   "fields":[
          {"name":"b3","type":"int","doc":"blabla","newField1":"test", "newField2":"test2"}
]}');


Thank you!