Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

feat: Support cast to large list. #1547

Merged
merged 2 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! feat: Support cast to large list.
  • Loading branch information
reswqa committed Aug 20, 2023
commit 9f01bd78fb1286d79db51dcec5a534333b54a7c7
1 change: 1 addition & 0 deletions src/compute/cast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
(List(list_from), LargeList(list_to)) if list_from == list_to => true,
(LargeList(list_from), List(list_to)) if list_from == list_to => true,
(_, List(list_to)) => can_cast_types(from_type, &list_to.data_type),
(_, LargeList(list_to)) => can_cast_types(from_type, &list_to.data_type),
(Dictionary(_, from_value_type, _), Dictionary(_, to_value_type, _)) => {
can_cast_types(from_value_type, to_value_type)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/it/compute/cast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use arrow2::array::*;
use arrow2::compute::cast::{can_cast_types, cast, CastOptions};
use arrow2::datatypes::*;
use arrow2::datatypes::DataType::LargeList;
use arrow2::datatypes::*;
use arrow2::types::{days_ms, months_days_ns, NativeType};

#[test]
Expand Down Expand Up @@ -129,7 +129,7 @@ fn i32_to_large_list_i32() {
&LargeList(Box::new(Field::new("item", DataType::Int32, true))),
CastOptions::default(),
)
.unwrap();
.unwrap();

let arr = b.as_any().downcast_ref::<ListArray<i64>>().unwrap();
assert_eq!(&[0, 1, 2, 3, 4, 5], arr.offsets().as_slice());
Expand Down
Loading