jonahgao commented on code in PR #7627:
URL: https://github.com/apache/arrow-datafusion/pull/7627#discussion_r1335048520
##########
datafusion/sql/src/expr/value.rs:
##########
@@ -66,23 +67,19 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
let p = str.len() - 1;
let s = str.len() - i - 1;
let str = str.replace('.', "");
- let n = str.parse::<i128>().map_err(|_| {
- DataFusionError::from(ParserError(format!(
- "Cannot parse {str} as i128 when building decimal"
- )))
- })?;
+ let n = parse_decimal_128_without_scale(&str)?;
Ok(Expr::Literal(ScalarValue::Decimal128(
Some(n),
p as u8,
s as i8,
)))
} else {
- let number = n.parse::<i128>().map_err(|_| {
- DataFusionError::from(ParserError(format!(
- "Cannot parse {n} as i128 when building decimal"
- )))
- })?;
- Ok(Expr::Literal(ScalarValue::Decimal128(Some(number), 38, 0)))
+ let number = parse_decimal_128_without_scale(str)?;
+ Ok(Expr::Literal(ScalarValue::Decimal128(
+ Some(number),
+ str.len() as u8,
Review Comment:
Try to use the minimum precision instead of the maximum precision.
--
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]