lw-mcno opened a new pull request, #3660:
URL: https://github.com/apache/avro/pull/3660

   The assumption in JacksonUtils#toObject(JsonNode, Schema), that the actual 
data schema in a UNION schema (of some data with NULL), always comes first, is 
incorrect.
   
   For example, a field with this schema will have its default value converted 
incorrectly:
   
   ```
   {
     "name": "exampleDateTime",
     "type": ["null", { "type": "long", "logicalType": "local-timestamp-millis" 
}],
     "default": 1746088255000
   }
   ```
   
   Here the "null" schema explicitly comes first and the assumption is no 
longer correct (JacksonUtils tries to interpret the value 1746088255000 using 
the NULL schema).
   
   Another example using Avro IDL (nullable field, containing an array of 
nullable items):
   
   ```
   record SomeRecord {
     union{array<int?>, null} optArrayOptItemVal = [4];
   }
   ```
   
   In this case, the "optArrayOptItemVal" field fulfills the assumption, but 
the array item's schema does not. On my machine, with Avro 1.12.1, the item's 
schema is the following:
   
   ```
   "type": ["null", { "type": "int" }]
   ```
   
   which also fails the non-NULL schema first assumption.
   
   All of the above examples are successfully parsed or converted through the 
Avro IDL library to a Schema object.
   
   ## What is the purpose of the change
   
   Fix the retrieval of schema fields' default values (JacksonUtils) when the 
schema(s) consist of UNIONs with NULLs (as first type in the UNION).
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - Added test statements in TestJacksonUtils.java, which check the behavior 
with UNION schemas, that contain NULL schema as its first type.
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to