feat(arrow-array): add BinaryArrayType similar to StringArrayType#6924
feat(arrow-array): add BinaryArrayType similar to StringArrayType#6924rluvaton wants to merge 1 commit intoapache:mainfrom
BinaryArrayType similar to StringArrayType#6924Conversation
wiedld
left a comment
There was a problem hiding this comment.
Question. What does this provide which is missing with the current IntoIterator implementations for &'a GenericByteArray, &'a FixedSizeBinaryArray, and &'a BinaryViewArray?
My question above is because I think this may not be needed? But I wasn't sure if I was missing something. This introduced trait converts a referenced array to an ArrayIter, and it does so by abstracting over these three generic types (GenericBinaryArray, BinaryViewArray, FixedSizeBinaryArray) calling the When I looked at the existing code, we have a &'a GenericByteArray which also takes a reference and returns ArrayIter. So I wasn't sure why this was needed -- and what it added by making the |
I am not sure -- that is why I was asking for an example of this trait being used -- then we can have a concrete discussion if this API is duplicative or not |
I think the idea is that |
|
IMO this looks great. I was just trying to figure out what this provided that fn use_binary_array<'a>(array: impl arrow_array::ArrayAccessor<Item = &'a [u8]>) {
// Have to manually iterate over the array
for i in 0..array.len() {
dbg!(String::from_utf8(array.value(i).to_vec()).unwrap());
}
}
#[test]
fn binary_array() {
let mut builder = BinaryViewBuilder::new();
builder.append_value(b"foo");
builder.append_value(b"bar");
builder.append_value(b"baz");
use_binary_array(&builder.finish());
let mut builder = FixedSizeBinaryBuilder::new(3);
builder.append_value(b"foo").unwrap();
builder.append_value(b"bar").unwrap();
builder.append_value(b"baz").unwrap();
use_binary_array(&builder.finish());
} |
|
The above example use case (kindly provided by @kylebarron) -- is already passing on main. 🤔 |
So perhaps the conclusion is that What can we do to make it clearer to find? Maybe we can add this example on |
|
Well, on the contrary I was saying that |
|
Marking as draft as I don't think this PR is waiting on feedback anymore -- it needs some test / use in the crate otherwise it risks bitrotting / maybe not working as designed. Please mark it ready for review when it is ready for another look |
Rationale for this change
This trait helps to abstract over the different types of binary arrays
so that we don't need to duplicate the implementation for each type.
Same as
StringArrayTypeWhat changes are included in this PR?
Added
BinaryArrayTypeand implemented forBinaryArray,LargeBinaryArray,BinaryViewArrayandFixedSizeBinaryArrayAre there any user-facing changes?
Yes, there is a new public trait