Skip to content

Commit 66bada5

Browse files
authored
Implement like/ilike etc for StringViewArray (#5931)
* like for string view array * fix bug * update doc * update tests
1 parent 3139a08 commit 66bada5

File tree

3 files changed

+417
-254
lines changed

3 files changed

+417
-254
lines changed

arrow-array/src/array/byte_view_array.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,20 @@ impl StringViewArray {
569569
pub fn to_binary_view(self) -> BinaryViewArray {
570570
unsafe { BinaryViewArray::new_unchecked(self.views, self.buffers, self.nulls) }
571571
}
572+
573+
/// Returns true if all data within this array is ASCII
574+
pub fn is_ascii(&self) -> bool {
575+
// Alternative (but incorrect): directly check the underlying buffers
576+
// (1) Our string view might be sparse, i.e., a subset of the buffers,
577+
// so even if the buffer is not ascii, we can still be ascii.
578+
// (2) It is quite difficult to know the range of each buffer (unlike StringArray)
579+
// This means that this operation is quite expensive, shall we cache the result?
580+
// i.e. track `is_ascii` in the builder.
581+
self.iter().all(|v| match v {
582+
Some(v) => v.is_ascii(),
583+
None => true,
584+
})
585+
}
572586
}
573587

574588
impl From<Vec<&str>> for StringViewArray {

0 commit comments

Comments
 (0)