You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "paleolimbot (via GitHub)" <gi...@apache.org> on 2026/01/14 21:33:54 UTC
[I] rust/sedona-testing: Update assert_array_equal to accept a SeondType parameter for better failures [sedona-db]
paleolimbot opened a new issue, #518:
URL: https://github.com/apache/sedona-db/issues/518
Currently failures from `assert_array_equal()` are very bad binary strings. This is a relict from a much, much earlier version of SedonaDB where our ArrayRef had the full extension type embedded and could detect the geometry case. Now we need a parameter:
```rust
/// Assert two [`ArrayRef`]s are equal with SedonaType context
///
/// Panics if the values' length or types are different or if the content is otherwise not
/// equal. This can be used in place of `assert_eq!()` to generate reasonable
/// failure messages for geometry arrays where the default failure message would
/// otherwise be uninformative.
pub fn assert_array_equal(actual: &ArrayRef, expected: &ArrayRef, sedona_type: &SedonaType) {
if actual.data_type() != sedona_type.storage_type() {
panic!(
"expected storage type != {sedona_type} storage type ({})",
sedona_type.storage_type()
);
}
if actual.data_type() != sedona_type.storage_type() {
panic!(
"actual storage type != {sedona_type} storage type ({})",
sedona_type.storage_type()
);
}
if actual.len() != expected.len() {
panic!(
"Lengths not equal: actual Array has length {}, expected Array has length {}",
actual.len(),
expected.len()
)
}
match sedona_type {
SedonaType::Arrow(_) => {
assert_eq!(actual, expected)
}
SedonaType::Wkb(_, _) => {
assert_wkb_sequences_equal(
as_binary_array(&actual).unwrap(),
as_binary_array(&expected).unwrap(),
);
}
SedonaType::WkbView(_, _) => {
assert_wkb_sequences_equal(
as_binary_view_array(&actual).unwrap(),
as_binary_view_array(&expected).unwrap(),
);
}
unsupported => {
panic!("SedonaType comparison for {unsupported} is not supported");
}
}
}
```
This change requires a lot of changes in tests but they should be straightfoward (I adapted this function whilst attempting to debug a failure of my own in a PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org