Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`null_if_overflow_precision` resets decimal precision and scale, changing valid values

Open Beginner friendly
#11,300 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
data

Research direction

Start in arrow-array/src/array/primitive_array.rs at null_if_overflow_precision and inspect the unary_opt result construction. Add regression coverage in arrow-array/tests/decimal_overflow_mask.rs, including the decimal widths that share this implementation, then run cargo test -p arrow-array --test decimal_overflow_mask -- --nocapture. Done means masked arrays retain their input datatype and surviving values keep their numerical meaning.

Written by the indexing model from the issue text.

Description

Describe the bug

Decimal128Array::null_if_overflow_precision resets the output datatype to
Decimal128(38,10) instead of preserving the input precision and scale. It
retains the unscaled integers, so this changes the numerical meaning of values
that survive the mask.

No overflow is needed to trigger the bug: a valid one-element
Decimal128(2,1) array containing 9.9 becomes a Decimal128(38,10) array
containing 0.0000000099.

Reproduced on Apache Arrow Rust main at
8208506f8f9ec193c08023ac2477d211d1d86d20
(workspace version 60.0.0), checked on 2026-09-29.

To reproduce

In an arrow-rs checkout, put this in
arrow-array/tests/decimal_overflow_mask.rs:

use arrow_array::{Array, Decimal128Array};

#[test]
fn overflow_mask_preserves_decimal_type() {
    let input = Decimal128Array::from(vec![99])
        .with_precision_and_scale(2, 1)
        .unwrap();
    input.validate_decimal_precision(2).unwrap();

    let output = input.null_if_overflow_precision(2);

    println!("before: {:?}, {}", input.data_type(), input.value_as_string(0));
    println!("after:  {:?}, {}", output.data_type(), output.value_as_string(0));
    assert_eq!(output.value(0), 99);
    assert!(!output.is_null(0));
    assert_eq!(output.data_type(), input.data_type()); // fails
}

Run from the repository root:

cargo test -p arrow-array --test decimal_overflow_mask -- --nocapture

Observed output:

before: Decimal128(2, 1), 9.9
after:  Decimal128(38, 10), 0.0000000099

assertion `left == right` failed
  left: Decimal128(38, 10)
 right: Decimal128(2, 1)

Expected behavior

Mask values that exceed the supplied precision without changing the array's
datatype or the numerical meaning of surviving values. In this example the
output should still be Decimal128(2,1) containing 9.9.

Apparent cause

null_if_overflow_precision
calls self.unary_opt::<_, T>(...). That generic operation constructs its
result with
PrimitiveArray::new,
whose constructor initializes the datatype from T::DATA_TYPE. For
Decimal128Type, that is the default (38,10), not the input array's runtime
precision and scale. The masking method does not restore that runtime datatype.

A caller can compensate by applying .with_data_type(input.data_type().clone())
to the result. Preserving the datatype in the masking method itself would avoid
requiring every caller to do so. Regression coverage should include the other
decimal widths that share this implementation.

Additional context

This is separate from float/string-to-decimal conversion overflow: the input
above is already a valid decimal array, and no conversion or rounding occurs.
It was found while investigating Variant extraction, but this reproducer uses
only arrow-array.

AI assistance: OpenAI Codex assisted with investigation, reproducer execution,
and drafting this report.

Dominant language
Rust
Stars
3.6k
Forks
1.3k
Avg merge
3d 10h
Merged PRs (30d)
146

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/arrow-rs

All issues in apache/arrow-rs

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.