Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions vortex-array/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>

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<Self>

pub fn vortex_array::dtype::datetime::Timestamp::new_with_tz(time_unit: vortex_array::dtype::datetime::TimeUnit, timezone: core::option::Option<alloc::sync::Arc<str>>, nullability: vortex_array::dtype::Nullability) -> vortex_array::dtype::extension::ExtDType<Self>

impl core::clone::Clone for vortex_array::dtype::datetime::Timestamp
Expand Down Expand Up @@ -6642,10 +6644,28 @@ pub fn vortex_array::dtype::extension::ExtDType<V>::storage_dtype(&self) -> &vor

pub fn vortex_array::dtype::extension::ExtDType<V>::try_with_vtable(vtable: V, metadata: <V as vortex_array::dtype::extension::ExtDTypeVTable>::Metadata, storage_dtype: vortex_array::dtype::DType) -> vortex_error::VortexResult<Self>

pub fn vortex_array::dtype::extension::ExtDType<V>::vtable(&self) -> &V

impl<V: core::clone::Clone + vortex_array::dtype::extension::ExtDTypeVTable> core::clone::Clone for vortex_array::dtype::extension::ExtDType<V>

pub fn vortex_array::dtype::extension::ExtDType<V>::clone(&self) -> vortex_array::dtype::extension::ExtDType<V>

impl<V: core::cmp::Eq + vortex_array::dtype::extension::ExtDTypeVTable> core::cmp::Eq for vortex_array::dtype::extension::ExtDType<V>

impl<V: core::cmp::PartialEq + vortex_array::dtype::extension::ExtDTypeVTable> core::cmp::PartialEq for vortex_array::dtype::extension::ExtDType<V>

pub fn vortex_array::dtype::extension::ExtDType<V>::eq(&self, other: &vortex_array::dtype::extension::ExtDType<V>) -> bool

impl<V: core::fmt::Debug + vortex_array::dtype::extension::ExtDTypeVTable> core::fmt::Debug for vortex_array::dtype::extension::ExtDType<V>

pub fn vortex_array::dtype::extension::ExtDType<V>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

impl<V: core::hash::Hash + vortex_array::dtype::extension::ExtDTypeVTable> core::hash::Hash for vortex_array::dtype::extension::ExtDType<V>

pub fn vortex_array::dtype::extension::ExtDType<V>::hash<__H: core::hash::Hasher>(&self, state: &mut __H)

impl<V: vortex_array::dtype::extension::ExtDTypeVTable> core::marker::StructuralPartialEq for vortex_array::dtype::extension::ExtDType<V>

pub struct vortex_array::dtype::extension::ExtDTypeMetadata<'a>

impl vortex_array::dtype::extension::ExtDTypeMetadata<'_>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -7520,10 +7544,28 @@ pub fn vortex_array::dtype::extension::ExtDType<V>::storage_dtype(&self) -> &vor

pub fn vortex_array::dtype::extension::ExtDType<V>::try_with_vtable(vtable: V, metadata: <V as vortex_array::dtype::extension::ExtDTypeVTable>::Metadata, storage_dtype: vortex_array::dtype::DType) -> vortex_error::VortexResult<Self>

pub fn vortex_array::dtype::extension::ExtDType<V>::vtable(&self) -> &V

impl<V: core::clone::Clone + vortex_array::dtype::extension::ExtDTypeVTable> core::clone::Clone for vortex_array::dtype::extension::ExtDType<V>

pub fn vortex_array::dtype::extension::ExtDType<V>::clone(&self) -> vortex_array::dtype::extension::ExtDType<V>

impl<V: core::cmp::Eq + vortex_array::dtype::extension::ExtDTypeVTable> core::cmp::Eq for vortex_array::dtype::extension::ExtDType<V>

impl<V: core::cmp::PartialEq + vortex_array::dtype::extension::ExtDTypeVTable> core::cmp::PartialEq for vortex_array::dtype::extension::ExtDType<V>

pub fn vortex_array::dtype::extension::ExtDType<V>::eq(&self, other: &vortex_array::dtype::extension::ExtDType<V>) -> bool

impl<V: core::fmt::Debug + vortex_array::dtype::extension::ExtDTypeVTable> core::fmt::Debug for vortex_array::dtype::extension::ExtDType<V>

pub fn vortex_array::dtype::extension::ExtDType<V>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

impl<V: core::hash::Hash + vortex_array::dtype::extension::ExtDTypeVTable> core::hash::Hash for vortex_array::dtype::extension::ExtDType<V>

pub fn vortex_array::dtype::extension::ExtDType<V>::hash<__H: core::hash::Hasher>(&self, state: &mut __H)

impl<V: vortex_array::dtype::extension::ExtDTypeVTable> core::marker::StructuralPartialEq for vortex_array::dtype::extension::ExtDType<V>

pub struct vortex_array::dtype::ExtDTypeRef(_)

impl vortex_array::dtype::extension::ExtDTypeRef
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions vortex-array/src/dtype/datetime/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
ExtDType::try_new(options, DType::Primitive(PType::I64, nullability))
.vortex_expect("failed to create timestamp dtype")
}
}

/// Options for the Timestamp DType.
Expand Down
23 changes: 20 additions & 3 deletions vortex-array/src/dtype/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::dtype::Nullability;
pub type ExtID = ArcRef<str>;

/// An extension data type.
#[derive(Clone)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ExtDType<V: ExtDTypeVTable>(Arc<ExtDTypeAdapter<V>>);

// Convenience impls for zero-sized VTables
Expand Down Expand Up @@ -60,6 +60,11 @@ impl<V: ExtDTypeVTable> ExtDType<V> {
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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<'_> {
Expand Down Expand Up @@ -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<V: ExtDTypeVTable> {
vtable: V,
metadata: V::Metadata,
Expand Down
Loading