Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-10042: [Rust] Fix tests involving ArrayData/Buffer equality #8590

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions rust/arrow/src/array/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,11 @@ mod tests {
assert_eq!(2, new_data.offset());
assert_eq!(data.null_count() - 1, new_data.null_count());
}

#[test]
fn test_equality() {
let int_data = ArrayData::builder(DataType::Int32).build();
let float_data = ArrayData::builder(DataType::Float32).build();
assert_ne!(int_data, float_data);
}
}
14 changes: 11 additions & 3 deletions rust/arrow/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ mod tests {
#[test]
fn test_buffer_data_equality() {
let buf1 = Buffer::from(&[0, 1, 2, 3, 4]);
let mut buf2 = Buffer::from(&[0, 1, 2, 3, 4]);
let buf2 = Buffer::from(&[0, 1, 2, 3, 4]);
assert_eq!(buf1, buf2);

// slice with same offset should still preserve equality
Expand All @@ -854,12 +854,20 @@ mod tests {
let buf4 = buf2.slice(2);
assert_eq!(buf3, buf4);

// Different capacities should still preserve equality
let mut buf2 = MutableBuffer::new(65);
buf2.write_all(&[0, 1, 2, 3, 4])
.expect("write should be OK");

let buf2 = buf2.freeze();
assert_eq!(buf1, buf2);

// unequal because of different elements
buf2 = Buffer::from(&[0, 0, 2, 3, 4]);
let buf2 = Buffer::from(&[0, 0, 2, 3, 4]);
assert_ne!(buf1, buf2);

// unequal because of different length
buf2 = Buffer::from(&[0, 1, 2, 3]);
let buf2 = Buffer::from(&[0, 1, 2, 3]);
assert_ne!(buf1, buf2);
}

Expand Down
14 changes: 1 addition & 13 deletions rust/parquet/src/arrow/arrow_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,17 +911,7 @@ mod tests {
let expected_data = expected_batch.column(i).data();
let actual_data = actual_batch.column(i).data();

assert_eq!(expected_data.data_type(), actual_data.data_type());
assert_eq!(expected_data.len(), actual_data.len());
assert_eq!(expected_data.null_count(), actual_data.null_count());
assert_eq!(expected_data.offset(), actual_data.offset());
assert_eq!(expected_data.buffers(), actual_data.buffers());
assert_eq!(expected_data.child_data(), actual_data.child_data());
// Null counts should be the same, not necessarily bitmaps
// A null bitmap is optional if an array has no nulls
if expected_data.null_count() != 0 {
assert_eq!(expected_data.null_bitmap(), actual_data.null_bitmap());
}
assert_eq!(expected_data, actual_data);
}
}

Expand Down Expand Up @@ -1198,7 +1188,6 @@ mod tests {
}

#[test]
#[ignore] // Binary support isn't correct yet - buffers don't match
fn binary_single_column() {
let one_vec: Vec<u8> = (0..SMALL_SIZE as u8).collect();
let many_vecs: Vec<_> = std::iter::repeat(one_vec).take(SMALL_SIZE).collect();
Expand All @@ -1209,7 +1198,6 @@ mod tests {
}

#[test]
#[ignore] // Large binary support isn't correct yet - buffers don't match
fn large_binary_single_column() {
let one_vec: Vec<u8> = (0..SMALL_SIZE as u8).collect();
let many_vecs: Vec<_> = std::iter::repeat(one_vec).take(SMALL_SIZE).collect();
Expand Down