Lstarsky0 commented on issue #10791: URL: https://github.com/apache/arrow-rs/issues/10791#issuecomment-5383985782
`scale` is used in exactly three places in `parse_decimal`, and all three assume it's `>= 0`: - `:981` `if fractionals == scale` — the stop condition for consuming fractional digits. Never true for a negative scale, so the whole fraction gets consumed. - `:1021` `if fractionals < scale` — the only rescaling step. Also never true. - `:1024`, the multiply inside it. `result` is only ever multiplied in this function; there is no division anywhere. A negative scale needs `result / 10^-scale` and there's no code path for it, so what comes back is the mantissa digits with the decimal point deleted: ``` "1234.5", scale -2 -> 12345 "150", scale -2 -> 150 "1200", scale -2 -> 1200 "0.05", scale -2 -> 5 ``` This only reaches callers who use `parse_decimal` directly — `cast_string_to_decimal` refuses negative scale up front at `cast/decimal.rs:798`, which is the other side of #10792. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
