[ 
https://issues.apache.org/jira/browse/AVRO-2115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16288851#comment-16288851
 ] 

Miguel edited comment on AVRO-2115 at 12/13/17 8:35 AM:
--------------------------------------------------------

That is not allowed. Checking 
[https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/reflect/Union.java]:

{code:java}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.PARAMETER, ElementType.METHOD})
@Documented
public @interface Union {
  /** The instantiable classes that compose this union. */
  Class[] value();
}
{code}

I tried (without using Void.class). 

I omitted the FieldUnion annotation where it is needed to add the 
ElementType.FIELD target: 

{code:java}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@Documented
public @interface FieldUnion {
  /** The instantiable classes that compose this union. */
  Class[] value();
}
{code}




was (Author: elmendavies):
That is not allowed. Checking 
[https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/reflect/Union.java]:

{code:java}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.PARAMETER, ElementType.METHOD})
@Documented
public @interface Union {
  /** The instantiable classes that compose this union. */
  Class[] value();
}
{code}

I tried (without using Void.class). 

> Support @Union in members too
> -----------------------------
>
>                 Key: AVRO-2115
>                 URL: https://issues.apache.org/jira/browse/AVRO-2115
>             Project: Avro
>          Issue Type: Improvement
>            Reporter: Miguel
>            Priority: Minor
>
> Allow defining unions in members:
> {code:java}
> class MyDatum {
>    @Nullable
>    @Union({String.class, Long.class, Other.class,...})
>    Object o;
> }
> {code}
> It can currently be implemented using @AvroSchema like this, but it is seems 
> in my oppinion more verbose and more difficult to maintain:
> {code:java}
> @AvroSchema("[\"null\",\"string\",...")
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to