alamb commented on PR #9486:
URL: https://github.com/apache/arrow-rs/pull/9486#issuecomment-4092234595
In terms of the failing test, I think the clearest behavior would be to have
the arrow-row crate follow the same contract as the eq kernels for equality
(which I think is that the order of fields must match exactly)
If a user wants to treat maps with different field orders as equal, they can
write some sort of canonicalization function perhaps that reorders the fields 🤔
What do yo uthink about this approach:
```diff
index 21a1af62c5..6f8b924084 100644
--- a/arrow-row/src/lib.rs
+++ b/arrow-row/src/lib.rs
@@ -2717,7 +2717,7 @@ mod tests {
assert_eq!(&cols[0], &col);
}
- /// If `exact` is false performs a logical comparison between a and
dictionary-encoded b
+ /// Performs a logical comparison between a and dictionary-encoded b.
fn dictionary_eq(a: &dyn Array, b: &dyn Array) {
match b.data_type() {
DataType::Dictionary(_, v) => {
@@ -4160,7 +4160,7 @@ mod tests {
}
#[test]
- fn two_maps_with_different_keys_order_should_still_match() {
+ fn two_maps_with_different_keys_order_should_sort_by_entry_order() {
// { "hello": 1, "world": 2 }
let map_1 = {
let mut builder = MapBuilder::new(None, StringBuilder::new(),
Int32Builder::new());
@@ -4196,10 +4196,13 @@ mod tests {
let map_1_rows =
converter.convert_columns(&[Arc::clone(&map_1)]).unwrap();
let map_2_rows =
converter.convert_columns(&[Arc::clone(&map_2)]).unwrap();
- assert_eq!(map_1_rows.row(0), map_2_rows.row(0));
+ assert_ne!(map_1_rows.row(0), map_2_rows.row(0));
+ assert!(map_1_rows.row(0) < map_2_rows.row(0));
- // TODO - what would the expected returned array be?
- // if they are the same rows they will produce the same output,
TODO - this should be noted if we decide to go that path
+ let back_1 = converter.convert_rows(&map_1_rows).unwrap();
+ let back_2 = converter.convert_rows(&map_2_rows).unwrap();
+ assert_eq!(&back_1[0], &map_1);
+ assert_eq!(&back_2[0], &map_2);
}
#[test]
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]