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 76829d5ce4 Fix unshredded Variant field extraction benchmark (#11253)
76829d5ce4 is described below

commit 76829d5ce4562616a69ea8b2696e96160514482f
Author: Kosta Tarasov <[email protected]>
AuthorDate: Mon Sep 28 11:11:37 2026 -0400

    Fix unshredded Variant field extraction benchmark (#11253)
    
    # Which issue does this PR close?
    
    Follow-up to #10357; corrects the benchmark used by #10358.
    
    # Rationale for this change
    
    The unshredded object fixture has a literal field named `attr.140`, but
    `VariantPath::try_from("attr.140")` parses it as two nested fields
    (`attr` then `140`). Since the fixture has no `attr` field, the
    benchmark returns NULL for every row instead of extracting the intended
    value.
    
    # What changes are included in this PR?
    
    Construct the path with `VariantPathElement::field("attr.140")` and
    assert that every result is `Some(140)` before entering the timed loop.
    
    # Are these changes tested?
    
    - `cargo bench --offline -p parquet-variant-compute --bench
    variant_kernels -- variant_get_unshredded_object_path_262k_rows --test`
    - `cargo fmt --all -- --check`
    - `git diff --check`
    
    # Are there any user-facing changes?
    
    No. This only corrects the benchmark workload; previous timings for this
    benchmark measured missing-path handling.
---
 parquet-variant-compute/benches/variant_kernels.rs | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/parquet-variant-compute/benches/variant_kernels.rs 
b/parquet-variant-compute/benches/variant_kernels.rs
index 5a8862f1a9..373a66cdd8 100644
--- a/parquet-variant-compute/benches/variant_kernels.rs
+++ b/parquet-variant-compute/benches/variant_kernels.rs
@@ -15,14 +15,16 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use arrow::array::{Array, ArrayRef, BinaryViewArray, BinaryViewBuilder, 
StringArray, StructArray};
+use arrow::array::{
+    Array, ArrayRef, BinaryViewArray, BinaryViewBuilder, Int32Array, 
StringArray, StructArray,
+};
 use arrow::buffer::Buffer;
 use arrow_schema::{DataType, Field, FieldRef, Fields};
 use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime};
 use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
 use parquet_variant::{
     EMPTY_VARIANT_METADATA_BYTES, Variant, VariantBuilder, VariantBuilderExt, 
VariantDecimal8,
-    VariantPath,
+    VariantPath, VariantPathElement,
 };
 use parquet_variant_compute::{
     GetOptions, VariantArray, VariantArrayBuilder, json_to_variant, 
shred_variant, variant_get,
@@ -198,8 +200,13 @@ pub fn variant_get_unshredded_object_path_bench(c: &mut 
Criterion) {
     let variant_array = 
create_unshredded_object_variant_array(VARIANT_GET_UNSHREDDED_OBJECT_ROWS);
     let input = ArrayRef::from(variant_array);
     let field: FieldRef = Arc::new(Field::new("typed_value", DataType::Int32, 
true));
-    let options = 
GetOptions::new_with_path(VariantPath::try_from("attr.140").unwrap())
-        .with_as_type(Some(field));
+    // The dot is part of the field name, not a separator between nested 
fields.
+    let path = VariantPath::from(vec![VariantPathElement::field("attr.140")]);
+    let options = GetOptions::new_with_path(path).with_as_type(Some(field));
+
+    let result = variant_get(&input, options.clone()).unwrap();
+    let result = result.as_any().downcast_ref::<Int32Array>().unwrap();
+    assert!(result.iter().all(|value| value == Some(140)));
 
     c.bench_function("variant_get_unshredded_object_path_262k_rows", |b| {
         b.iter(|| variant_get(&input, options.clone()).unwrap())

Reply via email to