-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
From this comments in the datafusion.
apache/datafusion#1394 (comment)
Creating an DecimalArray from an array of Option<i128> using DecimalBuilder is quite painful (see apache/datafusion#1394)
Ideally it would be possible to do something similar to the PrimitiveArrays, such as https://docs.rs/arrow/6.3.0/arrow/array/type.UInt32Array.html#example-using-collect
// get an iterator over `Option<i128>`
let data: Vec<Option<i128>> = ....;
let array: DecimalArray = data.into_iter().collect();Describe the solution you'd like
However, since DecimalArray has precision and scale in its DataType, we need some way to specify that.
One thought, would be a function such as (for precision 20 and scale 5):
let array = DecimalArray::from_iter_and_scale(20, 5, data.iter())An alternate might be something more like:
// creates a decimal array with default precision 32 and scale 0 (could be something else)
let array: DecimalArray = data.into_iter().collect();
// consume the existing array and make a new one with a different declared precision and scale
let array = array.with_precision_and_scale(20, 5);Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.