Avro arrays: null
vs []
#44
Replies: 5 comments
-
I think the first step would be to check if this is not already functioning as desired. I expect Lancaster to handle this automatically for us, but of course it might be that we're not calling the library in the right way for that edge case. So again: needs to be checked! |
Beta Was this translation helpful? Give feedback.
-
We need to test if this is correct: will an empty array validate against the schema? |
Beta Was this translation helpful? Give feedback.
-
It's also important to consider what the consequences of our choices are here: an optional array is different from a required array that is empty. Discuss this with Sjoerd. |
Beta Was this translation helpful? Give feedback.
-
I've given this some thought. Open world vs closed world Bad idea: custom Consequences Note: because of the possibility of an empty array, there is no way to express a cardinality range of 1-many. This is by design of Avro, but it should be better reflected in the transformation specification on the wiki and the code (particulary the cardinality mapping). So, if semantically there is no difference in this context, what does it matter what way we map array cardinality? There could be consequences for the user of the schema. For instance, if a field has a nullable array type, this allows leaving out the field altogether, where an array type would require the presence of the field at all times. This influences validation. Way forward
Note: I have made some assumptions about how Avro works here, particulary regarding "leaving out fields of cardinality zero" and perhaps also how it validates "empty arrays versus absent values" (as Joep pointed out). |
Beta Was this translation helpful? Give feedback.
-
We can also consider implementing a option one can pass to the application to specify if we want to enforce optionality (for the purpose of schema evolution) if that's desired. |
Beta Was this translation helpful? Give feedback.
-
Avro supports empty arrays, so this should be reflected in the transformation logic
Beta Was this translation helpful? Give feedback.
All reactions