You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/09/22 17:17:13 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #7627: fix: check for precision overflow when parsing float as decimal

alamb commented on code in PR #7627:
URL: https://github.com/apache/arrow-datafusion/pull/7627#discussion_r1334643541


##########
datafusion/sql/src/expr/value.rs:
##########
@@ -394,6 +386,23 @@ const fn try_decode_hex_char(c: u8) -> Option<u8> {
     }
 }
 
+fn parse_decimal_128_without_scale(s: &str) -> Result<i128> {
+    let number = s.parse::<i128>().map_err(|e| {
+        DataFusionError::from(ParserError(format!(
+            "Cannot parse {s} as i128 when building decimal: {e}"
+        )))
+    })?;
+
+    const MAX_DECIMAL_128_VALUE: i128 = 10_i128.pow(38) - 1;

Review Comment:
   Perhaps using https://docs.rs/arrow/latest/arrow/datatypes/constant.DECIMAL128_MAX_PRECISION.html would be clearer than `38` here



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org