You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "neilconway (via GitHub)" <gi...@apache.org> on 2026/08/21 20:47:39 UTC
[I] `variant_get` converts floats and doubles to decimals without checking the target precision [arrow-rs]
neilconway opened a new issue, #10795:
URL: https://github.com/apache/arrow-rs/issues/10795
### Describe the bug
See repro. Similar to #10794
### To Reproduce
```rust
use arrow::array::{ArrayRef, AsArray, Float64Array};
use arrow::compute::cast;
use arrow::datatypes::{DataType, Decimal32Type, DecimalType, Field};
use parquet_variant::Variant;
use parquet_variant_compute::{GetOptions, VariantArrayBuilder, variant_get};
use std::sync::Arc;
let target = DataType::Decimal32(5, 2); // max 999.99
// cast(Float64 -> Decimal32(5, 2)): the value does not fit, so the result is null
let floats: ArrayRef = Arc::new(Float64Array::from(vec![12345.678]));
assert!(cast(&floats, &target).unwrap().is_null(0));
// variant_get with the same values: non-null, out-of-precision results
let mut builder = VariantArrayBuilder::new(2);
builder.append_variant(Variant::Double(12345.678));
builder.append_variant(Variant::Float(12345.678));
let input = ArrayRef::from(builder.build());
let options = GetOptions::new().with_as_type(Some(Arc::new(Field::new("r", target, true))));
let out = variant_get(&input, options).unwrap();
let out = out.as_primitive::<Decimal32Type>();
assert_eq!(out.null_count(), 0);
assert_eq!(out.value(0), 1234568); // 12345.68 in a Decimal32(5, 2) array
assert!(!Decimal32Type::is_valid_decimal_precision(out.value(0), 5));
assert!(!Decimal32Type::is_valid_decimal_precision(out.value(1), 5));
```
### Expected behavior
_No response_
### Additional context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] `variant_get` converts floats and doubles to decimals without checking the target precision [arrow-rs]
Posted by "sdf-jkl (via GitHub)" <gi...@apache.org>.
sdf-jkl closed issue #10795: `variant_get` converts floats and doubles to decimals without checking the target precision
URL: https://github.com/apache/arrow-rs/issues/10795
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] `variant_get` converts floats and doubles to decimals without checking the target precision [arrow-rs]
Posted by "neilconway (via GitHub)" <gi...@apache.org>.
neilconway commented on issue #10795:
URL: https://github.com/apache/arrow-rs/issues/10795#issuecomment-5375243956
take
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org