liukun4515 commented on a change in pull request #941:
URL: https://github.com/apache/arrow-rs/pull/941#discussion_r750316078
##########
File path: arrow/src/csv/reader.rs
##########
@@ -769,20 +773,93 @@ fn build_decimal_array(
Ok(Arc::new(decimal_builder.finish()))
}
-// parse the string format decimal value to i128 format.
-// like "125.12" to 12512_i128.
+// Parse the string format decimal value to i128 format and checking the
precision and scale.
+// The result i128 value can't be out of bounds.
+fn parse_decimal_with_parameter(s: &str, precision: usize, scale: usize) ->
Result<i128> {
+ if PARSE_DECIMAL_RE.is_match(s) {
+ let mut offset = s.len();
+ let len = s.len();
+ // each byte is digit、'-' or '.'
+ let mut base = 1;
+
+ // handle the value after the '.' and meet the scale
+ let delimiter_position = s.find('.');
Review comment:
I think this value `123.123.13` will get an error, because of the regex
`static ref PARSE_DECIMAL_RE: Regex =
Regex::new(r"^-?(\d+\.?\d*|\d*\.?\d+)$").unwrap();`.
I will add more test case and change the code style in the next pull request.
--
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]