Skip to content
Closed
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
18 changes: 5 additions & 13 deletions datafusion/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl ScalarValue {
macro_rules! build_array_primitive {
($ARRAY_TY:ident, $SCALAR_TY:ident) => {{
{
let values = scalars
let array = scalars
.map(|sv| {
if let ScalarValue::$SCALAR_TY(v) = sv {
Ok(*v)
Expand All @@ -356,9 +356,7 @@ impl ScalarValue {
)))
}
})
.collect::<Result<Vec<_>>>()?;

let array: $ARRAY_TY = values.iter().collect();
.collect::<Result<$ARRAY_TY>>()?;
Arc::new(array)
}
}};
Expand All @@ -369,10 +367,10 @@ impl ScalarValue {
macro_rules! build_array_string {
($ARRAY_TY:ident, $SCALAR_TY:ident) => {{
{
let values = scalars
let array = scalars
.map(|sv| {
if let ScalarValue::$SCALAR_TY(v) = sv {
Ok(v)
Ok(v.as_ref())
} else {
Err(DataFusionError::Internal(format!(
"Inconsistent types in ScalarValue::iter_to_array. \
Expand All @@ -381,14 +379,8 @@ impl ScalarValue {
)))
}
})
.collect::<Result<Vec<_>>>()?;

// it is annoying that one can not create
// StringArray et al directly from iter of &String,
// requiring this map to &str
let values = values.iter().map(|s| s.as_ref());
.collect::<Result<$ARRAY_TY>>()?;

let array: $ARRAY_TY = values.collect();
Arc::new(array)
}
}};
Expand Down