Skip to content

Commit

Permalink
fix: expand arrow to iceberg schema to handle nanosecond timestamp (#710
Browse files Browse the repository at this point in the history
)

* fix: expand schema conversion data types for nanoseconds

* fix: use ns timestamp variants
  • Loading branch information
jdockerty authored Nov 28, 2024
1 parent aa54f22 commit 564f5a3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/iceberg/src/arrow/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,21 @@ impl ArrowSchemaVisitor for ArrowSchemaConverter {
DataType::Timestamp(unit, None) if unit == &TimeUnit::Microsecond => {
Ok(Type::Primitive(PrimitiveType::Timestamp))
}
DataType::Timestamp(unit, None) if unit == &TimeUnit::Nanosecond => {
Ok(Type::Primitive(PrimitiveType::TimestampNs))
}
DataType::Timestamp(unit, Some(zone))
if unit == &TimeUnit::Microsecond
&& (zone.as_ref() == "UTC" || zone.as_ref() == "+00:00") =>
{
Ok(Type::Primitive(PrimitiveType::Timestamptz))
}
DataType::Timestamp(unit, Some(zone))
if unit == &TimeUnit::Nanosecond
&& (zone.as_ref() == "UTC" || zone.as_ref() == "+00:00") =>
{
Ok(Type::Primitive(PrimitiveType::TimestamptzNs))
}
DataType::Binary | DataType::LargeBinary => Ok(Type::Primitive(PrimitiveType::Binary)),
DataType::FixedSizeBinary(width) => {
Ok(Type::Primitive(PrimitiveType::Fixed(*width as u64)))
Expand Down

0 comments on commit 564f5a3

Please sign in to comment.