Skip to content
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

fix: ensure take_fixed_size_list can handle null indices #5170

Merged

Conversation

westonpace
Copy link
Member

Which issue does this PR close?

Closes #5169

Rationale for this change

See issue

What changes are included in this PR?

The take implementation for fixed size list currently works by expanding the indices from "list indices" into "child indices". In other words, if the list is a fixed size list of 3 and the indices are [0, 5] then it converts this into [0, 1, 2, 15, 16, 17]. This process was ignoring null indices and the result was that the child array would be too short. For example, [0, null] would turn into [0, 1, 2] which is too short. This PR propagates the null into the child index list. So now [0, null] turns into [0, 1, 2, null, null, null].

Are there any user-facing changes?

None

arrow-select/src/take.rs Outdated Show resolved Hide resolved
arrow-select/src/take.rs Show resolved Hide resolved
arrow-select/src/take.rs Outdated Show resolved Hide resolved
westonpace and others added 2 commits December 5, 2023 11:17
Co-authored-by: Will Jones <willjones127@gmail.com>
@@ -689,7 +689,7 @@ fn take_value_indices_from_fixed_size_list<IndexType>(
where
IndexType: ArrowPrimitiveType,
{
let mut values = vec![];
let mut values = Vec::with_capacity(length as usize * indices.len());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, we should make this PrimitiveBuilder, since the conversion from Vec is no longer zero-copy when it's an Option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to a builder

arrow-select/src/take.rs Outdated Show resolved Hide resolved
arrow-select/src/take.rs Outdated Show resolved Hide resolved
@wjones127 wjones127 merged commit f4bad68 into apache:master Dec 6, 2023
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Take panics on a fixed size list array when given null indices
2 participants