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

Schemas with namespaces break on reuse #61

Open
anthonymckale-6point6 opened this issue Apr 25, 2023 · 0 comments
Open

Schemas with namespaces break on reuse #61

anthonymckale-6point6 opened this issue Apr 25, 2023 · 0 comments

Comments

@anthonymckale-6point6
Copy link

anthonymckale-6point6 commented Apr 25, 2023

When java avro-tools convert .avdl files into .avsc files

the files are created with namespaces which aren't supported by pydantic-avro

https://avro.apache.org/docs/1.10.2/spec.html

this breaks classes when they are reused, as the key doesn't match

aka "<some_namespace>.Class" is stored in classes as "Class" instead of "<some_namespace>.Class"

written a small change when looking up a reused class will look at the Class portion of namespaced types

example

{
            "name": "Test",
            "type": "record",
            "fields": [
                {
                    "name": "col1",
                    "type": {
                        "type": "record",
                        "name": "Nested",
                        "namespace": "com.pydantic",
                        "fields": [{"name": "col1", "type": "string"}]},
                },
                {
                    "name": "col2",
                    "type": "com.pydantic.Nested",
                },
            ],
        }

Note existing edge case where there is a clash with namespaces but that already exists for non reused case

anthonymckale-6point6 added a commit to anthonymckale-6point6/pydantic-avro that referenced this issue Apr 25, 2023
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

1 participant