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
4 changes: 1 addition & 3 deletions vortex-array/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9166,7 +9166,7 @@ impl core::cmp::Eq for vortex_array::dtype::DType

impl core::cmp::PartialEq for vortex_array::dtype::DType

pub fn vortex_array::dtype::DType::eq(&self, other: &vortex_array::dtype::DType) -> bool
pub fn vortex_array::dtype::DType::eq(&self, other: &Self) -> bool

impl core::convert::From<vortex_array::dtype::DType> for vortex_array::dtype::FieldDType

Expand Down Expand Up @@ -9216,8 +9216,6 @@ impl core::hash::Hash for vortex_array::dtype::DType

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

impl core::marker::StructuralPartialEq for vortex_array::dtype::DType

impl vortex_array::dtype::arrow::FromArrowType<&arrow_schema::field::Field> for vortex_array::dtype::DType

pub fn vortex_array::dtype::DType::from_arrow(field: &arrow_schema::field::Field) -> Self
Expand Down
39 changes: 38 additions & 1 deletion vortex-array/src/dtype/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ use std::sync::Arc;
///
/// [`I32`]: PType::I32
/// [`NonNullable`]: Nullability::NonNullable
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Eq, Hash)]
#[allow(clippy::derived_hash_with_manual_eq)] // manual PartialEq adds Arc::ptr_eq fast path only
pub enum DType {
/// A logical null type.
///
Expand Down Expand Up @@ -106,6 +107,42 @@ pub enum DType {
Variant(Nullability),
}

impl PartialEq for DType {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Null, Self::Null) => true,
(Self::Bool(a), Self::Bool(b)) => a == b,
(Self::Primitive(pa, na), Self::Primitive(pb, nb)) => pa == pb && na == nb,
(Self::Decimal(da, na), Self::Decimal(db, nb)) => da == db && na == nb,
(Self::Utf8(a), Self::Utf8(b)) => a == b,
(Self::Binary(a), Self::Binary(b)) => a == b,
(Self::List(da, na), Self::List(db, nb)) => {
na == nb && (Arc::ptr_eq(da, db) || da == db)
}
(Self::FixedSizeList(da, sa, na), Self::FixedSizeList(db, sb, nb)) => {
sa == sb && na == nb && (Arc::ptr_eq(da, db) || da == db)
}
// StructFields handles its own Arc::ptr_eq in its PartialEq impl.
(Self::Struct(a, na), Self::Struct(b, nb)) => na == nb && a == b,
(Self::Extension(a), Self::Extension(b)) => a == b,
(Self::Variant(a), Self::Variant(b)) => a == b,
// Every variant is listed in the first position so that adding a new
// variant produces a non-exhaustive match compile error.
(Self::Null, _)
| (Self::Bool(_), _)
| (Self::Primitive(..), _)
| (Self::Decimal(..), _)
| (Self::Utf8(_), _)
| (Self::Binary(_), _)
| (Self::List(..), _)
| (Self::FixedSizeList(..), _)
| (Self::Struct(..), _)
| (Self::Extension(_), _)
| (Self::Variant(_), _) => false,
}
}
}

pub use bigint::*;
pub use decimal::*;
pub use dtype_impl::NativeDType;
Expand Down
Loading