RE: add new attributes into avro schema

2015-12-17 Thread David Newberger
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:lenov...@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!



Avro Create Generic Type

2015-12-17 Thread Rushi
I am fairly certain that this is not possible currently, but thought I
should ask anyway.

In Avro, is there a way to create generic types using schema files? As an
example, this is what I am looking to create:

/**
 * Autogenerated by Avro
 *
 * DO NOT EDIT DIRECTLY
 */public class MyAvroType {
  private Object value;  // value will be of type T.}

Here, this parameterized java class would be generated by the
avro-maven-plugin or any other available plugin using the avsc files.

What I am trying to solve is, to know the type of the value that will get
stored in the avro object so that I can find out any class compatibility
issues at compile time rather than at runtime.

Thanks!


Re: Avro Create Generic Type

2015-12-17 Thread Matheus Santana
Hey, Rushi.

AFAIK, there is no support for generating generic types or inheritance
relationship between types through Avro compiler.

One thing that you can try is customize generated code by replacing
Velocity templates with your own (record.vm, for instance) and then achieve
the desired result (the generic type parameterization, in your case). Would
this fit your needs?

On Thu, Dec 17, 2015 at 3:09 PM, Rushi  wrote:

> I am fairly certain that this is not possible currently, but thought I
> should ask anyway.
>
> In Avro, is there a way to create generic types using schema files? As an
> example, this is what I am looking to create:
>
> /**
>  * Autogenerated by Avro
>  *
>  * DO NOT EDIT DIRECTLY
>  */public class MyAvroType {
>   private Object value;  // value will be of type T.}
>
> Here, this parameterized java class would be generated by the
> avro-maven-plugin or any other available plugin using the avsc files.
>
> What I am trying to solve is, to know the type of the value that will get
> stored in the avro object so that I can find out any class compatibility
> issues at compile time rather than at runtime.
>
> Thanks!
>


add new attributes into avro schema

2015-12-17 Thread John Smith
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!