This is an automated email from the ASF dual-hosted git repository.
Jefffrey 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 579ccf1a49 fix: Avoid spurious assert when Parquet decimal has scale
== precision (#10875)
579ccf1a49 is described below
commit 579ccf1a490c991a925c01bb055728e7a2c13f4a
Author: Neil Conway <[email protected]>
AuthorDate: Wed Aug 26 20:29:30 2026 -0400
fix: Avoid spurious assert when Parquet decimal has scale == precision
(#10875)
# Which issue does this PR close?
- Closes #10874.
# Rationale for this change
`convert_decimal_to_string` asserted `precision > scale`, but the
Parquet spec requires only `scale <= precision`, so displaying a row
from a file with a `DECIMAL(p, p)` column resulted in a spurious
assertion failure.
# What changes are included in this PR?
* Weaken assert to match Parquet spec
* Update test coverage
# Are these changes tested?
Yes, test coverage added.
# Are there any user-facing changes?
No.
---
parquet/src/record/api.rs | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/parquet/src/record/api.rs b/parquet/src/record/api.rs
index 3a09f5253c..665a54edb1 100644
--- a/parquet/src/record/api.rs
+++ b/parquet/src/record/api.rs
@@ -990,11 +990,11 @@ fn convert_time_micros_to_string(value: i64) -> String {
}
/// Helper method to convert Parquet decimal into a string.
-/// We assert that `scale >= 0` and `precision > scale`, but this will be
enforced
-/// when constructing Parquet schema.
+/// We assert that `scale >= 0` and `precision >= scale`, which is enforced
when
+/// constructing a Parquet schema.
#[inline]
fn convert_decimal_to_string(decimal: &Decimal) -> String {
- assert!(decimal.scale() >= 0 && decimal.precision() > decimal.scale());
+ assert!(decimal.scale() >= 0 && decimal.precision() >= decimal.scale());
// Specify as signed bytes to resolve sign as part of conversion.
let num = BigInt::from_signed_bytes_be(decimal.data());
@@ -1428,6 +1428,9 @@ mod tests {
check_decimal(vec![0, 0, 0, 0, 1, 201, 195, 140], 18, 2, "300000.12");
check_decimal(vec![207, 200], 10, 2, "-123.44");
check_decimal(vec![207, 200], 10, 8, "-0.00012344");
+ check_decimal(vec![48, 57], 5, 5, "0.12345");
+ check_decimal(vec![207, 199], 5, 5, "-0.12345");
+ check_decimal(vec![45], 5, 5, "0.00045");
}
#[test]