Overview
Currently Duckdb-rs supports Decimal128, but not Decimal256. However, its support for Decimal128 downcasts to f64. See decimal_array_to_vector.
/// Convert Arrow [Decimal128Array] to a duckdb vector.
fn decimal_array_to_vector(array: &Decimal128Array, out: &mut FlatVector) {
assert!(array.len() <= out.capacity());
for i in 0..array.len() {
out.as_mut_slice()[i] = array.value_as_string(i).parse::<f64>().unwrap();
}
}
This fails a check_rust_primitive_array_roundtrip, when I ran it locally.
assertion `left == right` failed
left: Float64
right: Decimal128(38, 10)
The underlying cause of the issue is that duckdb-rs explicitly converts to Double, and not Decimal see code
// duckdb/src/main/capi/helper-c.cpp does not support decimal
// DataType::Decimal128(_, _) => Decimal,
// DataType::Decimal256(_, _) => Decimal,
DataType::Decimal128(_, _) => Double,
DataType::Decimal256(_, _) => Double,
The comment above reference the fact Decimal does not appear in https://github.com/duckdb/duckdb/blob/main/src/main/capi/helper-c.cpp#L5-L61.
Feature
Support for Decimal128 and Decimal256.
Question
Is this issue in capi/helper-c.cpp an intrinisic issue with DuckDB, and if not, what work would be required to support all Decimal types in the Rust bindings?
Overview
Currently Duckdb-rs supports Decimal128, but not Decimal256. However, its support for Decimal128 downcasts to f64. See decimal_array_to_vector.
This fails a check_rust_primitive_array_roundtrip, when I ran it locally.
The underlying cause of the issue is that duckdb-rs explicitly converts to Double, and not Decimal see code
The comment above reference the fact Decimal does not appear in https://github.com/duckdb/duckdb/blob/main/src/main/capi/helper-c.cpp#L5-L61.
Feature
Support for Decimal128 and Decimal256.
Question
Is this issue in
capi/helper-c.cppan intrinisic issue with DuckDB, and if not, what work would be required to support all Decimal types in the Rust bindings?