Skip to content

Commit 7b1d689

Browse files
Fix up tests
1 parent 20171ad commit 7b1d689

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

arrow-array/src/array/union_array.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,8 +1705,9 @@ mod tests {
17051705
.len(7)
17061706
.buffers(vec![type_ids, value_offsets])
17071707
.child_data(vec![
1708-
string_array.into_data(),
1708+
// Child arrays must be in sorted order by type ID: 4, 8, 9
17091709
int_array.into_data(),
1710+
string_array.into_data(),
17101711
float_array.into_data(),
17111712
])
17121713
.build()
@@ -1817,8 +1818,9 @@ mod tests {
18171818
.len(7)
18181819
.buffers(vec![type_ids, value_offsets])
18191820
.child_data(vec![
1820-
string_array.into_data(),
1821+
// Child arrays must be in sorted order by type ID: 4, 8, 9
18211822
int_array.into_data(),
1823+
string_array.into_data(),
18221824
float_array.into_data(),
18231825
])
18241826
.build()
@@ -1846,9 +1848,10 @@ mod tests {
18461848
],
18471849
)
18481850
.unwrap();
1851+
// Child arrays must be in sorted order by type ID: 2, 3
18491852
let children = vec![
1850-
Arc::new(StringArray::from_iter_values(["a", "b"])) as _,
18511853
Arc::new(StringArray::from_iter_values(["c", "d"])) as _,
1854+
Arc::new(StringArray::from_iter_values(["a", "b"])) as _,
18521855
];
18531856

18541857
let type_ids = vec![3, 3, 2].into();
@@ -1874,9 +1877,10 @@ mod tests {
18741877
"Invalid argument error: Type Ids values must match one of the field type ids"
18751878
);
18761879

1880+
// Child arrays must be in sorted order by type ID: 2, 3
18771881
let children = vec![
1878-
Arc::new(StringArray::from_iter_values(["a", "b"])) as _,
18791882
Arc::new(StringArray::from_iter_values(["c"])) as _,
1883+
Arc::new(StringArray::from_iter_values(["a", "b"])) as _,
18801884
];
18811885
let type_ids = ScalarBuffer::from(vec![3_i8, 3, 2]);
18821886
let offsets = Some(vec![0, 1, 0].into());

arrow-schema/src/fields.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl<'a> IntoIterator for &'a Fields {
318318
}
319319

320320
/// A cheaply cloneable, owned collection of [`FieldRef`] and their corresponding type ids
321-
#[derive(Clone, Eq, Ord, PartialOrd)]
321+
#[derive(Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
322322
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
323323
#[cfg_attr(feature = "serde", serde(transparent))]
324324
pub struct UnionFields(Arc<[(i8, FieldRef)]>);
@@ -345,21 +345,6 @@ impl std::ops::Index<usize> for UnionFields {
345345
}
346346
}
347347

348-
impl PartialEq for UnionFields {
349-
fn eq(&self, other: &Self) -> bool {
350-
self.len() == other.len() && self.iter().all(|a| other.iter().any(|b| a == b))
351-
}
352-
}
353-
354-
impl Hash for UnionFields {
355-
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
356-
let mut v = self.0.iter().collect::<Vec<_>>();
357-
v.sort_by_key(|(id, _)| *id);
358-
359-
v.hash(state);
360-
}
361-
}
362-
363348
impl UnionFields {
364349
/// Create a new [`UnionFields`] with no fields
365350
pub fn empty() -> Self {

0 commit comments

Comments
 (0)