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

Cleanup cast_primitive_to_list #4511

Merged
merged 2 commits into from
Jul 12, 2023
Merged

Conversation

tustvold
Copy link
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jul 12, 2023
to_type.clone(),
array.len(),
Some(cast_array.null_count()),
cast_array.nulls().map(|b| b.inner().sliced()),
Copy link
Contributor Author

@tustvold tustvold Jul 12, 2023

Choose a reason for hiding this comment

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

There is no reason to duplicate the null buffer here, so I opted to just remove this. I can easily revert if people feel it is better to include the child null mask twice

@@ -9448,4 +9420,21 @@ mod tests {
assert_eq!("1969-12-31", string_array.value(1));
assert_eq!("1989-12-31", string_array.value(2));
}

#[test]
fn test_nested_list() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not new functionality, I just couldn't find a test of it

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Makes sense to me

@@ -5098,7 +5070,7 @@ mod tests {
)
.unwrap();
assert_eq!(5, b.len());
assert_eq!(1, b.null_count());
assert_eq!(0, b.null_count());
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the difference that b[1] is [null] (aka a 1 element list with a null) rather than null itself? I believe that is already covered below.

fn test_nested_list() {
let mut list = ListBuilder::new(Int32Builder::new());
list.append_value([Some(1), Some(2), Some(3)]);
list.append_value([Some(4), Some(5), Some(6)]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please include a NULL in the list -- for example,

Suggested change
list.append_value([Some(4), Some(5), Some(6)]);
list.append_value([Some(4), Null, Some(6)]);

@tustvold tustvold merged commit e169355 into apache:master Jul 12, 2023
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