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

Ryan Skraba commented on AVRO-2872:
-----------------------------------

With just a little attention, we can probably get the PR merged! But I had this 
comment in the 
[PR|https://github.com/apache/avro/pull/1097#pullrequestreview-634479856]:
{quote}To be honest, I've been stepping through the readWithoutConversion code 
and I can't find where it's important for the conversions[] array to be set! It 
seems to work as long as the logical type is registered in any case.
{quote}

Specifically, I can't seem to reproduce a serialization failure, exception, or 
unexpected result when using an optional logical type (such as the 
{{nullableTimestamp}} field in the record above.  It's easy to prove that the 
{{Conversions[]}} array isn't populated, but I can't seem to figure out what 
that _means_!

[~paulkmoore] If you've got a test case that fails, that would help clarify and 
validate the fix!

> 'conversions' array is not populated for Avro Union Logicaltype fields 
> -----------------------------------------------------------------------
>
>                 Key: AVRO-2872
>                 URL: https://issues.apache.org/jira/browse/AVRO-2872
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: logical types
>    Affects Versions: 1.9.2
>         Environment: * Apache Avro Version [1.9.2]
> * Java Version [11]
>            Reporter: Pádraig de Buitléar
>            Priority: Minor
>
> Steps to reproduce :
>  # Using the maven/gradle plugin generate code with the following avsc:
>    
> {code:java}
> {
>   "type": "record",
>   "name": "Messages",
>   "namespace": "com.somedomain",
>   "fields": [
>     {
>       "name": "start",
>       "type": {
>         "type": "long",
>         "logicalType": "timestamp-millis"
>       }
>     },
>     {
>       "name": "optional_date",
>       "type": [
>         "null",
>         {
>           "type": "long",
>           "logicalType": "timestamp-millis"
>         }
>       ],
>       "default": null
>     }
>   ]
> }{code}
>  
> *Actual behavior*
>  In the generated code, the return types of the getter methods for both 
> fields are correct, however the conversions array only has an element for the 
> field which isn't a union.
>   
> {code:java}
>   private static final org.apache.avro.Conversion<?>[] conversions =
>       new org.apache.avro.Conversion<?>[] {
>       new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
>       null,
>       null
>   };
> {code}
>  
> *Expected output:*
>  Based on the above avsc the following is expected.
>   
> {code:java}
>   private static final org.apache.avro.Conversion[] conversions =
>       new org.apache.avro.Conversion[] {
>       new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
>       new org.apache.avro.data.TimeConversions.TimestampMillisConversion(),
>       null
>   };
> {code}
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to