-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Original schema not guaranteed to match generated schema from models #544
Comments
I have prepared a local branch with a solution in place. Leveraging the ModelGenerator.metadata_field_templates attribute. I don't have the permissions to create remote branch here though. Would like to be able to create a PR and get your thoughts on the implementation. |
HI @bengels97 Interesting case. Please send the PR and we can take a look. You can fork the repository and then send a PR from your fork |
Appreciate the quick response @marcosschroh. You can find the PR here: #545 |
Mitigated by #545 but still we need a solution for fields with |
@bengels97 After merging #544 this issue will be fixed. Hopefully you won't need anymore to have the original schema in your model. |
Is your feature request related to a problem? Please describe.
Kafka ValueDeserializationError thrown when deserialising message using the generated schema from AvroModel.avro_schema(), due to a mismatch in between the original schema, retrieved from our schema registry, and the generated schema.
In short, the flow: original_schema -> generated_object -> generated_schema, will not always work, as compatibility between original_schema and generated_schema is not guaranteed.
See pictures in additional context.
Describe the solution you'd like
The easiest work-around would be to include the original schema inside the generated object. Should be relatively easy to implement, the schema is already passed to the ModelGenerator.render() method. This would prevent any mismatch to happen, as you are able to refer to the original schema in the resulting models.
A more generic approach: Make it possible to pass extra meta information to the ModelGenerator.render() method.
Describe alternatives you've considered
Additional context
![image](https://private-user-images.githubusercontent.com/64258145/304399930-3bb2dcb9-8b53-4d84-9745-129917201d39.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwOTE4NDQsIm5iZiI6MTcyMDA5MTU0NCwicGF0aCI6Ii82NDI1ODE0NS8zMDQzOTk5MzAtM2JiMmRjYjktOGI1My00ZDg0LTk3NDUtMTI5OTE3MjAxZDM5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA0VDExMTIyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZhM2I1ZTQ1MDA4MWRkMDNkYTU3MjViOWM4MWNjYmZmNjI5MTJlYTE4YjE0M2YxZTQyNDE0MzRlMzI0ZjI5NWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.6U_qeuVsfrS4arFqgnQbdvbkjYBf7b040xIQVD4sn7c)
The thrown error:
Cause of the error:
Original schema:
"fields": [{"name": "accumulation", "type": {"type": "enum", "name": "Accumulation_analog", "symbols": [ "Average", "Maximum", "Minimum", "Summation", "None"]}}]
Generated schema from model:
"fields": [{"name": "accumulation", "type": {"type": "enum", "name": "AccumulationAnalog", "symbols": ["Average", "Maximum", "Minimum", "Summation", "None"]}}]
The text was updated successfully, but these errors were encountered: