You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I figured it out, the library tried to validate default value "23" against the first type in the type array. However the first type is null, so it says that "23" is not a valid null. Which is correct.
Expected behaviour
The library tries to validate the default value against all the types listed in the type array. And spits the exception only when no passing type is found.
Work around
So far I've found the following workound. If I change the order of elements in the type array and put on the first place a type that represents the default value it works.
So changing this
"type": ["null", "string"],
To this
"type": ["string", "null"],
Allows to avoid the error.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi @greyblake, thanks for the detailed report! This is actually WAI; from the Avro specification (emphasis mine):
default: A default value for this field, used when reading instances that lack this field (optional). Permitted values depend on the field's schema type, according to the table below. Default values for union fields correspond to the first schema in the union. Default values for bytes and fixed fields are JSON strings, where Unicode code points 0-255 are mapped to unsigned 8-bit byte values 0-255.
So your workaround is actually what the specification says you should do...
Hi!
Thanks for the cool library!
I got some problems initializing a schema with fields that may have multiple types. Here is a minimal example to reproduce:
Exception:
As I figured it out, the library tried to validate default value
"23"
against the first type in the type array. However the first type is null, so it says that"23"
is not a valid null. Which is correct.Expected behaviour
The library tries to validate the default value against all the types listed in the
type
array. And spits the exception only when no passing type is found.Work around
So far I've found the following workound. If I change the order of elements in the
type
array and put on the first place a type that represents the default value it works.So changing this
To this
Allows to avoid the error.
Thanks!
The text was updated successfully, but these errors were encountered: