diff --git a/vortex-array/public-api.lock b/vortex-array/public-api.lock index 7d122a6f98c..85e3e658c6f 100644 --- a/vortex-array/public-api.lock +++ b/vortex-array/public-api.lock @@ -6528,6 +6528,8 @@ impl vortex_array::dtype::datetime::Timestamp pub fn vortex_array::dtype::datetime::Timestamp::new(time_unit: vortex_array::dtype::datetime::TimeUnit, nullability: vortex_array::dtype::Nullability) -> vortex_array::dtype::extension::ExtDType +pub fn vortex_array::dtype::datetime::Timestamp::new_with_options(options: vortex_array::dtype::datetime::TimestampOptions, nullability: vortex_array::dtype::Nullability) -> vortex_array::dtype::extension::ExtDType + pub fn vortex_array::dtype::datetime::Timestamp::new_with_tz(time_unit: vortex_array::dtype::datetime::TimeUnit, timezone: core::option::Option>, nullability: vortex_array::dtype::Nullability) -> vortex_array::dtype::extension::ExtDType impl core::clone::Clone for vortex_array::dtype::datetime::Timestamp @@ -6642,10 +6644,28 @@ pub fn vortex_array::dtype::extension::ExtDType::storage_dtype(&self) -> &vor pub fn vortex_array::dtype::extension::ExtDType::try_with_vtable(vtable: V, metadata: ::Metadata, storage_dtype: vortex_array::dtype::DType) -> vortex_error::VortexResult +pub fn vortex_array::dtype::extension::ExtDType::vtable(&self) -> &V + impl core::clone::Clone for vortex_array::dtype::extension::ExtDType pub fn vortex_array::dtype::extension::ExtDType::clone(&self) -> vortex_array::dtype::extension::ExtDType +impl core::cmp::Eq for vortex_array::dtype::extension::ExtDType + +impl core::cmp::PartialEq for vortex_array::dtype::extension::ExtDType + +pub fn vortex_array::dtype::extension::ExtDType::eq(&self, other: &vortex_array::dtype::extension::ExtDType) -> bool + +impl core::fmt::Debug for vortex_array::dtype::extension::ExtDType + +pub fn vortex_array::dtype::extension::ExtDType::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result + +impl core::hash::Hash for vortex_array::dtype::extension::ExtDType + +pub fn vortex_array::dtype::extension::ExtDType::hash<__H: core::hash::Hasher>(&self, state: &mut __H) + +impl core::marker::StructuralPartialEq for vortex_array::dtype::extension::ExtDType + pub struct vortex_array::dtype::extension::ExtDTypeMetadata<'a> impl vortex_array::dtype::extension::ExtDTypeMetadata<'_> @@ -6690,8 +6710,12 @@ pub fn vortex_array::dtype::extension::ExtDTypeRef::eq_ignore_nullability(&self, pub fn vortex_array::dtype::extension::ExtDTypeRef::id(&self) -> vortex_array::dtype::extension::ExtID +pub fn vortex_array::dtype::extension::ExtDTypeRef::is_nullable(&self) -> bool + pub fn vortex_array::dtype::extension::ExtDTypeRef::metadata_erased(&self) -> vortex_array::dtype::extension::ExtDTypeMetadata<'_> +pub fn vortex_array::dtype::extension::ExtDTypeRef::nullability(&self) -> vortex_array::dtype::Nullability + pub fn vortex_array::dtype::extension::ExtDTypeRef::storage_dtype(&self) -> &vortex_array::dtype::DType pub fn vortex_array::dtype::extension::ExtDTypeRef::with_nullability(&self, nullability: vortex_array::dtype::Nullability) -> Self @@ -7520,10 +7544,28 @@ pub fn vortex_array::dtype::extension::ExtDType::storage_dtype(&self) -> &vor pub fn vortex_array::dtype::extension::ExtDType::try_with_vtable(vtable: V, metadata: ::Metadata, storage_dtype: vortex_array::dtype::DType) -> vortex_error::VortexResult +pub fn vortex_array::dtype::extension::ExtDType::vtable(&self) -> &V + impl core::clone::Clone for vortex_array::dtype::extension::ExtDType pub fn vortex_array::dtype::extension::ExtDType::clone(&self) -> vortex_array::dtype::extension::ExtDType +impl core::cmp::Eq for vortex_array::dtype::extension::ExtDType + +impl core::cmp::PartialEq for vortex_array::dtype::extension::ExtDType + +pub fn vortex_array::dtype::extension::ExtDType::eq(&self, other: &vortex_array::dtype::extension::ExtDType) -> bool + +impl core::fmt::Debug for vortex_array::dtype::extension::ExtDType + +pub fn vortex_array::dtype::extension::ExtDType::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result + +impl core::hash::Hash for vortex_array::dtype::extension::ExtDType + +pub fn vortex_array::dtype::extension::ExtDType::hash<__H: core::hash::Hasher>(&self, state: &mut __H) + +impl core::marker::StructuralPartialEq for vortex_array::dtype::extension::ExtDType + pub struct vortex_array::dtype::ExtDTypeRef(_) impl vortex_array::dtype::extension::ExtDTypeRef @@ -7544,8 +7586,12 @@ pub fn vortex_array::dtype::extension::ExtDTypeRef::eq_ignore_nullability(&self, pub fn vortex_array::dtype::extension::ExtDTypeRef::id(&self) -> vortex_array::dtype::extension::ExtID +pub fn vortex_array::dtype::extension::ExtDTypeRef::is_nullable(&self) -> bool + pub fn vortex_array::dtype::extension::ExtDTypeRef::metadata_erased(&self) -> vortex_array::dtype::extension::ExtDTypeMetadata<'_> +pub fn vortex_array::dtype::extension::ExtDTypeRef::nullability(&self) -> vortex_array::dtype::Nullability + pub fn vortex_array::dtype::extension::ExtDTypeRef::storage_dtype(&self) -> &vortex_array::dtype::DType pub fn vortex_array::dtype::extension::ExtDTypeRef::with_nullability(&self, nullability: vortex_array::dtype::Nullability) -> Self diff --git a/vortex-array/src/dtype/datetime/timestamp.rs b/vortex-array/src/dtype/datetime/timestamp.rs index d5e4b261006..c7069032fee 100644 --- a/vortex-array/src/dtype/datetime/timestamp.rs +++ b/vortex-array/src/dtype/datetime/timestamp.rs @@ -46,6 +46,12 @@ impl Timestamp { ) .vortex_expect("failed to create timestamp dtype") } + + /// Creates a new `Timestamp` extension dtype with the given options and nullability. + pub fn new_with_options(options: TimestampOptions, nullability: Nullability) -> ExtDType { + ExtDType::try_new(options, DType::Primitive(PType::I64, nullability)) + .vortex_expect("failed to create timestamp dtype") + } } /// Options for the Timestamp DType. diff --git a/vortex-array/src/dtype/extension/mod.rs b/vortex-array/src/dtype/extension/mod.rs index 27c082e47ca..a6c3a494fae 100644 --- a/vortex-array/src/dtype/extension/mod.rs +++ b/vortex-array/src/dtype/extension/mod.rs @@ -29,7 +29,7 @@ use crate::dtype::Nullability; pub type ExtID = ArcRef; /// An extension data type. -#[derive(Clone)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ExtDType(Arc>); // Convenience impls for zero-sized VTables @@ -60,6 +60,11 @@ impl ExtDType { self.0.id() } + /// Returns the vtable of the extension type. + pub fn vtable(&self) -> &V { + &self.0.vtable + } + /// Returns the metadata of the extension type. pub fn metadata(&self) -> &V::Metadata { &self.0.metadata @@ -135,9 +140,20 @@ impl ExtDTypeRef { self.0.storage_dtype() } + /// Returns the nullability of the storage dtype. + pub fn nullability(&self) -> Nullability { + // The nullability of the extension type must always be the same as the storage type. + self.storage_dtype().nullability() + } + + /// Returns true if the storage dtype is nullable. + pub fn is_nullable(&self) -> bool { + self.nullability().is_nullable() + } + /// Returns a new ExtDTypeRef with the given nullability. pub fn with_nullability(&self, nullability: Nullability) -> Self { - if self.storage_dtype().nullability() == nullability { + if self.nullability() == nullability { self.clone() } else { self.0.with_nullability(nullability) @@ -211,7 +227,7 @@ impl ExtDTypeRef { /// Wrapper for type-erased extension dtype metadata. pub struct ExtDTypeMetadata<'a> { - pub(super) ext_dtype: &'a ExtDTypeRef, + ext_dtype: &'a ExtDTypeRef, } impl ExtDTypeMetadata<'_> { @@ -262,6 +278,7 @@ trait ExtDTypeImpl: 'static + Send + Sync + private::Sealed { fn with_nullability(&self, nullability: Nullability) -> ExtDTypeRef; } +#[derive(Debug, PartialEq, Eq, Hash)] struct ExtDTypeAdapter { vtable: V, metadata: V::Metadata,