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

Christophe Le Saec commented on AVRO-3649:
------------------------------------------

I wonder if it could not be better to make union type agnostic of its inner 
type order. Strictly speaking int|string is same as string|int (and null|int == 
int|null).

In order to do that, i build [this PR|https://github.com/apache/avro/pull/1922] 
just to show how it could be done and make discussion easier ({_}if this lead 
is good, i should clean some part of code, with Schema.isValidDefault (or 
isValidValue) and also add specific unit test on it{_})

 

> [JAVA] reorder union types to match default value
> -------------------------------------------------
>
>                 Key: AVRO-3649
>                 URL: https://issues.apache.org/jira/browse/AVRO-3649
>             Project: Apache Avro
>          Issue Type: Improvement
>            Reporter: Daniel Heinrich
>            Priority: Trivial
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> The Avro specification requires that a default value matches the first schema 
> of a union type.
>  
> Using @Nullable on a field will return a union type of the form ["null", 
> "<something>"].
> @Nullable also sets the default value to "null".
>  
> It is not possible to override this default value with 
> {color:#bbb529}{color:#172b4d}@AvroDefault because of the order of the 
> schemas in the generated union.{color}
> {color}
>  
> It would be nice that union types are automatically reordered to match the 
> type of the provided default value.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to