Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
  • Loading branch information
jayzhan211 committed Oct 25, 2023
1 parent 12620d3 commit c9f4ea1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions datafusion/common/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3314,13 +3314,14 @@ mod tests {

let array = ScalarValue::new_list(scalars.as_slice(), &DataType::Utf8);
let result = as_list_array(&array).unwrap();

let expected = wrap_into_list_array(&[&StringArray::from(vec![
"rust",
"arrow",
"data-fusion",
])]).unwrap();

])])
.unwrap();

assert_eq!(result, &expected);
}

Expand Down Expand Up @@ -3353,12 +3354,10 @@ mod tests {

#[test]
fn iter_to_array_string_test() {
let arr1 = wrap_into_list_array(&[&StringArray::from(vec![
"foo", "bar", "baz",
])]).unwrap();
let arr2 = wrap_into_list_array(&[&StringArray::from(vec![
"rust", "world",
])]).unwrap();
let arr1 = wrap_into_list_array(&[&StringArray::from(vec!["foo", "bar", "baz"])])
.unwrap();
let arr2 =
wrap_into_list_array(&[&StringArray::from(vec!["rust", "world"])]).unwrap();

let scalars = vec![
ScalarValue::List(Arc::new(arr1)),
Expand Down Expand Up @@ -4528,13 +4527,16 @@ mod tests {
// Define list-of-structs scalars

let nl0_array = ScalarValue::iter_to_array(vec![s0.clone(), s1.clone()]).unwrap();
let nl0 = ScalarValue::List(Arc::new(wrap_into_list_array(&[&nl0_array]).unwrap()));
let nl0 =
ScalarValue::List(Arc::new(wrap_into_list_array(&[&nl0_array]).unwrap()));

let nl1_array = ScalarValue::iter_to_array(vec![s2.clone()]).unwrap();
let nl1 = ScalarValue::List(Arc::new(wrap_into_list_array(&[&nl1_array]).unwrap()));
let nl1 =
ScalarValue::List(Arc::new(wrap_into_list_array(&[&nl1_array]).unwrap()));

let nl2_array = ScalarValue::iter_to_array(vec![s1.clone()]).unwrap();
let nl2 = ScalarValue::List(Arc::new(wrap_into_list_array(&[&nl2_array]).unwrap()));
let nl2 =
ScalarValue::List(Arc::new(wrap_into_list_array(&[&nl2_array]).unwrap()));

// iter_to_array for list-of-struct
let array = ScalarValue::iter_to_array(vec![nl0, nl1, nl2]).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion datafusion/common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub fn wrap_into_list_array(arr: &[&dyn Array]) -> Result<ListArray> {
let lens = arr.iter().map(|x| x.len()).collect::<Vec<_>>();
// Assume data type is consistent
let data_type = arr[0].data_type().to_owned();
let offsets = OffsetBuffer::from_lengths(lens.into_iter());
let offsets = OffsetBuffer::from_lengths(lens);
// let elements = arr.into_iter().map(|a| a.as_ref()).collect::<Vec<_>>();
Ok(ListArray::new(
Arc::new(Field::new("item", data_type, true)),
Expand Down

0 comments on commit c9f4ea1

Please sign in to comment.