serialization problem with "f32 as f64" #5863
Replies: 5 comments
-
the code show
output:
|
Beta Was this translation helpful? Give feedback.
-
12.34000015258789 is bad but maybe we have to tolerate if for now if can not get a round serder_json::Value |
Beta Was this translation helpful? Give feedback.
-
Clickhouse has settings to quoted some results.
|
Beta Was this translation helpful? Give feedback.
-
snowflake API use strings too propose we turn the HTTP handler to return JSON with a string for each field. I will start with adding a flag to select which to use.
for sqllogic test @ZeaLoVe field is turn to str in python, only need to remove some type checks here, I will do it for front end @Chasen-Zhang for HTTP handler unit test, I will use original version for now, and change to all-string a little later. |
Beta Was this translation helpful? Give feedback.
-
this happen in both seder_json::Value and our DataValue, for a standalone value they use a Float64 to hold both f32 and f64 (e.g. serde_json::to_value() do this). for f32, use "as f64" to cast.
it is ok for calc.
but cause problems to serialization, in this case: it will serialize 12.34 to 12.34000015258789
for our owner DataValue, we can solve it by skipping the DataValue and using the raw column data for serialization( serialize f32 directly).
https://github.com/datafuselabs/databend/pull/5791/files
but for seder_json, we use seder_json::Value as AST a lot, one we use it, we lost the info that it is originally f32.
since HTTP handler use nested JSON (by nested I mean a field is a json ast too ) for the result.
the diff of the two make it hard to write logistic test for both handlers.
the problem did not show up, because we use DataValue for serialization, so get the same result with serde_json
Beta Was this translation helpful? Give feedback.
All reactions