Skip to content

Commit 5b3aacc

Browse files
authored
Minor: Remove unecessary map_err (#9186)
1 parent f97a208 commit 5b3aacc

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

datafusion/common/src/scalar.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use std::iter::repeat;
2727
use std::str::FromStr;
2828
use std::sync::Arc;
2929

30-
use crate::arrow_datafusion_err;
3130
use crate::cast::{
3231
as_decimal128_array, as_decimal256_array, as_dictionary_array,
3332
as_fixed_size_binary_array, as_fixed_size_list_array,
@@ -1639,18 +1638,16 @@ impl ScalarValue {
16391638
scale: i8,
16401639
size: usize,
16411640
) -> Result<Decimal128Array> {
1642-
match value {
1641+
Ok(match value {
16431642
Some(val) => Decimal128Array::from(vec![val; size])
1644-
.with_precision_and_scale(precision, scale)
1645-
.map_err(|e| arrow_datafusion_err!(e)),
1643+
.with_precision_and_scale(precision, scale)?,
16461644
None => {
16471645
let mut builder = Decimal128Array::builder(size)
1648-
.with_precision_and_scale(precision, scale)
1649-
.map_err(|e| arrow_datafusion_err!(e))?;
1646+
.with_precision_and_scale(precision, scale)?;
16501647
builder.append_nulls(size);
1651-
Ok(builder.finish())
1648+
builder.finish()
16521649
}
1653-
}
1650+
})
16541651
}
16551652

16561653
fn build_decimal256_array(
@@ -1659,11 +1656,10 @@ impl ScalarValue {
16591656
scale: i8,
16601657
size: usize,
16611658
) -> Result<Decimal256Array> {
1662-
std::iter::repeat(value)
1659+
Ok(std::iter::repeat(value)
16631660
.take(size)
16641661
.collect::<Decimal256Array>()
1665-
.with_precision_and_scale(precision, scale)
1666-
.map_err(|e| arrow_datafusion_err!(e))
1662+
.with_precision_and_scale(precision, scale)?)
16671663
}
16681664

16691665
/// Converts `Vec<ScalarValue>` where each element has type corresponding to
@@ -2053,7 +2049,7 @@ impl ScalarValue {
20532049

20542050
fn list_to_array_of_size(arr: &dyn Array, size: usize) -> Result<ArrayRef> {
20552051
let arrays = std::iter::repeat(arr).take(size).collect::<Vec<_>>();
2056-
arrow::compute::concat(arrays.as_slice()).map_err(|e| arrow_datafusion_err!(e))
2052+
Ok(arrow::compute::concat(arrays.as_slice())?)
20572053
}
20582054

20592055
/// Retrieve ScalarValue for each row in `array`

0 commit comments

Comments
 (0)