Skip to content

Commit

Permalink
remove lexical in timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Sep 8, 2023
1 parent 4006115 commit 1144add
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions arrow-json/src/reader/timestamp_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,21 @@ where
TapeElement::Number(idx) => {
let s = tape.get_string(idx);
let b = s.as_bytes();
let value = lexical_core::parse::<i64>(b)
.or_else(|_| lexical_core::parse::<f64>(b).map(|x| x as i64))
.map_err(|_| {
ArrowError::JsonError(format!(
"failed to parse {s} as {}",
self.data_type
))
})?;
let value = match std::str::from_utf8(b) {
Ok(s) => s
.parse::<i64>()
.or_else(|_| s.parse::<f64>().map(|x| x as i64))
.map_err(|_| {
ArrowError::JsonError(format!(
"failed to parse {s} as {}",
self.data_type
))
}),
Err(_) => Err(ArrowError::JsonError(format!(
"failed to parse {s} as {}",
self.data_type
))),
}?;

builder.append_value(value)
}
Expand Down

0 comments on commit 1144add

Please sign in to comment.