-
Notifications
You must be signed in to change notification settings - Fork 787
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
Add support for BinaryView in arrow_string::length #6359
Conversation
@@ -85,6 +85,14 @@ pub fn length(array: &dyn Array) -> Result<ArrayRef, ArrowError> { | |||
DataType::FixedSizeBinary(len) | DataType::FixedSizeList(_, len) => Ok(Arc::new( | |||
Int32Array::new(vec![*len; array.len()].into(), array.nulls().cloned()), | |||
)), | |||
DataType::BinaryView => { | |||
let list = array.as_binary_view(); | |||
let v = list.views().iter().map(|v| *v as i32).collect::<Vec<_>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Omega359 -- I have a test suggestion but the code in this PR looks good.
Thank you for making it small and easy to review
arrow-string/src/length.rs
Outdated
@@ -224,6 +232,18 @@ mod tests { | |||
length_binary_helper!(i64, Int64Array, length, value, result) | |||
} | |||
|
|||
#[test] | |||
fn length_test_binary_view() { | |||
let value: Vec<&[u8]> = vec![b"zero", &[0xff, 0xf8], b"two"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a test value that has more than 12 bytes (which ends up running a different code path)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @Omega359
b"zero", | ||
&[0xff, 0xf8], | ||
b"two", | ||
b"this is a longer string to test binary array with", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Which issue does this PR close?
Closes #6358
Rationale for this change
Adding additional functionality
What changes are included in this PR?
Code, test.
Are there any user-facing changes?
No.