ryanaston opened a new issue, #5068: URL: https://github.com/apache/arrow-rs/issues/5068
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.** There are currently two different functions in arrow-cast which convert strings to decimals. `parse_string_to_decimal_native` is used by arrow-cast when casting an entire array from a string type to a decimal type. `parse_decimal` is used by arrow-csv and arrow-json. The implementations do differ a bit. The latter accepts an additional precision argument, however when the former is used it is followed up by a call to `validate_decimal_precision` for the desired type. The former rounds values when input exceeds scale while the latter truncates. Neither function supports parsing scientific notation. **Describe the solution you'd like** 1. Consolidate into a single, consistent function 2. Support scientific notation input 3. Default to "half up" rounding 4. Stretch goal: allow for configurable rounding (maybe as a CastOption?) **Describe alternatives you've considered** N/A **Additional context** I stumbled upon this when using arrow-json reader to build a record batch. I was getting errors when my decimal values contained scientific notation and noticed `parse_decimal` doesn't support it, despite scientific notation being valid for JSON numbers. When I tried forcing expanded notation I found the excess scale was being truncated instead of rounded. I then tried building my column using a string array and casting that to a decimal type. Instead of erroring on scientific notation the value was being treated as `null`. Expanded values did work and were rounded. -- 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]
