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

feat: add take for MapArray #3925

Merged
merged 2 commits into from
Mar 25, 2023
Merged

feat: add take for MapArray #3925

merged 2 commits into from
Mar 25, 2023

Conversation

wjones127
Copy link
Member

Which issue does this PR close?

Closes #3875

Rationale for this change

This seems to be one of the only array types that isn't supported by this function.

What changes are included in this PR?

Adds an easy conversion between MapArray and ListArray, which allows us to reuse kernels that support ListArray.

Are there any user-facing changes?

No breaking changes.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Mar 24, 2023
Comment on lines 276 to 287
let old_data = value.to_data();
let array_data = unsafe {
ArrayData::new_unchecked(
DataType::Map(field.clone(), false),
old_data.len(),
Some(old_data.null_count()),
old_data.nulls().map(|nulls|nulls.buffer().clone()),
old_data.offset(),
old_data.buffers().to_vec(),
old_data.child_data().to_vec(),
)
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a better way to create a copy of ArrayData that's the same except for the type?

Copy link
Contributor

Choose a reason for hiding this comment

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

into_builder()

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, that's much better!

@@ -251,6 +251,69 @@ impl std::fmt::Debug for MapArray {
}
}

impl TryFrom<&ListArray> for MapArray {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
impl TryFrom<&ListArray> for MapArray {
impl TryFrom<ListArray> for MapArray {

To be consistent with other array conversions, and to make the clone explicit if necessary

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this one.

arrow-array/src/array/map_array.rs Outdated Show resolved Hide resolved
let old_data = value.to_data();
let array_data = unsafe {
ArrayData::new_unchecked(
DataType::Map(field.clone(), false),
Copy link
Contributor

Choose a reason for hiding this comment

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

This data type inference is potentially problematic, as it loses part

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what you meant here, but I deleted this implementation so not sure it's relevant anyways.

arrow-select/src/take.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

Thank you

@tustvold tustvold merged commit 1500c9b into apache:master Mar 25, 2023
richox pushed a commit to richox/arrow-rs that referenced this pull request Apr 7, 2023
* feat: add take for MapArray

* refactor: use into_builder
richox pushed a commit to richox/arrow-rs that referenced this pull request Apr 7, 2023
* feat: add take for MapArray

* refactor: use into_builder
richox pushed a commit to richox/arrow-rs that referenced this pull request Apr 7, 2023
* feat: add take for MapArray

* refactor: use into_builder
richox pushed a commit to richox/arrow-rs that referenced this pull request Apr 7, 2023
* feat: add take for MapArray

* refactor: use into_builder
richox pushed a commit to richox/arrow-rs that referenced this pull request Apr 7, 2023
* feat: add take for MapArray

* refactor: use into_builder
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.

Support take on MapArray
2 participants