avro icon indicating copy to clipboard operation
avro copied to clipboard

Fix Union Generation for map[string]interface{} in Avro Schemas

Open gskchaitanya opened this issue 7 months ago • 0 comments

The current implementation of the avrogo code generator incorrectly omits union information for fields defined as map[string]interface{} in Avro schemas. This occurs specifically in cases where the union type is ["null", map[string]T]. The omission of this union information leads to incorrect code generation, not reflecting the intended schema's flexibility and complexity.

Example of Issue: A field defined as mapTest *map[string]interface{} 'json:"mapTest"' in the Avro schema incorrectly omits the necessary union type information in the generated Go code.

Solution: This pull request introduces a fix in the union type generation logic within the writeUnionInfo function. It specifically addresses the handling of map[string]interface{} fields to ensure the proper inclusion of union type information.

The fix involves updating the logic to recognize and correctly handle the ["null", map[string]T] union case, ensuring that it's not omitted during code generation. This change allows the generated Go code to accurately represent the Avro schema's structure and the intended flexibility of the map[string]interface{} field.

gskchaitanya avatar Dec 05 '23 02:12 gskchaitanya