New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARROW-4865: [Rust] Support list casts #3896
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3896 +/- ##
==========================================
+ Coverage 87.85% 88.68% +0.82%
==========================================
Files 726 592 -134
Lines 88304 78721 -9583
Branches 1252 0 -1252
==========================================
- Hits 77578 69812 -7766
+ Misses 10612 8909 -1703
+ Partials 114 0 -114 Continue to review full report at Codecov.
|
(List(_), List(ref to)) => { | ||
let data = array.data_ref(); | ||
let underlying_array = make_array(data.child_data()[0].clone()); | ||
let cast_array = cast(&underlying_array, &*to)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: &*to
-> to
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
rust/arrow/src/array.rs
Outdated
@@ -131,7 +131,7 @@ pub type ArrayRef = Arc<Array>; | |||
|
|||
/// Constructs an array using the input `data`. Returns a reference-counted `Array` | |||
/// instance. | |||
fn make_array(data: ArrayDataRef) -> ArrayRef { | |||
pub fn make_array(data: ArrayDataRef) -> ArrayRef { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this pub(crate)
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
fn test_cast_i32_to_list_i32() { | ||
let a = Int32Array::from(vec![5, 6, 7, 8, 9]); | ||
let array = Arc::new(a) as ArrayRef; | ||
let b = cast(&array, &DataType::List(Box::new(DataType::Int32))).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also test length, offset for each value in the casted list array? same in test_cast_i32_to_list_i32_nullable
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done for all tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @nevi-me
@sunchao please see https://issues.apache.org/jira/browse/ARROW-4886, I've disabled casting sliced primitives to lists for now until we can slice list arrays. |
@nevi-me : sounds good. I'll try to get the slice issue fixed ASAP. BTW: in the null case, how does the conversion from primitive array to list array look like: is a null value converted to |
I'll check what happens, my initial thought is a list with a single null, because I would expect |
@sunchao I found the issue. When slicing an array, we count the nulls from a sliced offset bitmask, but we return the original bitmask without the offset applied. I've opened https://issues.apache.org/jira/browse/ARROW-4914 |
This is a follow up from the initial cast kernel PR, and adds support for:
The only remaining expansion to the cast kernel will be temporal casts, then I think we'll be able to cover all cast use-cases.