Skip to content

Commit

Permalink
Support Absolute Timestamps in CSV Schema Inference (#4131) (#4217)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold authored May 22, 2023
1 parent 25bfccc commit e2b9b1a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions arrow-csv/src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ lazy_static! {
r"^-?(\d+)$", //INTEGER
r"^-?((\d*\.\d+|\d+\.\d*)([eE]-?\d+)?|\d+([eE]-?\d+))$", //DECIMAL
r"^\d{4}-\d\d-\d\d$", //DATE32
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d$", //Timestamp(Second)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d.\d{1,3}$", //Timestamp(Millisecond)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d.\d{1,6}$", //Timestamp(Microsecond)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d.\d{1,9}$", //Timestamp(Nanosecond)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d(?:[^\d\.].*)?$", //Timestamp(Second)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d\.\d{1,3}(?:[^\d].*)?$", //Timestamp(Millisecond)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d\.\d{1,6}(?:[^\d].*)?$", //Timestamp(Microsecond)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d\.\d{1,9}(?:[^\d].*)?$", //Timestamp(Nanosecond)
]).unwrap();
}

Expand Down Expand Up @@ -2165,6 +2165,19 @@ mod tests {
],
DataType::Timestamp(TimeUnit::Microsecond, None),
),
(
&["2020-03-19 02:00:00+02:00", "2020-03-19 02:00:00Z"],
DataType::Timestamp(TimeUnit::Second, None),
),
(
&[
"2020-03-19",
"2020-03-19 02:00:00+02:00",
"2020-03-19 02:00:00Z",
"2020-03-19 02:00:00.12Z",
],
DataType::Timestamp(TimeUnit::Millisecond, None),
),
(
&[
"2020-03-19",
Expand Down

0 comments on commit e2b9b1a

Please sign in to comment.