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
Currently we found that in the avro-schema reference there is support for multiple complex union types, however using avsc we found that schemas such as this:
constemployee={name: 'Alice',role: {programmingLanguage: 'Typescript',},};// Throws an exception!constbuffered=employeeSchema.toBuffer(dummyValue);
We get this error message: invalid [{"name":"Manager","type":"record","fields":[{"name":"managees","type":{"type":"array","items":"string"}}]},{"name":"Developer","type":"record","fields":[{"name":"programmingLanguage","type":"string"}]}]: {"programmingLanguage":"Typescript"}
We'd like to know if this is a problem with our interpretation of the documentation of the avro-schema or if there's any workaround that we can do to support union complex types.
The text was updated successfully, but these errors were encountered:
Hi @sj-freitas. The issue you're bumping into is that unions with multiple records need to be wrapped to ensure that they don't lose branch information. For your example, you'll need to tweak the data as follows:
constemployee={name: 'Alice',role: {Developer: {// Note this extra key, matching the branch's record's name.programmingLanguage: 'TypeScript',},},};
Take a look at this comment for more context as well as a couple examples.
Hello, first of all, thanks for the library!
Currently we found that in the avro-schema reference there is support for multiple complex union types, however using
avsc
we found that schemas such as this:When we do the following:
We get this error message:
invalid [{"name":"Manager","type":"record","fields":[{"name":"managees","type":{"type":"array","items":"string"}}]},{"name":"Developer","type":"record","fields":[{"name":"programmingLanguage","type":"string"}]}]: {"programmingLanguage":"Typescript"}
We'd like to know if this is a problem with our interpretation of the documentation of the avro-schema or if there's any workaround that we can do to support union complex types.
The text was updated successfully, but these errors were encountered: