Skip to content

Commit 89d6b49

Browse files
authored
Add TimestampWithOffset canonical extension type (#8743)
# Which issue does this PR close? Implement `arrow.timestamp_with_offset` canonical extension type. # Rationale for this change Be compliant with Arrow spec: apache/arrow#48002 # What changes are included in this PR? This commit adds a new `TimestampWithOffset` extension type. This type represents a timestamp column that stores potentially different timezone offsets per value. The timestamp is stored in UTC alongside the original timezone offset in minutes. # Are these changes tested? Yes. # Are there any user-facing changes? Yes, this is a new canonical extension type.
1 parent a453c84 commit 89d6b49

File tree

2 files changed

+548
-0
lines changed

2 files changed

+548
-0
lines changed

arrow-schema/src/extension/canonical/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ mod json;
3333
pub use json::{Json, JsonMetadata};
3434
mod opaque;
3535
pub use opaque::{Opaque, OpaqueMetadata};
36+
mod timestamp_with_offset;
37+
pub use timestamp_with_offset::TimestampWithOffset;
3638
mod uuid;
3739
pub use uuid::Uuid;
3840
mod variable_shape_tensor;
@@ -77,6 +79,11 @@ pub enum CanonicalExtensionType {
7779
///
7880
/// <https://arrow.apache.org/docs/format/CanonicalExtensions.html#bit-boolean>
7981
Bool8(Bool8),
82+
83+
/// The extension type for `TimestampWithOffset`.
84+
///
85+
/// <https://arrow.apache.org/docs/format/CanonicalExtensions.html#timestamp-with-offset>
86+
TimestampWithOffset(TimestampWithOffset),
8087
}
8188

8289
impl TryFrom<&Field> for CanonicalExtensionType {
@@ -97,6 +104,9 @@ impl TryFrom<&Field> for CanonicalExtensionType {
97104
Uuid::NAME => value.try_extension_type::<Uuid>().map(Into::into),
98105
Opaque::NAME => value.try_extension_type::<Opaque>().map(Into::into),
99106
Bool8::NAME => value.try_extension_type::<Bool8>().map(Into::into),
107+
TimestampWithOffset::NAME => value
108+
.try_extension_type::<TimestampWithOffset>()
109+
.map(Into::into),
100110
_ => Err(ArrowError::InvalidArgumentError(format!(
101111
"Unsupported canonical extension type: {name}"
102112
))),
@@ -148,3 +158,9 @@ impl From<Bool8> for CanonicalExtensionType {
148158
CanonicalExtensionType::Bool8(value)
149159
}
150160
}
161+
162+
impl From<TimestampWithOffset> for CanonicalExtensionType {
163+
fn from(value: TimestampWithOffset) -> Self {
164+
CanonicalExtensionType::TimestampWithOffset(value)
165+
}
166+
}

0 commit comments

Comments
 (0)