This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-11556-cf9a19df5cac2855f6c16c314eefc7656000b20f
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git

commit 94789d5b4904e0c40bf89588f3ca76d6f32bb5cc
Author: Kosta Tarasov <[email protected]>
AuthorDate: Sat Oct 17 15:06:31 2026 +0000

    Add Variant string-to-decimal benchmarks (#11556)
    
    # Which issue does this PR close?
    
    Follow-up to #11416.
    
    # Rationale for this change
    
    The existing `variant_get` decimal benchmarks cover integer and
    floating-point
    inputs, but not strings. These cases provide a baseline for measuring
    changes
    to string parsing and decimal conversion.
    
    # What changes are included in this PR?
    
    Add six benchmarks covering four conversion paths:
    
    - Short strings to Decimal32 in safe and strict modes.
    - Strings longer than Variant's 63-byte short-string limit to Decimal128
    in
      safe and strict modes.
    - Wide values to Decimal256, exercising accumulation beyond the
    Decimal128
      range.
    - Strings to Decimal256 with a negative scale, exercising the additional
      integer-digit scan and scale-down path.
    
    Fixtures contain 8,192 unshredded Variant rows with approximately 10%
    nulls and
    a fixed RNG seed. They reuse the existing `bench_variant_get_decimal`
    helper,
    with fixture construction outside timing.
    
    # Are these changes tested?
    
    This PR adds benchmarks only. All six cases were smoke-tested on
    upstream main
    (`4dc6bc25f3`). Formatting and whitespace checks pass. No library
    behavior
    changes or additional unit tests are included.
    
    # Are there any significant user-facing changes?
    
    No.
    
    # AI usage
    
    Developed with assistance from OpenAI Codex for implementation,
    validation,
    and this description.
---
 parquet-variant-compute/benches/variant_kernels.rs | 47 +++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/parquet-variant-compute/benches/variant_kernels.rs 
b/parquet-variant-compute/benches/variant_kernels.rs
index c1b5e6fda6..d556f19170 100644
--- a/parquet-variant-compute/benches/variant_kernels.rs
+++ b/parquet-variant-compute/benches/variant_kernels.rs
@@ -661,6 +661,50 @@ pub fn variant_get_decimal_from_float_bench(c: &mut 
Criterion) {
     );
 }
 
+pub fn variant_get_decimal_from_string_bench(c: &mut Criterion) {
+    let samples = ["123.45", "-67.89", "0"];
+    bench_variant_get_decimal(
+        c,
+        "short_string_to_decimal32(7,2)_valid",
+        |rng| Variant::from(samples[rng.random_range(0..samples.len())]),
+        DataType::Decimal32(7, 2),
+        &[true, false],
+    );
+
+    // Exceed the 63-byte short-string limit while keeping the values in range.
+    let samples = [
+        
"0000000000000000000000000000000000000000000000000000000000000000123.45",
+        
"-000000000000000000000000000000000000000000000000000000000000000067.89",
+    ];
+    bench_variant_get_decimal(
+        c,
+        "string_to_decimal128(38,3)_long",
+        |rng| Variant::from(samples[rng.random_range(0..samples.len())]),
+        DataType::Decimal128(38, 3),
+        &[true, false],
+    );
+    let samples = [
+        "1234567890123456789012345678901234567890.12",
+        "-1234567890123456789012345678901234567890.12",
+    ];
+    bench_variant_get_decimal(
+        c,
+        "short_string_to_decimal256(76,2)_wide",
+        |rng| Variant::from(samples[rng.random_range(0..samples.len())]),
+        DataType::Decimal256(76, 2),
+        &[true],
+    );
+
+    let samples = ["12345.67", "-6789.01", "0"];
+    bench_variant_get_decimal(
+        c,
+        "short_string_to_decimal256(40,-2)_scale_down",
+        |rng| Variant::from(samples[rng.random_range(0..samples.len())]),
+        DataType::Decimal256(40, -2),
+        &[true],
+    );
+}
+
 fn bench_variant_get_decimal(
     c: &mut Criterion,
     name: &str,
@@ -685,7 +729,7 @@ fn bench_variant_get_decimal(
             &format!("variant_get_decimal_{name}_8192_{mode}"),
             |rng, array_size| {
                 // Unshredded input exercises Variant's scalar conversion. Keep
-                // the requested numeric type and make every tenth row null.
+                // the requested source type and make every tenth row null.
                 let mut builder = VariantArrayBuilder::new(array_size);
                 for i in 0..array_size {
                     if i % 10 == 0 {
@@ -726,6 +770,7 @@ criterion_group!(
     variant_get_binary_from_string_bench,
     variant_get_decimal_from_int_bench,
     variant_get_decimal_from_float_bench,
+    variant_get_decimal_from_string_bench,
 );
 
 criterion_main!(benches);

Reply via email to