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

default values of null are removed from schema in encode_schema #77

Open
otosky opened this issue Jun 23, 2022 · 2 comments
Open

default values of null are removed from schema in encode_schema #77

otosky opened this issue Jun 23, 2022 · 2 comments
Labels

Comments

@otosky
Copy link

otosky commented Jun 23, 2022

Heyo 👋

Ran into an edge case today where a schema defined in JSON containing nullable unions would have the "default": null portion stripped out if it was run through a sequence of AvroEx.decode_schema -> AvroEx.encode_schema.

Example:

schema = AvroEx.decode_schema!(~S({
  "type": "record", 
  "name": "Record", 
  "fields": [
     {"type": ["null", "int"], "name": "nullable", "default": null}
   ]
}))
AvroEx.encode_schema(schema)

Output:

"{\"fields\":[{\"name\":\"nullable\",\"type\":[{\"type\":\"null\"},{\"type\":\"int\"}]}],\"name\":\"Record\",\"type\":\"record\"}"

I haven't dug too deep, but other primitives seem okay:

schema = AvroEx.decode_schema!(~S({
  "type": "record", 
  "name": "Record", 
  "fields": [
     {"type": ["null", "int"], "name": "nullable", "default": 5}
   ]
}))
AvroEx.encode_schema(schema)
"{\"fields\":[{\"default\":5,\"name\":\"nullable\",\"type\":[{\"type\":\"null\"},{\"type\":\"int\"}]}],\"name\":\"Record\",\"type\":\"record\"}"

Using v2.0.1

@davydog187
Copy link
Member

Thanks for the report @otosky :)

@davydog187 davydog187 added the bug label Jun 23, 2022
@davydog187
Copy link
Member

@marpo60 told me he is working on a fix

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

No branches or pull requests

2 participants