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

Can't parse default value of 1 as a double #92

Open
larshesel opened this issue Nov 10, 2023 · 2 comments
Open

Can't parse default value of 1 as a double #92

larshesel opened this issue Nov 10, 2023 · 2 comments

Comments

@larshesel
Copy link

Passing the following into AvroEx.decode_schema!/1

{
  "type": "record",
  "name": "record0",
  "namespace": "namespace",
  "fields": [
    {
      "name": "double_test",
      "type": "double",
      "default": 1
    }
  ]
}

gives this error:

     ** (AvroEx.Schema.DecodeError) Invalid default in Field<name=double_test> Schema Mismatch: Expected value of double, got 1

Other validators, like the confluence cloud schema validator, validates this and to me it seems reasonable that an value without decimals should be parsed as a double.

With the following "fix" I was able to make AvroEx do as I wanted: https://github.com/beam-community/avro_ex/compare/master...larshesel:avro_ex:larshesel-double-integer-default?expand=1

I'm sure this is not the final solution - if you think this is an actual error I'd love to create a proper PR.

@Hanspagh
Copy link
Contributor

Hi. Thank you for the report, it seems reasonable, and I can't seem to find any documentation mentioning this. If we go down this road I guess we should do the same for the float type. Can you confirm that confluence schema validate behaves the same for floats?

@davydog187
Copy link
Member

Sorry @larshesel I never got around to responding! We should do whatever the Java implementation does. Do you have any further info?

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

3 participants