gruuya commented on code in PR #8700:
URL: https://github.com/apache/arrow-rs/pull/8700#discussion_r2703839494
##########
arrow-cast/src/parse.rs:
##########
@@ -861,19 +850,19 @@ pub fn parse_decimal<T: DecimalType>(
let mut digits: u8 = 0;
let base = T::Native::usize_as(10);
+ if matches!(s, "" | "-" | "+" | "." | "1e" | "1e+" | "1e-") {
Review Comment:
Fair point—yeah we could rely on checking whether the last character is a
digit, but we also need to disallow `"."`, while supporting these
https://github.com/apache/arrow-rs/blob/ba3446bb90cc652a45e909f1caf6a64c39a57609/arrow-cast/src/parse.rs#L2537-L2538
I've converged on this
```rust
if !bs
.last()
.is_some_and(|b| b.is_ascii_digit() || (b == &b'.' && s.len() > 1))
{
// If the last character is not a digit (or a decimal point prefixed
with some digits), then
// it's not a valid decimal.
return Err(ArrowError::ParseError(format!(
"can't parse the string value {s} to decimal"
)));
}
```
let me know how that looks.
--
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]