Fix schema_registry_decode processor #1198
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When dealing with AVRO logical types, we can't serialise the native struct emitted by goavro directly to JSON, since that will discard schema information that
codec.TextualFromNative
uses to produce the expected JSON.Also, the tip version of goavro is required because the fix for this regression linkedin/goavro#242 was merged, but there isn't a tagged release yet.
Fixes #1161.
For a bit of extra detail, when converting this JSON to binary AVRO using the schema from the test I added (see #1161 for steps on how to do that):
and then we skip the
codec.TextualFromNative
call when passing it throughschema_registry_decode
, we get the following serialised JSON from Benthos:which doesn't look like something that users will expect, but not sure. I have very limited experience with AVRO.
On the other hand, calling
codec.TextualFromNative
produces a JSON string which will then need to be unmarshalled back to a native struct if there are any subsequent processors. This is wasteful, but goavro doesn't seem to have any mechanism for crafting a native struct that is compatible with Benthos. I'm not sure right now what bloblang does under the hood if we callMessage.SetStructured()
with a native struct that contains types such astime.Time
,time.Duration
,math/big.Rat
etc. Is that supported?