Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: Remove unecessary map_err #9186

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions datafusion/common/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use std::iter::repeat;
use std::str::FromStr;
use std::sync::Arc;

use crate::arrow_datafusion_err;
use crate::cast::{
as_decimal128_array, as_decimal256_array, as_dictionary_array,
as_fixed_size_binary_array, as_fixed_size_list_array,
Expand Down Expand Up @@ -1732,18 +1731,16 @@ impl ScalarValue {
scale: i8,
size: usize,
) -> Result<Decimal128Array> {
match value {
Ok(match value {
Some(val) => Decimal128Array::from(vec![val; size])
.with_precision_and_scale(precision, scale)
.map_err(|e| arrow_datafusion_err!(e)),
.with_precision_and_scale(precision, scale)?,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ? automatically will convert the Error types.

None => {
let mut builder = Decimal128Array::builder(size)
.with_precision_and_scale(precision, scale)
.map_err(|e| arrow_datafusion_err!(e))?;
.with_precision_and_scale(precision, scale)?;
builder.append_nulls(size);
Ok(builder.finish())
builder.finish()
}
}
})
}

fn build_decimal256_array(
Expand All @@ -1752,11 +1749,10 @@ impl ScalarValue {
scale: i8,
size: usize,
) -> Result<Decimal256Array> {
std::iter::repeat(value)
Ok(std::iter::repeat(value)
.take(size)
.collect::<Decimal256Array>()
.with_precision_and_scale(precision, scale)
.map_err(|e| arrow_datafusion_err!(e))
.with_precision_and_scale(precision, scale)?)
}

/// Converts `Vec<ScalarValue>` where each element has type corresponding to
Expand Down Expand Up @@ -2146,7 +2142,7 @@ impl ScalarValue {

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

/// Retrieve ScalarValue for each row in `array`
Expand Down
Loading