lquerel / gcp-bigquery-client

GCP BigQuery Client (Rust)
Apache License 2.0
92 stars 60 forks source link

Properly parse big integer #5

Closed komi1230 closed 2 years ago

komi1230 commented 2 years ago

Hi ! I encountered an error in parsing big integer.

For example, 123.45E4 is integer and this should be parsed as 1234500 but this fails. Rust cannot parse 123.45E4 as integer but can parse as float.

So with this change, we at first accept data as float and then cast it as integer.

スクリーンショット 2021-08-23 15 28 21

lquerel commented 2 years ago

Hi Komi. Sorry for this late answer, i was in PTO. I don't think this PR completely corrects the problem. What happens with an integer near i64: MAX? It would be better to try parsing the number as i64 and if that fails try parsing it as f64, then convert it to i64. Thus big integers do not lose in precision.

komi1230 commented 2 years ago

Definitely! I tried to parse big integer as f64 but something goes wrong. I'll fix as you pointed out. Thanks !

スクリーンショット 2021-08-31 15 21 50