mtth / avsc

Avro for JavaScript :zap:
MIT License
1.27k stars 147 forks source link

float value is inaccurate after serializing and deserializing using avro schema #430

Closed JyothsnaGoalla closed 1 year ago

JyothsnaGoalla commented 1 year ago

Hello,

I have a avro schema which has some float values and i am using java code to send events and receiving using python consumer. For some reason float value serialization and deserialization is not working. Avro schema:- { "type": "record", "name": "Marks", "namespace": "com.Marks.sample", "fields": [ { "name": "Name", "type": { "type": "string", "avro.java.string": "String" } }, { "name": "Marks", "type": [ "null", { "type": "record", "name": "Marks", "fields": [ { "name": "Maths", "type": "float" } ] } ], "default": null } ] }

Sample Data:- {"Name": "Avro", "Marks": { "Maths": 20.0}}

Expected: {"Name": "Avro", "Marks": { "Maths": 20.0}} Actual:{"Name": "Avro", "Marks": { "Maths": -1.8671875}}

please help me resolve this issue.

mtth commented 1 year ago

Hi @JyothsnaGoalla. It's hard to say without more context. You only mention Java and Python, how are you using avsc?