This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 312e2fd44a Move variant interop test to Rust integration test (#7602)
312e2fd44a is described below
commit 312e2fd44a96b6d96a9c79c51876ab701825ab66
Author: Andrew Lamb <[email protected]>
AuthorDate: Mon Jun 9 09:07:12 2025 -0400
Move variant interop test to Rust integration test (#7602)
# Which issue does this PR close?
- Part of https://github.com/apache/arrow-rs/issues/6736
# Rationale for this change
Rust integration tests (in `parquet-variant/tests`) are compiled as a
external program would be compiled and thus can only use the exposed
API. This helps verify that the crate is usable
# What changes are included in this PR?
1. Move the tests that read/write variant values into `variant_interop`
test (`cargo test --test variant_interop`)
2. Publically expose `pub` structures
# Are there any user-facing changes?
There are now pub APIs in the parquet-variant crate
---
parquet-testing | 2 +-
parquet-variant/src/lib.rs | 5 +----
parquet-variant/src/variant.rs | 8 +++++++-
.../{src/test_variant.rs => tests/variant_interop.rs} | 19 +++++++++----------
4 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/parquet-testing b/parquet-testing
index 2dc8bf140e..b68bea40fe 160000
--- a/parquet-testing
+++ b/parquet-testing
@@ -1 +1 @@
-Subproject commit 2dc8bf140ed6e28652fc347211c7d661714c7f95
+Subproject commit b68bea40fed8d1a780a9e09dd2262017e04b19ad
diff --git a/parquet-variant/src/lib.rs b/parquet-variant/src/lib.rs
index a31187daeb..557271823b 100644
--- a/parquet-variant/src/lib.rs
+++ b/parquet-variant/src/lib.rs
@@ -30,12 +30,9 @@
// TODO: dead code removal
#[allow(dead_code)]
mod decoder;
-// TODO: dead code removal
-#[allow(dead_code)]
mod variant;
// TODO: dead code removal
#[allow(dead_code)]
mod utils;
-#[cfg(test)]
-mod test_variant;
+pub use variant::*;
diff --git a/parquet-variant/src/variant.rs b/parquet-variant/src/variant.rs
index 999826f5c2..b7b1932580 100644
--- a/parquet-variant/src/variant.rs
+++ b/parquet-variant/src/variant.rs
@@ -88,7 +88,7 @@ impl OffsetSizeBytes {
}
#[derive(Clone, Debug, Copy, PartialEq)]
-pub(crate) struct VariantMetadataHeader {
+pub struct VariantMetadataHeader {
version: u8,
is_sorted: bool,
/// Note: This is `offset_size_minus_one` + 1
@@ -323,10 +323,16 @@ pub struct VariantArray<'m, 'v> {
}
impl<'m, 'v> VariantArray<'m, 'v> {
+ /// Return the length of this array
pub fn len(&self) -> usize {
todo!()
}
+ /// Is the array of zero length
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
+ }
+
pub fn values(&self) -> Result<impl Iterator<Item = Variant<'m, 'v>>,
ArrowError> {
todo!();
#[allow(unreachable_code)] // Just to infer the return type
diff --git a/parquet-variant/src/test_variant.rs
b/parquet-variant/tests/variant_interop.rs
similarity index 81%
rename from parquet-variant/src/test_variant.rs
rename to parquet-variant/tests/variant_interop.rs
index 07c9eaf9c6..33bbbd5f5e 100644
--- a/parquet-variant/src/test_variant.rs
+++ b/parquet-variant/tests/variant_interop.rs
@@ -23,8 +23,8 @@
use std::fs;
use std::path::{Path, PathBuf};
-use crate::variant::{Variant, VariantMetadata};
use arrow_schema::ArrowError;
+use parquet_variant::{Variant, VariantMetadata};
fn cases_dir() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR"))
@@ -42,15 +42,14 @@ fn load_case(name: &str) -> Result<(Vec<u8>, Vec<u8>),
ArrowError> {
fn get_primitive_cases() -> Vec<(&'static str, Variant<'static, 'static>)> {
vec![
- ("primitive_boolean_false", Variant::BooleanFalse),
- ("primitive_boolean_true", Variant::BooleanTrue),
- ("primitive_int8", Variant::Int8(42)),
- // Using the From<String> trait
- ("primitive_string", Variant::from("This string is longer than 64 bytes
and therefore does not fit in a short_string and it also includes several non
ascii characters such as 🐢, 💖, ♥\u{fe0f}, 🎣 and 🤦!!")),
- // Using the From<String> trait
- ("short_string", Variant::from("Less than 64 bytes (❤\u{fe0f} with
utf8)")),
- // TODO Reenable when https://github.com/apache/parquet-testing/issues/81
is fixed
- // ("primitive_null", Variant::Null),
+ ("primitive_null", Variant::Null),
+ ("primitive_boolean_false", Variant::BooleanFalse),
+ ("primitive_boolean_true", Variant::BooleanTrue),
+ ("primitive_int8", Variant::Int8(42)),
+ // Using the From<String> trait
+ ("primitive_string", Variant::from("This string is longer than 64
bytes and therefore does not fit in a short_string and it also includes several
non ascii characters such as 🐢, 💖, ♥\u{fe0f}, 🎣 and 🤦!!")),
+ // Using the From<String> trait
+ ("short_string", Variant::from("Less than 64 bytes (❤\u{fe0f} with
utf8)")),
]
}