Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create aliases on the globalNames somehow #120

Open
rfloriano opened this issue Mar 29, 2023 · 2 comments
Open

Create aliases on the globalNames somehow #120

rfloriano opened this issue Mar 29, 2023 · 2 comments

Comments

@rfloriano
Copy link

Hey,

I'm using the confluent-kafka-go, during the deserialization-generic flow they call avro.Unmarshal, which by consequence it will use the globalNames.Unmarshal.
In my case, I'm experiencing an error of Incompatible types from gogen-avro, I have a struct with the Avro schema defined just on the schema registry, outer from my project. So the writer and reader schemas don't match, because the field names are interpreted differently.

After doing some hacks locally in order to test, I found globalNames.Rename("<struct_field>", "<schema_registry_field>", "<struct_field>") and it solves the issue. But I didn't find a way to hook globalNames variable or some way to replace them globally (as zap log does for instance).

Which is the right way to use the aliases by Rename method?
Does makes sense for you to propose a way to use Rename method on the globalNames? If does, would you accept a PR making this kind of change?

Tks

@skateinmars
Copy link
Member

Hi @rfloriano and thanks for your feedback.

I'm not quite sure we would like to expose the globalNames since it means manipulating global state.
One solution I believe may help is aliases on the avro schema itself https://avro.apache.org/docs/1.8.1/spec.html#Aliases
It does require to have control over the reader schema though.

Given this, one solution may be to expose a Rename function that would itself call globalNames
Thoughts @sixstone-qq @rogpeppe ?

@rfloriano
Copy link
Author

rfloriano commented Apr 3, 2023

hey @skateinmars,

I understand. However, for this particular case I'm talking about, the gogen-avro will generate the Avro schema in runtime and try to match, that's why I need to use the Rename function.

I said about the possibility to expose globalNames or replace it, as zap lib does could solve.
But of course, expose or not the globalNames is your call, exposing Rename function solves this case and probably is simplest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants