tustvold commented on code in PR #5217:
URL: https://github.com/apache/arrow-rs/pull/5217#discussion_r1436957712
##########
arrow-ord/src/cmp.rs:
##########
@@ -702,4 +826,137 @@ mod tests {
neq(&col.slice(0, col.len() - 1), &col.slice(1, col.len() -
1)).unwrap();
}
+
+ #[test]
+ fn test_struct_uncomparable() {
+ // test struct('a') == struct('a','b')
+ let left_a = Arc::new(Int32Array::new(
+ vec![0, 1, 2, 3].into(),
+ Some(vec![true, false, true, false].into()),
+ ));
+ let right_a = Arc::new(Int32Array::new(
+ vec![0, 1, 2, 3].into(),
+ Some(vec![true, false, true, false].into()),
+ ));
+ let right_b = Arc::new(Int32Array::new(
+ vec![0, 1, 2, 3].into(),
+ Some(vec![true, true, true, false].into()),
+ ));
+ let field_a = Arc::new(Field::new("a", DataType::Int32, true));
+ let field_b = Arc::new(Field::new("b", DataType::Int32, true));
+ let left = StructArray::from(vec![(field_a.clone(), left_a.clone() as
ArrayRef)]);
+ let right = StructArray::from(vec![
+ (field_a.clone(), right_a.clone() as ArrayRef),
+ (field_b.clone(), right_b.clone() as ArrayRef),
+ ]);
+ assert_eq!(eq(&left, &right).unwrap_err().to_string(), "Invalid
argument error: Invalid comparison operation: Struct([Field { name: \"a\",
data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
{} }]) == Struct([Field { name: \"a\", data_type: Int32, nullable: true,
dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: \"b\",
data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
{} }])");
+
+ // test struct('a') <= struct('a')
+ assert_eq!(lt(&left, &left).unwrap_err().to_string(), "Invalid
argument error: Invalid comparison operation: Struct([Field { name: \"a\",
data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
{} }]) < Struct([Field { name: \"a\", data_type: Int32, nullable: true,
dict_id: 0, dict_is_ordered: false, metadata: {} }])");
+ }
+
+ #[test]
+ fn test_struct_compare() {
+ // test struct('a', 'b')ćstruct('a', 'b'), the null buffer is 0b0111
+ // left b[2] is different from right b[2]
+ let left_a = Arc::new(Int32Array::new(
+ vec![0, 1, 2, 3].into(),
+ Some(vec![true, false, true, true].into()),
+ ));
+ let right_a = Arc::new(Int32Array::new(
+ vec![0, 1, 2, 3].into(),
Review Comment:
```suggestion
vec![0, 72, 2, 3].into(),
```
This helps verify the null mask comparison is correct, and not relying on
the values comparison
--
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]