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: support reading and writingStringView and BinaryView in parquet (part 2) #5557

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions arrow-data/src/byte_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ impl ByteView {
| ((self.buffer_index as u128) << 64)
| ((self.offset as u128) << 96)
}

#[inline(always)]
pub fn as_bytes(self) -> [u8; 16] {
self.as_u128().to_le_bytes()
}
}

impl From<u128> for ByteView {
Expand Down
18 changes: 18 additions & 0 deletions parquet/src/arrow/arrow_writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,16 @@ mod tests {
values_required::<BinaryArray, _>(many_vecs_iter);
}

#[test]
fn binary_view_single_column() {
let one_vec: Vec<u8> = (0..SMALL_SIZE as u8).collect();
let many_vecs: Vec<_> = std::iter::repeat(one_vec).take(SMALL_SIZE).collect();
let many_vecs_iter = many_vecs.iter().map(|v| v.as_slice());

// BinaryArrays can't be built from Vec<Option<&str>>, so only call `values_required`
values_required::<BinaryViewArray, _>(many_vecs_iter);
}

#[test]
fn i32_column_bloom_filter() {
let array = Arc::new(Int32Array::from_iter(0..SMALL_SIZE as i32));
Expand Down Expand Up @@ -2187,6 +2197,14 @@ mod tests {
required_and_optional::<StringArray, _>(raw_strs);
}

#[test]
fn string_view_single_column() {
let raw_values: Vec<_> = (0..SMALL_SIZE).map(|i| i.to_string()).collect();
let raw_strs = raw_values.iter().map(|s| s.as_str());

required_and_optional::<StringViewArray, _>(raw_strs);
}

#[test]
fn large_string_single_column() {
let raw_values: Vec<_> = (0..SMALL_SIZE).map(|i| i.to_string()).collect();
Expand Down
Loading