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

Support casting a FixedSizedList<T>[1] to T #5779

Merged
merged 2 commits into from
May 18, 2024

Conversation

sadboy
Copy link
Contributor

@sadboy sadboy commented May 17, 2024

Which issue does this PR close?

N/A
This is a followup to #5340

Rationale for this change

This implements the mirror of #5340 -- casting FixedSizedList<T>[1] to T. Taken together, this allows FixedSizedList<T>[1] to be used "as though it were a T" for the purpose of casting.

What changes are included in this PR?

  • New casting method: cast_single_element_fixed_size_list_to_values
  • Minor bug fix in FixedSizeListArray::try_new: allow nulls to be None when values has null buffer with null_count of 0.

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label May 17, 2024
@sadboy sadboy marked this pull request as ready for review May 17, 2024 03:02
@@ -183,7 +183,8 @@ impl FixedSizeListArray {
|| nulls
.as_ref()
.map(|n| n.expand(size as _).contains(&a))
.unwrap_or_default();
.unwrap_or_default()
|| (nulls.is_none() && a.null_count() == 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The values array could have a NullBuffer but no actual nulls in it (which happens when you safe-cast from a primitive array). This just accounts for that case.

@tustvold tustvold merged commit a126d50 into apache:master May 18, 2024
25 checks passed
@sadboy sadboy deleted the fixedsizelist branch May 18, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants