Skip to content

Apache DataFusion SQL Query Engine

Fix Redundant ScalarValue Boxed Collection (#2523)

compheadc924536c54ea
diff --git a/datafusion/common/src/scalar.rs b/datafusion/common/src/scalar.rs
index 4a7bc5337c..758cc18bb1 100644
--- a/datafusion/common/src/scalar.rs
+++ b/datafusion/common/src/scalar.rs
@@ -73,9 +73,8 @@ pub enum ScalarValue {
Binary(Option<Vec<u8>>),
/// large binary
LargeBinary(Option<Vec<u8>>),
- /// list of nested ScalarValue (boxed to reduce size_of(ScalarValue))
- #[allow(clippy::box_collection)]
- List(Option<Box<Vec<ScalarValue>>>, Box<DataType>),
+ /// list of nested ScalarValue
+ List(Option<Vec<ScalarValue>>, Box<DataType>),
/// Date stored as a signed 32bit int
Date32(Option<i32>),
/// Date stored as a signed 64bit int
@@ -94,9 +93,8 @@ pub enum ScalarValue {
IntervalDayTime(Option<i64>),
/// Interval with MonthDayNano unit
IntervalMonthDayNano(Option<i128>),
- /// struct of nested ScalarValue (boxed to reduce size_of(ScalarValue))
- #[allow(clippy::box_collection)]
- Struct(Option<Box<Vec<ScalarValue>>>, Box<Vec<Field>>),
+ /// struct of nested ScalarValue
+ Struct(Option<Vec<ScalarValue>>, Box<Vec<Field>>),
}
// manual implementation of `PartialEq` that uses OrderedFloat to
@@ -400,7 +398,7 @@ macro_rules! build_list {
)
}
Some(values) => {
- build_values_list!($VALUE_BUILDER_TY, $SCALAR_TY, values.as_ref(), $SIZE)
+ build_values_list!($VALUE_BUILDER_TY, $SCALAR_TY, values, $SIZE)
}
}
}};
@@ -420,37 +418,34 @@ macro_rules! build_timestamp_list {
$SIZE,
)
}
- Some(values) => {
- let values = values.as_ref();
- match $TIME_UNIT {
- TimeUnit::Second => {
- build_values_list_tz!(
- TimestampSecondBuilder,
- TimestampSecond,
- values,
- $SIZE
- )
- }
- TimeUnit::Microsecond => build_values_list_tz!(
- TimestampMillisecondBuilder,
- TimestampMillisecond,
- values,
- $SIZE
- ),
- TimeUnit::Millisecond => build_values_list_tz!(
- TimestampMicrosecondBuilder,
- TimestampMicrosecond,
- values,
- $SIZE
- ),
- TimeUnit::Nanosecond => build_values_list_tz!(
- TimestampNanosecondBuilder,
- TimestampNanosecond,
+ Some(values) => match $TIME_UNIT {
+ TimeUnit::Second => {
+ build_values_list_tz!(
+ TimestampSecondBuilder,
+ TimestampSecond,
values,
$SIZE
- ),
+ )
}
- }
+ TimeUnit::Microsecond => build_values_list_tz!(
+ TimestampMillisecondBuilder,
+ TimestampMillisecond,
+ values,
+ $SIZE
+ ),
+ TimeUnit::Millisecond => build_values_list_tz!(
+ TimestampMicrosecondBuilder,
+ TimestampMicrosecond,
+ values,
+ $SIZE
+ ),
+ TimeUnit::Nanosecond => build_values_list_tz!(
+ TimestampNanosecondBuilder,
+ TimestampNanosecond,
+ values,
+ $SIZE
+ ),
+ },
}
}};
}
@@ -804,7 +799,6 @@ impl ScalarValue {
for scalar in scalars.into_iter() {
match scalar {
ScalarValue::List(Some(xs), _) => {
- let xs = *xs;
for s in xs {
match s {
ScalarValue::$SCALAR_TY(Some(val)) => {
@@ -934,17 +928,17 @@ impl ScalarValue {
match values {
Some(values) => {
// Push value for each field
- for c in 0..columns.len() {
- let column = columns.get_mut(c).unwrap();
- column.push(values[c].clone());
+ for (column, value) in columns.iter_mut().zip(values) {
+ column.push(value.clone());
}
}
None => {
// Push NULL of the appropriate type for each field
- for c in 0..columns.len() {
- let dtype = fields[c].data_type();
- let column = columns.get_mut(c).unwrap();
- column.push(ScalarValue::try_from(dtype)?);
+ for (column, field) in
+ columns.iter_mut().zip(fields.as_ref())
+ {
+ column
+ .push(ScalarValue::try_from(field.data_type())?);
}
}
};
@@ -1022,7 +1016,7 @@ impl ScalarValue {
if let ScalarValue::List(values, _) = scalar {
match values {
Some(values) => {
- let element_array = ScalarValue::iter_to_array(*values)?;
+ let element_array = ScalarValue::iter_to_array(values)?;
// Add new offset index
flat_len += element_array.len() as i32;
@@ -1327,9 +1321,8 @@ impl ScalarValue {
Some(scalar_vec)
}
};
- let value = value.map(Box::new);
- let data_type = Box::new(nested_type.data_type().clone());
- ScalarValue::List(value, data_type)
+ let data_type = nested_type.data_type().clone();
+ ScalarValue::List(value, Box::new(data_type))
}
DataType::Date32 => {
typed_cast!(array, index, Date32Array, Date32)
@@ -1413,7 +1406,7 @@ impl ScalarValue {
let col_scalar = ScalarValue::try_from_array(col_array, index)?;
field_values.push(col_scalar);
}
- Self::Struct(Some(Box::new(field_values)), Box::new(fields.clone()))
+ Self::Struct(Some(field_values), Box::new(fields.clone()))
}
DataType::FixedSizeList(nested_type, _len) => {
let list_array =
@@ -1428,9 +1421,8 @@ impl ScalarValue {
Some(scalar_vec)
}
};
- let value = value.map(Box::new);
- let data_type = Box::new(nested_type.data_type().clone());
- ScalarValue::List(value, data_type)
+ let data_type = nested_type.data_type().clone();
+ ScalarValue::List(value, Box::new(data_type))
}
other => {
return Err(DataFusionError::NotImplemented(format!(
@@ -1635,7 +1627,7 @@ impl From<Vec<(&str, ScalarValue)>> for ScalarValue {
})
.unzip();
- Self::Struct(Some(Box::new(scalars)), Box::new(fields))
+ Self::Struct(Some(scalars), Box::new(fields))
}
}
diff --git a/datafusion/core/src/scalar.rs b/datafusion/core/src/scalar.rs
index ea8fe7ac80..7ec8c53a83 100644
--- a/datafusion/core/src/scalar.rs
+++ b/datafusion/core/src/scalar.rs
@@ -170,11 +170,11 @@ mod tests {
#[test]
fn scalar_list_to_array() {
let list_array_ref = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::UInt64(Some(100)),
ScalarValue::UInt64(None),
ScalarValue::UInt64(Some(101)),
- ])),
+ ]),
Box::new(DataType::UInt64),
)
.to_array();
@@ -611,11 +611,11 @@ mod tests {
assert_eq!(
List(
- Some(Box::new(vec![Int32(Some(1)), Int32(Some(5))])),
+ Some(vec![Int32(Some(1)), Int32(Some(5))]),
Box::new(DataType::Int32),
)
.partial_cmp(&List(
- Some(Box::new(vec![Int32(Some(1)), Int32(Some(5))])),
+ Some(vec![Int32(Some(1)), Int32(Some(5))]),
Box::new(DataType::Int32),
)),
Some(Ordering::Equal)
@@ -623,11 +623,11 @@ mod tests {
assert_eq!(
List(
- Some(Box::new(vec![Int32(Some(10)), Int32(Some(5))])),
+ Some(vec![Int32(Some(10)), Int32(Some(5))]),
Box::new(DataType::Int32),
)
.partial_cmp(&List(
- Some(Box::new(vec![Int32(Some(1)), Int32(Some(5))])),
+ Some(vec![Int32(Some(1)), Int32(Some(5))]),
Box::new(DataType::Int32),
)),
Some(Ordering::Greater)
@@ -635,11 +635,11 @@ mod tests {
assert_eq!(
List(
- Some(Box::new(vec![Int32(Some(1)), Int32(Some(5))])),
+ Some(vec![Int32(Some(1)), Int32(Some(5))]),
Box::new(DataType::Int32),
)
.partial_cmp(&List(
- Some(Box::new(vec![Int32(Some(10)), Int32(Some(5))])),
+ Some(vec![Int32(Some(10)), Int32(Some(5))]),
Box::new(DataType::Int32),
)),
Some(Ordering::Less)
@@ -648,11 +648,11 @@ mod tests {
// For different data type, `partial_cmp` returns None.
assert_eq!(
List(
- Some(Box::new(vec![Int64(Some(1)), Int64(Some(5))])),
+ Some(vec![Int64(Some(1)), Int64(Some(5))]),
Box::new(DataType::Int64),
)
.partial_cmp(&List(
- Some(Box::new(vec![Int32(Some(1)), Int32(Some(5))])),
+ Some(vec![Int32(Some(1)), Int32(Some(5))]),
Box::new(DataType::Int32),
)),
None
@@ -699,7 +699,7 @@ mod tests {
);
let scalar = ScalarValue::Struct(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::Int32(Some(23)),
ScalarValue::Boolean(Some(false)),
ScalarValue::Utf8(Some("Hello".to_string())),
@@ -707,7 +707,7 @@ mod tests {
("e", ScalarValue::from(2i16)),
("f", ScalarValue::from(3i64)),
]),
- ])),
+ ]),
Box::new(vec![
field_a.clone(),
field_b.clone(),
@@ -871,24 +871,21 @@ mod tests {
// Define primitive list scalars
let l0 = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::from(1i32),
ScalarValue::from(2i32),
ScalarValue::from(3i32),
- ])),
+ ]),
Box::new(DataType::Int32),
);
let l1 = ScalarValue::List(
- Some(Box::new(vec![
- ScalarValue::from(4i32),
- ScalarValue::from(5i32),
- ])),
+ Some(vec![ScalarValue::from(4i32), ScalarValue::from(5i32)]),
Box::new(DataType::Int32),
);
let l2 = ScalarValue::List(
- Some(Box::new(vec![ScalarValue::from(6i32)])),
+ Some(vec![ScalarValue::from(6i32)]),
Box::new(DataType::Int32),
);
@@ -933,15 +930,13 @@ mod tests {
// Define list-of-structs scalars
let nl0 = ScalarValue::List(
- Some(Box::new(vec![s0.clone(), s1.clone()])),
+ Some(vec![s0.clone(), s1.clone()]),
Box::new(s0.get_datatype()),
);
- let nl1 =
- ScalarValue::List(Some(Box::new(vec![s2])), Box::new(s0.get_datatype()));
+ let nl1 = ScalarValue::List(Some(vec![s2]), Box::new(s0.get_datatype()));
- let nl2 =
- ScalarValue::List(Some(Box::new(vec![s1])), Box::new(s0.get_datatype()));
+ let nl2 = ScalarValue::List(Some(vec![s1]), Box::new(s0.get_datatype()));
// iter_to_array for list-of-struct
let array = ScalarValue::iter_to_array(vec![nl0, nl1, nl2]).unwrap();
@@ -1085,23 +1080,20 @@ mod tests {
fn test_nested_lists() {
// Define inner list scalars
let l1 = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::from(1i32),
ScalarValue::from(2i32),
ScalarValue::from(3i32),
- ])),
+ ]),
Box::new(DataType::Int32),
),
ScalarValue::List(
- Some(Box::new(vec![
- ScalarValue::from(4i32),
- ScalarValue::from(5i32),
- ])),
+ Some(vec![ScalarValue::from(4i32), ScalarValue::from(5i32)]),
Box::new(DataType::Int32),
),
- ])),
+ ]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
@@ -1110,19 +1102,16 @@ mod tests {
);
let l2 = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::List(
- Some(Box::new(vec![ScalarValue::from(6i32)])),
+ Some(vec![ScalarValue::from(6i32)]),
Box::new(DataType::Int32),
),
ScalarValue::List(
- Some(Box::new(vec![
- ScalarValue::from(7i32),
- ScalarValue::from(8i32),
- ])),
+ Some(vec![ScalarValue::from(7i32), ScalarValue::from(8i32)]),
Box::new(DataType::Int32),
),
- ])),
+ ]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
@@ -1131,10 +1120,10 @@ mod tests {
);
let l3 = ScalarValue::List(
- Some(Box::new(vec![ScalarValue::List(
- Some(Box::new(vec![ScalarValue::from(9i32)])),
+ Some(vec![ScalarValue::List(
+ Some(vec![ScalarValue::from(9i32)]),
Box::new(DataType::Int32),
- )])),
+ )]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
diff --git a/datafusion/core/src/sql/planner.rs b/datafusion/core/src/sql/planner.rs
index b722de5511..cb02c3ed07 100644
--- a/datafusion/core/src/sql/planner.rs
+++ b/datafusion/core/src/sql/planner.rs
@@ -2444,7 +2444,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
let data_type = values[0].get_datatype();
Ok(Expr::Literal(ScalarValue::List(
- Some(Box::new(values)),
+ Some(values),
Box::new(data_type),
)))
}
diff --git a/datafusion/physical-expr/src/aggregate/array_agg.rs b/datafusion/physical-expr/src/aggregate/array_agg.rs
index 3051662ad3..2a40c8bad8 100644
--- a/datafusion/physical-expr/src/aggregate/array_agg.rs
+++ b/datafusion/physical-expr/src/aggregate/array_agg.rs
@@ -133,7 +133,7 @@ impl Accumulator for ArrayAggAccumulator {
(0..arr.len()).try_for_each(|index| {
let scalar = ScalarValue::try_from_array(arr, index)?;
if let ScalarValue::List(Some(values), _) = scalar {
- self.values.extend(*values);
+ self.values.extend(values);
Ok(())
} else {
Err(DataFusionError::Internal(
@@ -149,7 +149,7 @@ impl Accumulator for ArrayAggAccumulator {
fn evaluate(&self) -> Result<ScalarValue> {
Ok(ScalarValue::List(
- Some(Box::new(self.values.clone())),
+ Some(self.values.clone()),
Box::new(self.datatype.clone()),
))
}
@@ -172,13 +172,13 @@ mod tests {
let a: ArrayRef = Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5]));
let list = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::Int32(Some(1)),
ScalarValue::Int32(Some(2)),
ScalarValue::Int32(Some(3)),
ScalarValue::Int32(Some(4)),
ScalarValue::Int32(Some(5)),
- ])),
+ ]),
Box::new(DataType::Int32),
);
@@ -188,23 +188,20 @@ mod tests {
#[test]
fn array_agg_nested() -> Result<()> {
let l1 = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::from(1i32),
ScalarValue::from(2i32),
ScalarValue::from(3i32),
- ])),
+ ]),
Box::new(DataType::Int32),
),
ScalarValue::List(
- Some(Box::new(vec![
- ScalarValue::from(4i32),
- ScalarValue::from(5i32),
- ])),
+ Some(vec![ScalarValue::from(4i32), ScalarValue::from(5i32)]),
Box::new(DataType::Int32),
),
- ])),
+ ]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
@@ -213,19 +210,16 @@ mod tests {
);
let l2 = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::List(
- Some(Box::new(vec![ScalarValue::from(6i32)])),
+ Some(vec![ScalarValue::from(6i32)]),
Box::new(DataType::Int32),
),
ScalarValue::List(
- Some(Box::new(vec![
- ScalarValue::from(7i32),
- ScalarValue::from(8i32),
- ])),
+ Some(vec![ScalarValue::from(7i32), ScalarValue::from(8i32)]),
Box::new(DataType::Int32),
),
- ])),
+ ]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
@@ -234,10 +228,10 @@ mod tests {
);
let l3 = ScalarValue::List(
- Some(Box::new(vec![ScalarValue::List(
- Some(Box::new(vec![ScalarValue::from(9i32)])),
+ Some(vec![ScalarValue::List(
+ Some(vec![ScalarValue::from(9i32)]),
Box::new(DataType::Int32),
- )])),
+ )]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
@@ -246,7 +240,7 @@ mod tests {
);
let list = ScalarValue::List(
- Some(Box::new(vec![l1.clone(), l2.clone(), l3.clone()])),
+ Some(vec![l1.clone(), l2.clone(), l3.clone()]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
diff --git a/datafusion/physical-expr/src/aggregate/array_agg_distinct.rs b/datafusion/physical-expr/src/aggregate/array_agg_distinct.rs
index c67945fb05..9448683c0d 100644
--- a/datafusion/physical-expr/src/aggregate/array_agg_distinct.rs
+++ b/datafusion/physical-expr/src/aggregate/array_agg_distinct.rs
@@ -121,7 +121,7 @@ impl DistinctArrayAggAccumulator {
impl Accumulator for DistinctArrayAggAccumulator {
fn state(&self) -> Result<Vec<ScalarValue>> {
Ok(vec![ScalarValue::List(
- Some(Box::new(self.values.clone().into_iter().collect())),
+ Some(self.values.clone().into_iter().collect()),
Box::new(self.datatype.clone()),
)])
}
@@ -152,7 +152,7 @@ impl Accumulator for DistinctArrayAggAccumulator {
fn evaluate(&self) -> Result<ScalarValue> {
Ok(ScalarValue::List(
- Some(Box::new(self.values.clone().into_iter().collect())),
+ Some(self.values.clone().into_iter().collect()),
Box::new(self.datatype.clone()),
))
}
@@ -207,13 +207,13 @@ mod tests {
let col: ArrayRef = Arc::new(Int32Array::from(vec![1, 2, 7, 4, 5, 2]));
let out = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::Int32(Some(1)),
ScalarValue::Int32(Some(2)),
ScalarValue::Int32(Some(7)),
ScalarValue::Int32(Some(4)),
ScalarValue::Int32(Some(5)),
- ])),
+ ]),
Box::new(DataType::Int32),
);
@@ -224,23 +224,20 @@ mod tests {
fn distinct_array_agg_nested() -> Result<()> {
// [[1, 2, 3], [4, 5]]
let l1 = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::from(1i32),
ScalarValue::from(2i32),
ScalarValue::from(3i32),
- ])),
+ ]),
Box::new(DataType::Int32),
),
ScalarValue::List(
- Some(Box::new(vec![
- ScalarValue::from(4i32),
- ScalarValue::from(5i32),
- ])),
+ Some(vec![ScalarValue::from(4i32), ScalarValue::from(5i32)]),
Box::new(DataType::Int32),
),
- ])),
+ ]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
@@ -250,19 +247,16 @@ mod tests {
// [[6], [7, 8]]
let l2 = ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::List(
- Some(Box::new(vec![ScalarValue::from(6i32)])),
+ Some(vec![ScalarValue::from(6i32)]),
Box::new(DataType::Int32),
),
ScalarValue::List(
- Some(Box::new(vec![
- ScalarValue::from(7i32),
- ScalarValue::from(8i32),
- ])),
+ Some(vec![ScalarValue::from(7i32), ScalarValue::from(8i32)]),
Box::new(DataType::Int32),
),
- ])),
+ ]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
@@ -272,10 +266,10 @@ mod tests {
// [[9]]
let l3 = ScalarValue::List(
- Some(Box::new(vec![ScalarValue::List(
- Some(Box::new(vec![ScalarValue::from(9i32)])),
+ Some(vec![ScalarValue::List(
+ Some(vec![ScalarValue::from(9i32)]),
Box::new(DataType::Int32),
- )])),
+ )]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
@@ -284,7 +278,7 @@ mod tests {
);
let list = ScalarValue::List(
- Some(Box::new(vec![l1.clone(), l2.clone(), l3.clone()])),
+ Some(vec![l1.clone(), l2.clone(), l3.clone()]),
Box::new(DataType::List(Box::new(Field::new(
"item",
DataType::Int32,
diff --git a/datafusion/physical-expr/src/aggregate/count_distinct.rs b/datafusion/physical-expr/src/aggregate/count_distinct.rs
index 5e3b6a2dd5..f1e3afe6b0 100644
--- a/datafusion/physical-expr/src/aggregate/count_distinct.rs
+++ b/datafusion/physical-expr/src/aggregate/count_distinct.rs
@@ -193,7 +193,7 @@ impl Accumulator for DistinctCountAccumulator {
.map(|state_data_type| {
let values = Box::new(Vec::new());
let data_type = Box::new(state_data_type.clone());
- ScalarValue::List(Some(values), data_type)
+ ScalarValue::List(Some(*values), data_type)
})
.collect::<Vec<_>>();
diff --git a/datafusion/physical-expr/src/aggregate/sum_distinct.rs b/datafusion/physical-expr/src/aggregate/sum_distinct.rs
index 2387227265..2b887c1fe5 100644
--- a/datafusion/physical-expr/src/aggregate/sum_distinct.rs
+++ b/datafusion/physical-expr/src/aggregate/sum_distinct.rs
@@ -132,7 +132,7 @@ impl Accumulator for DistinctSumAccumulator {
// 1. Stores aggregate state in `ScalarValue::List`
// 2. Constructs `ScalarValue::List` state from distinct numeric stored in hash set
let state_out = {
- let mut distinct_values = Box::new(Vec::new());
+ let mut distinct_values = Vec::new();
let data_type = Box::new(self.data_type.clone());
self.hash_values
.iter()
diff --git a/datafusion/physical-expr/src/aggregate/tdigest.rs b/datafusion/physical-expr/src/aggregate/tdigest.rs
index 401fd5a239..14d73b5bc0 100644
--- a/datafusion/physical-expr/src/aggregate/tdigest.rs
+++ b/datafusion/physical-expr/src/aggregate/tdigest.rs
@@ -626,7 +626,7 @@ impl TDigest {
ScalarValue::Float64(Some(self.count.into_inner())),
ScalarValue::Float64(Some(self.max.into_inner())),
ScalarValue::Float64(Some(self.min.into_inner())),
- ScalarValue::List(Some(Box::new(centroids)), Box::new(DataType::Float64)),
+ ScalarValue::List(Some(centroids), Box::new(DataType::Float64)),
]
}
diff --git a/datafusion/proto/src/from_proto.rs b/datafusion/proto/src/from_proto.rs
index 1ecb04bda9..0bb767a347 100644
--- a/datafusion/proto/src/from_proto.rs
+++ b/datafusion/proto/src/from_proto.rs
@@ -675,7 +675,7 @@ impl TryFrom<&protobuf::ScalarListValue> for ScalarValue {
})
.collect::<Result<Vec<_>, _>>()?;
ScalarValue::List(
- Some(Box::new(typechecked_values)),
+ Some(typechecked_values),
Box::new(leaf_scalar_type.into()),
)
}
@@ -710,7 +710,7 @@ impl TryFrom<&protobuf::ScalarListValue> for ScalarValue {
ScalarValue::List(
match typechecked_values.len() {
0 => None,
- _ => Some(Box::new(typechecked_values)),
+ _ => Some(typechecked_values),
},
Box::new((list_type).try_into()?),
)
@@ -861,7 +861,7 @@ impl TryFrom<&protobuf::ScalarValue> for ScalarValue {
.map(|val| val.try_into())
.collect::<Result<Vec<_>, _>>()?;
- Self::List(Some(Box::new(typechecked_values)), scalar_type)
+ Self::List(Some(typechecked_values), scalar_type)
}
Value::NullListValue(v) => {
let datatype = v.datatype.as_ref().required("datatype")?;
diff --git a/datafusion/proto/src/lib.rs b/datafusion/proto/src/lib.rs
index dcc18373c8..24809b9aa6 100644
--- a/datafusion/proto/src/lib.rs
+++ b/datafusion/proto/src/lib.rs
@@ -67,21 +67,21 @@ mod roundtrip_tests {
let should_fail_on_seralize: Vec<ScalarValue> = vec![
// Should fail due to inconsistent types
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::Int16(None),
ScalarValue::Float32(Some(32.0)),
- ])),
+ ]),
Box::new(DataType::List(new_box_field("item", DataType::Int16, true))),
),
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::Float32(None),
ScalarValue::Float32(Some(32.0)),
- ])),
+ ]),
Box::new(DataType::List(new_box_field("item", DataType::Int16, true))),
),
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::List(
None,
Box::new(DataType::List(new_box_field(
@@ -91,13 +91,13 @@ mod roundtrip_tests {
))),
),
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::Float32(Some(-213.1)),
ScalarValue::Float32(None),
ScalarValue::Float32(Some(5.5)),
ScalarValue::Float32(Some(2.0)),
ScalarValue::Float32(Some(1.0)),
- ])),
+ ]),
Box::new(DataType::List(new_box_field(
"level2",
DataType::Float32,
@@ -112,7 +112,7 @@ mod roundtrip_tests {
true,
))),
),
- ])),
+ ]),
Box::new(DataType::List(new_box_field(
"level1",
DataType::List(new_box_field("level2", DataType::Float32, true)),
@@ -207,13 +207,13 @@ mod roundtrip_tests {
ScalarValue::TimestampSecond(Some(0), Some("UTC".to_string())),
ScalarValue::TimestampSecond(None, None),
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::Float32(Some(-213.1)),
ScalarValue::Float32(None),
ScalarValue::Float32(Some(5.5)),
ScalarValue::Float32(Some(2.0)),
ScalarValue::Float32(Some(1.0)),
- ])),
+ ]),
Box::new(DataType::List(new_box_field(
"level1",
DataType::Float32,
@@ -221,7 +221,7 @@ mod roundtrip_tests {
))),
),
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::List(
None,
Box::new(DataType::List(new_box_field(
@@ -231,20 +231,20 @@ mod roundtrip_tests {
))),
),
ScalarValue::List(
- Some(Box::new(vec![
+ Some(vec![
ScalarValue::Float32(Some(-213.1)),
ScalarValue::Float32(None),
ScalarValue::Float32(Some(5.5)),
ScalarValue::Float32(Some(2.0)),
ScalarValue::Float32(Some(1.0)),
- ])),
+ ]),
Box::new(DataType::List(new_box_field(
"level2",
DataType::Float32,
true,
))),
),
- ])),
+ ]),
Box::new(DataType::List(new_box_field(
"level1",
DataType::List(new_box_field("level2", DataType::Float32, true)),