Weijun-H commented on code in PR #7893:
URL: https://github.com/apache/arrow-datafusion/pull/7893#discussion_r1458573584
##########
datafusion/common/src/scalar.rs:
##########
@@ -370,6 +370,34 @@ impl PartialOrd for ScalarValue {
partial_cmp_list(arr1.as_ref(), arr2.as_ref())
}
(List(_), _) | (LargeList(_), _) | (FixedSizeList(_), _) => None,
+ (Struct(struct_arr1), Struct(struct_arr2)) => {
+ if struct_arr1.len() != struct_arr2.len() {
+ return None;
+ }
+
+ if struct_arr1.data_type() != struct_arr2.data_type() {
+ return None;
+ }
+
+ for col_index in 0..struct_arr1.num_columns() {
+ let arr1 = struct_arr1.column(col_index);
+ let arr2 = struct_arr2.column(col_index);
+
+ let lt_res = arrow::compute::kernels::cmp::lt(arr1,
arr2).ok()?;
+ let eq_res = arrow::compute::kernels::cmp::eq(arr1,
arr2).ok()?;
+
+ for j in 0..lt_res.len() {
+ if lt_res.is_valid(j) && lt_res.value(j) {
+ return Some(Ordering::Less);
+ }
+ if eq_res.is_valid(j) && !eq_res.value(j) {
+ return Some(Ordering::Greater);
+ }
+ }
+ }
+ Some(Ordering::Equal)
Review Comment:
What do you think put it into function `partial_cmp_struct` to make the code
clear?
##########
datafusion/common/src/scalar.rs:
##########
@@ -1376,6 +1395,70 @@ impl ScalarValue {
}};
}
+ fn build_struct_array(
Review 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]