alamb commented on code in PR #8562:
URL: https://github.com/apache/arrow-datafusion/pull/8562#discussion_r1443768896
##########
datafusion/common/src/scalar.rs:
##########
@@ -2937,13 +3015,33 @@ impl fmt::Display for ScalarValue {
)?,
None => write!(f, "NULL")?,
},
- ScalarValue::List(arr)
- | ScalarValue::LargeList(arr)
- | ScalarValue::FixedSizeList(arr) => {
+ ScalarValue::List(arr) => {
// ScalarValue List should always have a single element
assert_eq!(arr.len(), 1);
let options =
FormatOptions::default().with_display_error(true);
- let formatter = ArrayFormatter::try_new(arr,
&options).unwrap();
+ let formatter =
Review Comment:
The same pattern could be applied here as in
https://github.com/rspears74/arrow-datafusion/pull/1 (use
`first_array_for_list`)
##########
datafusion/common/src/scalar.rs:
##########
@@ -359,29 +359,77 @@ impl PartialOrd for ScalarValue {
(FixedSizeBinary(_, _), _) => None,
(LargeBinary(v1), LargeBinary(v2)) => v1.partial_cmp(v2),
(LargeBinary(_), _) => None,
- (List(arr1), List(arr2))
- | (FixedSizeList(arr1), FixedSizeList(arr2))
- | (LargeList(arr1), LargeList(arr2)) => {
- // ScalarValue::List / ScalarValue::FixedSizeList /
ScalarValue::LargeList are ensure to have length 1
+ // ScalarValue::List / ScalarValue::FixedSizeList /
ScalarValue::LargeList are ensure to have length 1
+ (List(arr1), List(arr2)) => {
assert_eq!(arr1.len(), 1);
assert_eq!(arr2.len(), 1);
if arr1.data_type() != arr2.data_type() {
return None;
}
- fn first_array_for_list(arr: &ArrayRef) -> ArrayRef {
- if let Some(arr) = arr.as_list_opt::<i32>() {
- arr.value(0)
- } else if let Some(arr) = arr.as_list_opt::<i64>() {
- arr.value(0)
- } else if let Some(arr) = arr.as_fixed_size_list_opt() {
- arr.value(0)
- } else {
- unreachable!("Since only List / LargeList /
FixedSizeList are supported, this should never happen")
+ fn first_array_for_list(arr: &Arc<ListArray>) -> ArrayRef {
Review Comment:
Here is a proposal of how to do it:
https://github.com/rspears74/arrow-datafusion/pull/1 (that targets this 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]