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

Create ArrayScalarBuilder for creating single element List arrays #13623

Merged
merged 4 commits into from
Dec 4, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Dec 2, 2024

Which issue does this PR close?

Rationale for this change

There are a bewildering number of small free functions for performing the same basic thing: converting an array into a single row list array / scalar

This has also lead to subtle bugs such as #13481

Let's encapsulate that operation into a well documented structure

What changes are included in this PR?

  1. Add ArrayScalarBuilder
  2. Tests
  3. Documentation

Are these changes tested?

Are there any user-facing changes?

@alamb alamb marked this pull request as draft December 2, 2024 19:50
@github-actions github-actions bot added common Related to common crate functions labels Dec 2, 2024
@alamb alamb force-pushed the alamb/single_row_array branch from be70e93 to 26f2492 Compare December 2, 2024 20:13
@@ -321,89 +321,180 @@ pub fn longest_consecutive_prefix<T: Borrow<usize>>(
count
}

/// Creates single element [`ListArray`], [`LargeListArray`] and
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 idea is to pull the wrapping code into this structure so it remains consistent across list types

@alamb alamb marked this pull request as ready for review December 2, 2024 20:31
/// assert_eq!(list_arr.len(), 1);
/// ```
#[derive(Debug, Clone)]
pub struct SingleRowArrayBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this builder is for List, maybe name with SingleRowListArrayBuilder is more concise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 505edc9 👍

@jayzhan211 jayzhan211 merged commit 049ca15 into apache:main Dec 4, 2024
25 checks passed
@jayzhan211
Copy link
Contributor

Thanks @alamb

@alamb
Copy link
Contributor Author

alamb commented Dec 4, 2024

Thank you @jayzhan211

@alamb alamb deleted the alamb/single_row_array branch December 4, 2024 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Related to common crate functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants