Skip to content

Commit

Permalink
Parse timestamp partition value to micro seconds.
Browse files Browse the repository at this point in the history
  • Loading branch information
zijie0 committed Sep 15, 2021
1 parent 081df68 commit a4f71c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
17 changes: 7 additions & 10 deletions rust/src/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,9 @@ fn typed_partition_value_from_string(
let ts =
chrono::naive::NaiveDateTime::parse_from_str(string_value, "%Y-%m-%d %H:%M:%S")
.map_err(|_| {
CheckPointWriterError::PartitionValueNotParseable(
string_value.to_owned(),
)
CheckpointError::PartitionValueNotParseable(string_value.to_owned())
})?;
// Use nanosecond precision for timestamp: https://github.com/delta-io/delta-rs/pull/194
Ok(ts.timestamp_nanos().into())
Ok((ts.timestamp_millis() * 1000).into())
}
s => unimplemented!(
"Primitive type {} is not supported for partition column values.",
Expand Down Expand Up @@ -475,11 +472,11 @@ mod tests {
}

for (s, v) in [
("2021-08-08 01:00:01", 1628384401000000000i64),
("1970-01-02 12:59:59", 133199000000000i64),
("1970-01-01 13:00:01", 46801000000000i64),
("1969-12-31 00:00:00", -86400000000000i64),
("1677-09-21 00:12:44", -9223372036000000000i64),
("2021-08-08 01:00:01", 1628384401000000i64),
("1970-01-02 12:59:59", 133199000000i64),
("1970-01-01 13:00:01", 46801000000i64),
("1969-12-31 00:00:00", -86400000000i64),
("1677-09-21 00:12:44", -9223372036000000i64),
] {
let timestamp_value: Value = v.into();
assert_eq!(
Expand Down
1 change: 1 addition & 0 deletions rust/src/delta_arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl TryFrom<&schema::SchemaDataType> for ArrowDataType {
"float" => Ok(ArrowDataType::Float32),
"double" => Ok(ArrowDataType::Float64),
"boolean" => Ok(ArrowDataType::Boolean),
// Change to binary type after https://github.com/apache/arrow-rs/pull/702 is released
"binary" => Ok(ArrowDataType::Utf8),
decimal if DECIMAL_REGEX.is_match(decimal) => {
let extract = DECIMAL_REGEX.captures(decimal).ok_or_else(|| {
Expand Down

0 comments on commit a4f71c8

Please sign in to comment.