Skip to content

Conversation

@a10y
Copy link
Contributor

@a10y a10y commented Sep 6, 2024

Which issue does this PR close?

Closes #6366

Rationale for this change

Previously, StringViewArrays and BinaryViewArrays sent to PyArrow will panic.

If you use the updated test_to_pyarrow() from this PR without the additional changes, it will fail.

What changes are included in this PR?

The specification states that the C Data Interface format for StringViewArray and BinaryViewArray includes an extra variadic_buffer_sizes buffer at the end of the various output values.

We were not including that before. There was a prior PR to add it for the IPC format, but not for the C Data Interface.

I cribbed the relevant C++ code for this: https://github.com/apache/arrow/blob/ab0a40ee34217070f14027776682074c55d0b507/cpp/src/arrow/c/bridge.cc#L584-L609

Are there any user-facing changes?

It should now be possible to share StringViewArray and BinaryViewArray over C Data Interface.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Sep 6, 2024
@a10y
Copy link
Contributor Author

a10y commented Sep 6, 2024

Keeping this in draft until I can do some manual verification that it works

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.

Thank you @a10y -- this code looks great to me. I am not a low level expert in this area but I read it closely and it looks good. I found the code clear and easy to follow and the comments really helped. 🏆

I think the PR needs a few more tests (I commented on which below) but otherwise is ready to go.

@alamb alamb changed the title fix lingering C Data Interface issues for *ViewArray Support StringViewArray interop with python: fix lingering C Data Interface issues for *ViewArray Sep 11, 2024
@a10y
Copy link
Contributor Author

a10y commented Sep 11, 2024

@alamb I believe I've implemented all of the requested tests, thanks for reviewing!

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.

Looks good to me -- thank you @a10y

assert_eq!(mixed_one_variadic.data_buffers().len(), 1);
run_test_case!(mixed_one_variadic);

// inlined + non-inlined, 2 variadic buffers.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

}

fn binary_view_column(num_variadic_buffers: usize) -> BinaryViewArray {
let long_scalar = b"but soft what light through yonder window breaks".as_slice();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 nice choice

@alamb alamb merged commit 60ec869 into apache:master Sep 12, 2024
@alamb
Copy link
Contributor

alamb commented Sep 12, 2024

Thanks again @a10y

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.

Exporting Binary/Utf8View from arrow-rs to pyarrow fails

2 participants