Rich-T-kid commented on code in PR #7933: URL: https://github.com/apache/arrow-rs/pull/7933#discussion_r2216753563
########## arrow-ord/src/cmp.rs: ########## @@ -855,4 +863,122 @@ mod tests { neq(&col.slice(0, col.len() - 1), &col.slice(1, col.len() - 1)).unwrap(); } + + #[cfg(test)] + mod ree_tests { + use arrow_array::{Int32Array, RunArray, BooleanArray}; + use arrow_array::types::Int32Type; + use super::super::*; + + #[test] + fn test_ree_distinct_basic() { + // Create REE array: [10, 10, 20, 30, 30] (logical length 5) + let run_ends = Int32Array::from(vec![2, 3, 5]); + let values = Int32Array::from(vec![10, 20, 30]); + let run_array = RunArray::<Int32Type>::try_new(&run_ends, &values).unwrap(); + + let run_ends = Int32Array::from(vec![2, 3, 5]); + let values = Int32Array::from(vec![10, 20, 30]); + let other_array = RunArray::<Int32Type>::try_new(&run_ends, &values).unwrap(); + // Test distinct operations + let result = distinct(&run_array, &other_array).unwrap(); + assert_eq!(result, BooleanArray::from(vec![false,false,false,false,false])); + + let result = not_distinct(&run_array, &other_array).unwrap(); + // Expected: [true, false, true, false, true] (opposite of distinct) + assert_eq!(result, BooleanArray::from(vec![true,true,true,true,true])); + } + + #[test] + fn test_ree_distinct_mismatched_values() { + // [10, 10, 20] + let run_ends = Int32Array::from(vec![2, 3]); + let values = Int32Array::from(vec![10, 20]); + let lhs = RunArray::<Int32Type>::try_new(&run_ends, &values).unwrap(); + + // [10, 10, 99] + let run_ends = Int32Array::from(vec![2, 3]); + let values = Int32Array::from(vec![10, 99]); + let rhs = RunArray::<Int32Type>::try_new(&run_ends, &values).unwrap(); + + let result = distinct(&lhs, &rhs).unwrap(); + assert_eq!(result, BooleanArray::from(vec![false, false, true])); + + let result = not_distinct(&lhs, &rhs).unwrap(); + assert_eq!(result, BooleanArray::from(vec![true, true, false])); + } + + #[test] + fn test_ree_distinct_all_different() { + // [1, 2, 3] + let run_ends = Int32Array::from(vec![1, 2, 3]); + let values = Int32Array::from(vec![1, 2, 3]); + let lhs = RunArray::<Int32Type>::try_new(&run_ends, &values).unwrap(); + + // [4, 5, 6] + let run_ends = Int32Array::from(vec![1, 2, 3]); + let values = Int32Array::from(vec![4, 5, 6]); + let rhs = RunArray::<Int32Type>::try_new(&run_ends, &values).unwrap(); + + let result = distinct(&lhs, &rhs).unwrap(); + assert_eq!(result, BooleanArray::from(vec![true, true, true])); + + let result = not_distinct(&lhs, &rhs).unwrap(); + assert_eq!(result, BooleanArray::from(vec![false, false, false])); + } + + //failed Review Comment: Remove comment -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org