avro icon indicating copy to clipboard operation
avro copied to clipboard

Create aliases on the `globalNames` somehow

Open rfloriano opened this issue 1 year ago • 2 comments

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

rfloriano avatar Mar 29 '23 22:03 rfloriano