Apache DataFusion SQL Query Engine
Add unused_qualifications with deny level to linter. Fix unused_qualifications violations." (#13086)
Daniel Hegbergac79ef3442e6
diff --git a/Cargo.toml b/Cargo.tomlindex e1e3aca771..0a7184ad2d 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -169,3 +169,4 @@ large_futures = "warn"[workspace.lints.rust]unexpected_cfgs = { level = "warn", check-cfg = ["cfg(tarpaulin)"] }+unused_qualifications = "deny"diff --git a/datafusion-examples/examples/advanced_udaf.rs b/datafusion-examples/examples/advanced_udaf.rsindex 1259f90d64..414596bdc6 100644--- a/datafusion-examples/examples/advanced_udaf.rs+++ b/datafusion-examples/examples/advanced_udaf.rs@@ -193,7 +193,7 @@ impl Accumulator for GeometricMean {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}@@ -394,8 +394,8 @@ impl GroupsAccumulator for GeometricMeanGroupsAccumulator {}fn size(&self) -> usize {- self.counts.capacity() * std::mem::size_of::<u32>()- + self.prods.capacity() * std::mem::size_of::<Float64Type>()+ self.counts.capacity() * size_of::<u32>()+ + self.prods.capacity() * size_of::<Float64Type>()}}diff --git a/datafusion-examples/examples/custom_datasource.rs b/datafusion-examples/examples/custom_datasource.rsindex 0f7748b133..7440e59296 100644--- a/datafusion-examples/examples/custom_datasource.rs+++ b/datafusion-examples/examples/custom_datasource.rs@@ -110,7 +110,7 @@ struct CustomDataSourceInner {}impl Debug for CustomDataSource {- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {f.write_str("custom_db")}}@@ -220,7 +220,7 @@ impl CustomExec {}impl DisplayAs for CustomExec {- fn fmt_as(&self, _t: DisplayFormatType, f: &mut fmt::Formatter) -> std::fmt::Result {+ fn fmt_as(&self, _t: DisplayFormatType, f: &mut Formatter) -> fmt::Result {write!(f, "CustomExec")}}diff --git a/datafusion-examples/examples/custom_file_format.rs b/datafusion-examples/examples/custom_file_format.rsindex b85127d42f..95168597eb 100644--- a/datafusion-examples/examples/custom_file_format.rs+++ b/datafusion-examples/examples/custom_file_format.rs@@ -74,10 +74,7 @@ impl FileFormat for TSVFileFormat {"tsv".to_string()}- fn get_ext_with_compression(- &self,- c: &FileCompressionType,- ) -> datafusion::error::Result<String> {+ fn get_ext_with_compression(&self, c: &FileCompressionType) -> Result<String> {if c == &FileCompressionType::UNCOMPRESSED {Ok("tsv".to_string())} else {diff --git a/datafusion-examples/examples/flight/flight_server.rs b/datafusion-examples/examples/flight/flight_server.rsindex f9d1b8029f..cc5f43746d 100644--- a/datafusion-examples/examples/flight/flight_server.rs+++ b/datafusion-examples/examples/flight/flight_server.rs@@ -105,7 +105,7 @@ impl FlightService for FlightServiceImpl {}// add an initial FlightData message that sends schema- let options = datafusion::arrow::ipc::writer::IpcWriteOptions::default();+ let options = arrow::ipc::writer::IpcWriteOptions::default();let schema_flight_data = SchemaAsIpc::new(&schema, &options);let mut flights = vec![FlightData::from(schema_flight_data)];diff --git a/datafusion-examples/examples/function_factory.rs b/datafusion-examples/examples/function_factory.rsindex f57b3bf604..b42f25437d 100644--- a/datafusion-examples/examples/function_factory.rs+++ b/datafusion-examples/examples/function_factory.rs@@ -121,7 +121,7 @@ impl ScalarUDFImpl for ScalarFunctionWrapper {&self.name}- fn signature(&self) -> &datafusion_expr::Signature {+ fn signature(&self) -> &Signature {&self.signature}diff --git a/datafusion-examples/examples/simple_udaf.rs b/datafusion-examples/examples/simple_udaf.rsindex 140fc0d357..ef97bf9763 100644--- a/datafusion-examples/examples/simple_udaf.rs+++ b/datafusion-examples/examples/simple_udaf.rs@@ -131,7 +131,7 @@ impl Accumulator for GeometricMean {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}diff --git a/datafusion-examples/examples/simplify_udaf_expression.rs b/datafusion-examples/examples/simplify_udaf_expression.rsindex aedc511c62..52a27317e3 100644--- a/datafusion-examples/examples/simplify_udaf_expression.rs+++ b/datafusion-examples/examples/simplify_udaf_expression.rs@@ -70,7 +70,7 @@ impl AggregateUDFImpl for BetterAvgUdaf {unimplemented!("should not be invoked")}- fn state_fields(&self, _args: StateFieldsArgs) -> Result<Vec<arrow_schema::Field>> {+ fn state_fields(&self, _args: StateFieldsArgs) -> Result<Vec<Field>> {unimplemented!("should not be invoked")}@@ -90,8 +90,7 @@ impl AggregateUDFImpl for BetterAvgUdaf {fn simplify(&self) -> Option<AggregateFunctionSimplification> {// as an example for this functionality we replace UDF function// with build-in aggregate function to illustrate the use- let simplify = |aggregate_function: datafusion_expr::expr::AggregateFunction,- _: &dyn SimplifyInfo| {+ let simplify = |aggregate_function: AggregateFunction, _: &dyn SimplifyInfo| {Ok(Expr::AggregateFunction(AggregateFunction::new_udf(avg_udaf(),// yes it is the same Avg, `BetterAvgUdaf` was just adiff --git a/datafusion-examples/examples/simplify_udwf_expression.rs b/datafusion-examples/examples/simplify_udwf_expression.rsindex d95f1147bc..117063df4e 100644--- a/datafusion-examples/examples/simplify_udwf_expression.rs+++ b/datafusion-examples/examples/simplify_udwf_expression.rs@@ -70,8 +70,7 @@ impl WindowUDFImpl for SimplifySmoothItUdf {/// this function will simplify `SimplifySmoothItUdf` to `SmoothItUdf`.fn simplify(&self) -> Option<WindowFunctionSimplification> {- let simplify = |window_function: datafusion_expr::expr::WindowFunction,- _: &dyn SimplifyInfo| {+ let simplify = |window_function: WindowFunction, _: &dyn SimplifyInfo| {Ok(Expr::WindowFunction(WindowFunction {fun: datafusion_expr::WindowFunctionDefinition::AggregateUDF(avg_udaf()),args: window_function.args,diff --git a/datafusion/common/src/config.rs b/datafusion/common/src/config.rsindex 33e5184d2c..15290204fb 100644--- a/datafusion/common/src/config.rs+++ b/datafusion/common/src/config.rs@@ -876,7 +876,7 @@ pub trait ConfigExtension: ExtensionOptions {}/// An object-safe API for storing arbitrary configuration-pub trait ExtensionOptions: Send + Sync + std::fmt::Debug + 'static {+pub trait ExtensionOptions: Send + Sync + fmt::Debug + 'static {/// Return `self` as [`Any`]////// This is needed until trait upcasting is stabiliseddiff --git a/datafusion/common/src/join_type.rs b/datafusion/common/src/join_type.rsindex fbdae1c50a..d502e7836d 100644--- a/datafusion/common/src/join_type.rs+++ b/datafusion/common/src/join_type.rs@@ -97,7 +97,7 @@ pub enum JoinConstraint {}impl Display for JoinSide {- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {match self {JoinSide::Left => write!(f, "left"),JoinSide::Right => write!(f, "right"),diff --git a/datafusion/common/src/parsers.rs b/datafusion/common/src/parsers.rsindex e23edb4e2a..c73c8a55f1 100644--- a/datafusion/common/src/parsers.rs+++ b/datafusion/common/src/parsers.rs@@ -18,7 +18,6 @@//! Interval parsing logicuse std::fmt::Display;-use std::result;use std::str::FromStr;use sqlparser::parser::ParserError;@@ -41,7 +40,7 @@ pub enum CompressionTypeVariant {impl FromStr for CompressionTypeVariant {type Err = ParserError;- fn from_str(s: &str) -> result::Result<Self, ParserError> {+ fn from_str(s: &str) -> Result<Self, ParserError> {let s = s.to_uppercase();match s.as_str() {"GZIP" | "GZ" => Ok(Self::GZIP),diff --git a/datafusion/common/src/pyarrow.rs b/datafusion/common/src/pyarrow.rsindex 87254a499f..bdcf831c78 100644--- a/datafusion/common/src/pyarrow.rs+++ b/datafusion/common/src/pyarrow.rs@@ -34,7 +34,7 @@ impl From<DataFusionError> for PyErr {}impl FromPyArrow for ScalarValue {- fn from_pyarrow_bound(value: &pyo3::Bound<'_, pyo3::PyAny>) -> PyResult<Self> {+ fn from_pyarrow_bound(value: &Bound<'_, PyAny>) -> PyResult<Self> {let py = value.py();let typ = value.getattr("type")?;let val = value.call_method0("as_py")?;diff --git a/datafusion/common/src/scalar/mod.rs b/datafusion/common/src/scalar/mod.rsindex f609e9f9ef..7a1eaa2ad6 100644--- a/datafusion/common/src/scalar/mod.rs+++ b/datafusion/common/src/scalar/mod.rs@@ -28,6 +28,7 @@ use std::fmt;use std::hash::Hash;use std::hash::Hasher;use std::iter::repeat;+use std::mem::{size_of, size_of_val};use std::str::FromStr;use std::sync::Arc;@@ -691,8 +692,8 @@ hash_float_value!((f64, u64), (f32, u32));// # Panics//// Panics if there is an error when creating hash values for rows-impl std::hash::Hash for ScalarValue {- fn hash<H: std::hash::Hasher>(&self, state: &mut H) {+impl Hash for ScalarValue {+ fn hash<H: Hasher>(&self, state: &mut H) {use ScalarValue::*;match self {Decimal128(v, p, s) => {@@ -768,7 +769,7 @@ impl std::hash::Hash for ScalarValue {}}-fn hash_nested_array<H: std::hash::Hasher>(arr: ArrayRef, state: &mut H) {+fn hash_nested_array<H: Hasher>(arr: ArrayRef, state: &mut H) {let arrays = vec![arr.to_owned()];let hashes_buffer = &mut vec![0; arr.len()];let random_state = ahash::RandomState::with_seeds(0, 0, 0, 0);@@ -802,7 +803,7 @@ fn dict_from_scalar<K: ArrowDictionaryKeyType>(let values_array = value.to_array_of_size(1)?;// Create a key array with `size` elements, each of 0- let key_array: PrimitiveArray<K> = std::iter::repeat(if value.is_null() {+ let key_array: PrimitiveArray<K> = repeat(if value.is_null() {None} else {Some(K::default_value())@@ -2043,7 +2044,7 @@ impl ScalarValue {scale: i8,size: usize,) -> Result<Decimal256Array> {- Ok(std::iter::repeat(value)+ Ok(repeat(value).take(size).collect::<Decimal256Array>().with_precision_and_scale(precision, scale)?)@@ -2512,7 +2513,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<_>>();+ let arrays = repeat(arr).take(size).collect::<Vec<_>>();let ret = match !arrays.is_empty() {true => arrow::compute::concat(arrays.as_slice())?,false => arr.slice(0, 0),@@ -3083,7 +3084,7 @@ impl ScalarValue {/// Estimate size if bytes including `Self`. For values with internal containers such as `String`/// includes the allocated size (`capacity`) rather than the current length (`len`)pub fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)+ match self {ScalarValue::Null| ScalarValue::Boolean(_)@@ -3137,12 +3138,12 @@ impl ScalarValue {ScalarValue::Map(arr) => arr.get_array_memory_size(),ScalarValue::Union(vals, fields, _mode) => {vals.as_ref()- .map(|(_id, sv)| sv.size() - std::mem::size_of_val(sv))+ .map(|(_id, sv)| sv.size() - size_of_val(sv)).unwrap_or_default()// `fields` is boxed, so it is NOT already included in `self`- + std::mem::size_of_val(fields)- + (std::mem::size_of::<Field>() * fields.len())- + fields.iter().map(|(_idx, field)| field.size() - std::mem::size_of_val(field)).sum::<usize>()+ + size_of_val(fields)+ + (size_of::<Field>() * fields.len())+ + fields.iter().map(|(_idx, field)| field.size() - size_of_val(field)).sum::<usize>()}ScalarValue::Dictionary(dt, sv) => {// `dt` and `sv` are boxed, so they are NOT already included in `self`@@ -3155,11 +3156,11 @@ impl ScalarValue {////// Includes the size of the [`Vec`] container itself.pub fn size_of_vec(vec: &Vec<Self>) -> usize {- std::mem::size_of_val(vec)- + (std::mem::size_of::<ScalarValue>() * vec.capacity())+ size_of_val(vec)+ + (size_of::<ScalarValue>() * vec.capacity())+ vec.iter()- .map(|sv| sv.size() - std::mem::size_of_val(sv))+ .map(|sv| sv.size() - size_of_val(sv)).sum::<usize>()}@@ -3167,11 +3168,11 @@ impl ScalarValue {////// Includes the size of the [`VecDeque`] container itself.pub fn size_of_vec_deque(vec_deque: &VecDeque<Self>) -> usize {- std::mem::size_of_val(vec_deque)- + (std::mem::size_of::<ScalarValue>() * vec_deque.capacity())+ size_of_val(vec_deque)+ + (size_of::<ScalarValue>() * vec_deque.capacity())+ vec_deque.iter()- .map(|sv| sv.size() - std::mem::size_of_val(sv))+ .map(|sv| sv.size() - size_of_val(sv)).sum::<usize>()}@@ -3179,11 +3180,11 @@ impl ScalarValue {////// Includes the size of the [`HashSet`] container itself.pub fn size_of_hashset<S>(set: &HashSet<Self, S>) -> usize {- std::mem::size_of_val(set)- + (std::mem::size_of::<ScalarValue>() * set.capacity())+ size_of_val(set)+ + (size_of::<ScalarValue>() * set.capacity())+ set.iter()- .map(|sv| sv.size() - std::mem::size_of_val(sv))+ .map(|sv| sv.size() - size_of_val(sv)).sum::<usize>()}}@@ -4445,7 +4446,7 @@ mod tests {let right_array = right.to_array().expect("Failed to convert to array");let arrow_left_array = left_array.as_primitive::<T>();let arrow_right_array = right_array.as_primitive::<T>();- let arrow_result = kernels::numeric::add(arrow_left_array, arrow_right_array);+ let arrow_result = add(arrow_left_array, arrow_right_array);assert_eq!(scalar_result.is_ok(), arrow_result.is_ok());}@@ -5060,13 +5061,13 @@ mod tests {// thus the size of the enum appears to as well// The value may also change depending on rust version- assert_eq!(std::mem::size_of::<ScalarValue>(), 64);+ assert_eq!(size_of::<ScalarValue>(), 64);}#[test]fn memory_size() {let sv = ScalarValue::Binary(Some(Vec::with_capacity(10)));- assert_eq!(sv.size(), std::mem::size_of::<ScalarValue>() + 10,);+ assert_eq!(sv.size(), size_of::<ScalarValue>() + 10,);let sv_size = sv.size();let mut v = Vec::with_capacity(10);@@ -5075,9 +5076,7 @@ mod tests {assert_eq!(v.capacity(), 10);assert_eq!(ScalarValue::size_of_vec(&v),- std::mem::size_of::<Vec<ScalarValue>>()- + (9 * std::mem::size_of::<ScalarValue>())- + sv_size,+ size_of::<Vec<ScalarValue>>() + (9 * size_of::<ScalarValue>()) + sv_size,);let mut s = HashSet::with_capacity(0);@@ -5087,8 +5086,8 @@ mod tests {let s_capacity = s.capacity();assert_eq!(ScalarValue::size_of_hashset(&s),- std::mem::size_of::<HashSet<ScalarValue>>()- + ((s_capacity - 1) * std::mem::size_of::<ScalarValue>())+ size_of::<HashSet<ScalarValue>>()+ + ((s_capacity - 1) * size_of::<ScalarValue>())+ sv_size,);}diff --git a/datafusion/common/src/stats.rs b/datafusion/common/src/stats.rsindex d8e62b3045..e669c674f7 100644--- a/datafusion/common/src/stats.rs+++ b/datafusion/common/src/stats.rs@@ -190,7 +190,7 @@ impl Precision<ScalarValue> {}}-impl<T: fmt::Debug + Clone + PartialEq + Eq + PartialOrd> Debug for Precision<T> {+impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> Debug for Precision<T> {fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {match self {Precision::Exact(inner) => write!(f, "Exact({:?})", inner),@@ -200,7 +200,7 @@ impl<T: fmt::Debug + Clone + PartialEq + Eq + PartialOrd> Debug for Precision<T>}}-impl<T: fmt::Debug + Clone + PartialEq + Eq + PartialOrd> Display for Precision<T> {+impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> Display for Precision<T> {fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {match self {Precision::Exact(inner) => write!(f, "Exact({:?})", inner),@@ -341,7 +341,7 @@ fn check_num_rows(value: Option<usize>, is_exact: bool) -> Precision<usize> {}impl Display for Statistics {- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {// string of column statisticslet column_stats = self.column_statisticsdiff --git a/datafusion/common/src/utils/memory.rs b/datafusion/common/src/utils/memory.rsindex 2c34b61bd0..d5ce59e342 100644--- a/datafusion/common/src/utils/memory.rs+++ b/datafusion/common/src/utils/memory.rs@@ -18,6 +18,7 @@//! This module provides a function to estimate the memory size of a HashTable prior to alloactionuse crate::{DataFusionError, Result};+use std::mem::size_of;/// Estimates the memory size required for a hash table prior to allocation.///@@ -87,7 +88,7 @@ pub fn estimate_memory_size<T>(num_elements: usize, fixed_size: usize) -> Result// + size of entry * number of buckets// + 1 byte for each bucket// + fixed size of collection (HashSet/HashTable)- std::mem::size_of::<T>()+ size_of::<T>().checked_mul(estimated_buckets)?.checked_add(estimated_buckets)?.checked_add(fixed_size)@@ -108,7 +109,7 @@ mod tests {#[test]fn test_estimate_memory() {// size (bytes): 48- let fixed_size = std::mem::size_of::<HashSet<u32>>();+ let fixed_size = size_of::<HashSet<u32>>();// estimated buckets: 16 = (8 * 8 / 7).next_power_of_two()let num_elements = 8;@@ -126,7 +127,7 @@ mod tests {#[test]fn test_estimate_memory_overflow() {let num_elements = usize::MAX;- let fixed_size = std::mem::size_of::<HashSet<u32>>();+ let fixed_size = size_of::<HashSet<u32>>();let estimated = estimate_memory_size::<u32>(num_elements, fixed_size);assert!(estimated.is_err());diff --git a/datafusion/common/src/utils/proxy.rs b/datafusion/common/src/utils/proxy.rsindex d68b5e3543..5d14a15171 100644--- a/datafusion/common/src/utils/proxy.rs+++ b/datafusion/common/src/utils/proxy.rs@@ -18,6 +18,7 @@//! [`VecAllocExt`] and [`RawTableAllocExt`] to help tracking of memory allocationsuse hashbrown::raw::{Bucket, RawTable};+use std::mem::size_of;/// Extension trait for [`Vec`] to account for allocations.pub trait VecAllocExt {@@ -93,7 +94,7 @@ impl<T> VecAllocExt for Vec<T> {let new_capacity = self.capacity();if new_capacity > prev_capacty {// capacity changed, so we allocated more- let bump_size = (new_capacity - prev_capacty) * std::mem::size_of::<T>();+ let bump_size = (new_capacity - prev_capacty) * size_of::<T>();// Note multiplication should never overflow because `push` would// have panic'd first, but the checked_add could potentially// overflow since accounting could be tracking additional values, and@@ -102,7 +103,7 @@ impl<T> VecAllocExt for Vec<T> {}}fn allocated_size(&self) -> usize {- std::mem::size_of::<T>() * self.capacity()+ size_of::<T>() * self.capacity()}}@@ -157,7 +158,7 @@ impl<T> RawTableAllocExt for RawTable<T> {// need to request more memorylet bump_elements = self.capacity().max(16);- let bump_size = bump_elements * std::mem::size_of::<T>();+ let bump_size = bump_elements * size_of::<T>();*accounting = (*accounting).checked_add(bump_size).expect("overflow");self.reserve(bump_elements, hasher);diff --git a/datafusion/core/benches/parquet_query_sql.rs b/datafusion/core/benches/parquet_query_sql.rsindex bc42987860..f82a126c56 100644--- a/datafusion/core/benches/parquet_query_sql.rs+++ b/datafusion/core/benches/parquet_query_sql.rs@@ -249,7 +249,7 @@ fn criterion_benchmark(c: &mut Criterion) {}// Temporary file must outlive the benchmarks, it is deleted when dropped- std::mem::drop(temp_file);+ drop(temp_file);}criterion_group!(benches, criterion_benchmark);diff --git a/datafusion/core/src/dataframe/mod.rs b/datafusion/core/src/dataframe/mod.rsindex d1d49bfaa6..e5d352a63c 100644--- a/datafusion/core/src/dataframe/mod.rs+++ b/datafusion/core/src/dataframe/mod.rs@@ -1941,12 +1941,12 @@ mod tests {use crate::physical_plan::{ColumnarValue, Partitioning, PhysicalExpr};use crate::test_util::{register_aggregate_csv, test_table, test_table_with_name};- use arrow::array::{self, Int32Array};+ use arrow::array::Int32Array;use datafusion_common::{assert_batches_eq, Constraint, Constraints, ScalarValue};use datafusion_common_runtime::SpawnedTask;use datafusion_expr::expr::WindowFunction;use datafusion_expr::{- cast, create_udf, expr, lit, BuiltInWindowFunction, ExprFunctionExt,+ cast, create_udf, lit, BuiltInWindowFunction, ExprFunctionExt,ScalarFunctionImplementation, Volatility, WindowFrame, WindowFrameBound,WindowFrameUnits, WindowFunctionDefinition,};@@ -1979,8 +1979,8 @@ mod tests {let batch = RecordBatch::try_new(dual_schema.clone(),vec![- Arc::new(array::Int32Array::from(vec![1])),- Arc::new(array::StringArray::from(vec!["a"])),+ Arc::new(Int32Array::from(vec![1])),+ Arc::new(StringArray::from(vec!["a"])),],).unwrap();@@ -2176,7 +2176,7 @@ mod tests {async fn select_with_window_exprs() -> Result<()> {// build plan using Table APIlet t = test_table().await?;- let first_row = Expr::WindowFunction(expr::WindowFunction::new(+ let first_row = Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::BuiltInWindowFunction(BuiltInWindowFunction::FirstValue,),@@ -3570,11 +3570,10 @@ mod tests {#[tokio::test]async fn with_column_renamed_case_sensitive() -> Result<()> {- let config =- SessionConfig::from_string_hash_map(&std::collections::HashMap::from([(- "datafusion.sql_parser.enable_ident_normalization".to_owned(),- "false".to_owned(),- )]))?;+ let config = SessionConfig::from_string_hash_map(&HashMap::from([(+ "datafusion.sql_parser.enable_ident_normalization".to_owned(),+ "false".to_owned(),+ )]))?;let ctx = SessionContext::new_with_config(config);let name = "aggregate_test_100";register_aggregate_csv(&ctx, name).await?;@@ -3646,7 +3645,7 @@ mod tests {#[tokio::test]async fn row_writer_resize_test() -> Result<()> {- let schema = Arc::new(Schema::new(vec![arrow::datatypes::Field::new(+ let schema = Arc::new(Schema::new(vec![Field::new("column_1",DataType::Utf8,false,@@ -3655,7 +3654,7 @@ mod tests {let data = RecordBatch::try_new(schema,vec![- Arc::new(arrow::array::StringArray::from(vec![+ Arc::new(StringArray::from(vec![Some("2a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),Some("3a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800"),]))diff --git a/datafusion/core/src/datasource/avro_to_arrow/arrow_array_reader.rs b/datafusion/core/src/datasource/avro_to_arrow/arrow_array_reader.rsindex 98b6702bc3..9f089c7c0c 100644--- a/datafusion/core/src/datasource/avro_to_arrow/arrow_array_reader.rs+++ b/datafusion/core/src/datasource/avro_to_arrow/arrow_array_reader.rs@@ -206,7 +206,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {fn build_primitive_array<T>(&self, rows: RecordSlice, col_name: &str) -> ArrayRefwhereT: ArrowNumericType + Resolver,- T::Native: num_traits::cast::NumCast,+ T::Native: NumCast,{Arc::new(rows.iter()@@ -354,7 +354,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {let builder = builder.as_any_mut().downcast_mut::<ListBuilder<StringBuilder>>()- .ok_or_else(||ArrowError::SchemaError(+ .ok_or_else(||SchemaError("Cast failed for ListBuilder<StringBuilder> during nested data parsing".to_string(),))?;for val in vals {@@ -369,7 +369,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {builder.append(true);}DataType::Dictionary(_, _) => {- let builder = builder.as_any_mut().downcast_mut::<ListBuilder<StringDictionaryBuilder<D>>>().ok_or_else(||ArrowError::SchemaError(+ let builder = builder.as_any_mut().downcast_mut::<ListBuilder<StringDictionaryBuilder<D>>>().ok_or_else(||SchemaError("Cast failed for ListBuilder<StringDictionaryBuilder> during nested data parsing".to_string(),))?;for val in vals {@@ -402,7 +402,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {col_name: &str,) -> ArrowResult<ArrayRef>where- T::Native: num_traits::cast::NumCast,+ T::Native: NumCast,T: ArrowPrimitiveType + ArrowDictionaryKeyType,{let mut builder: StringDictionaryBuilder<T> =@@ -453,12 +453,10 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {DataType::UInt64 => {self.build_dictionary_array::<UInt64Type>(rows, col_name)}- _ => Err(ArrowError::SchemaError(- "unsupported dictionary key type".to_string(),- )),+ _ => Err(SchemaError("unsupported dictionary key type".to_string())),}} else {- Err(ArrowError::SchemaError(+ Err(SchemaError("dictionary types other than UTF-8 not yet supported".to_string(),))}@@ -532,7 +530,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {DataType::UInt32 => self.read_primitive_list_values::<UInt32Type>(rows),DataType::UInt64 => self.read_primitive_list_values::<UInt64Type>(rows),DataType::Float16 => {- return Err(ArrowError::SchemaError("Float16 not supported".to_string()))+ return Err(SchemaError("Float16 not supported".to_string()))}DataType::Float32 => self.read_primitive_list_values::<Float32Type>(rows),DataType::Float64 => self.read_primitive_list_values::<Float64Type>(rows),@@ -541,7 +539,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {| DataType::Date64| DataType::Time32(_)| DataType::Time64(_) => {- return Err(ArrowError::SchemaError(+ return Err(SchemaError("Temporal types are not yet supported, see ARROW-4803".to_string(),))}@@ -623,7 +621,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {.unwrap()}datatype => {- return Err(ArrowError::SchemaError(format!(+ return Err(SchemaError(format!("Nested list of {datatype:?} not supported")));}@@ -737,7 +735,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {&field_path,),t => {- return Err(ArrowError::SchemaError(format!(+ return Err(SchemaError(format!("TimeUnit {t:?} not supported with Time64")))}@@ -751,7 +749,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {&field_path,),t => {- return Err(ArrowError::SchemaError(format!(+ return Err(SchemaError(format!("TimeUnit {t:?} not supported with Time32")))}@@ -854,7 +852,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {make_array(data)}_ => {- return Err(ArrowError::SchemaError(format!(+ return Err(SchemaError(format!("type {:?} not supported",field.data_type())))@@ -870,7 +868,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> {fn read_primitive_list_values<T>(&self, rows: &[&Value]) -> ArrayDatawhereT: ArrowPrimitiveType + ArrowNumericType,- T::Native: num_traits::cast::NumCast,+ T::Native: NumCast,{let values = rows.iter()@@ -970,7 +968,7 @@ fn resolve_u8(v: &Value) -> AvroResult<u8> {other => Err(AvroError::GetU8(other.into())),}?;if let Value::Int(n) = int {- if n >= 0 && n <= std::convert::From::from(u8::MAX) {+ if n >= 0 && n <= From::from(u8::MAX) {return Ok(n as u8);}}@@ -1048,7 +1046,7 @@ fn maybe_resolve_union(value: &Value) -> &Value {impl<N> Resolver for NwhereN: ArrowNumericType,- N::Native: num_traits::cast::NumCast,+ N::Native: NumCast,{fn resolve(value: &Value) -> Option<Self::Native> {let value = maybe_resolve_union(value);diff --git a/datafusion/core/src/datasource/avro_to_arrow/mod.rs b/datafusion/core/src/datasource/avro_to_arrow/mod.rsindex c59078c89d..71184a78c9 100644--- a/datafusion/core/src/datasource/avro_to_arrow/mod.rs+++ b/datafusion/core/src/datasource/avro_to_arrow/mod.rs@@ -39,7 +39,7 @@ use std::io::Read;pub fn read_avro_schema_from_reader<R: Read>(reader: &mut R) -> Result<Schema> {let avro_reader = apache_avro::Reader::new(reader)?;let schema = avro_reader.writer_schema();- schema::to_arrow_schema(schema)+ to_arrow_schema(schema)}#[cfg(not(feature = "avro"))]diff --git a/datafusion/core/src/datasource/file_format/csv.rs b/datafusion/core/src/datasource/file_format/csv.rsindex f235c3b628..3cb5ae4f85 100644--- a/datafusion/core/src/datasource/file_format/csv.rs+++ b/datafusion/core/src/datasource/file_format/csv.rs@@ -78,7 +78,7 @@ impl CsvFormatFactory {}}-impl fmt::Debug for CsvFormatFactory {+impl Debug for CsvFormatFactory {fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {f.debug_struct("CsvFormatFactory").field("options", &self.options)@@ -968,7 +968,7 @@ mod tests {limit: Option<usize>,has_header: bool,) -> Result<Arc<dyn ExecutionPlan>> {- let root = format!("{}/csv", crate::test_util::arrow_test_data());+ let root = format!("{}/csv", arrow_test_data());let format = CsvFormat::default().with_has_header(has_header);scan_format(state, &format, &root, file_name, projection, limit).await}diff --git a/datafusion/core/src/datasource/file_format/json.rs b/datafusion/core/src/datasource/file_format/json.rsindex c9ed0c0d28..fd97da5216 100644--- a/datafusion/core/src/datasource/file_format/json.rs+++ b/datafusion/core/src/datasource/file_format/json.rs@@ -118,7 +118,7 @@ impl GetExt for JsonFormatFactory {}}-impl fmt::Debug for JsonFormatFactory {+impl Debug for JsonFormatFactory {fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {f.debug_struct("JsonFormatFactory").field("options", &self.options)diff --git a/datafusion/core/src/datasource/file_format/mod.rs b/datafusion/core/src/datasource/file_format/mod.rsindex a313a7a9bc..24f1111517 100644--- a/datafusion/core/src/datasource/file_format/mod.rs+++ b/datafusion/core/src/datasource/file_format/mod.rs@@ -79,7 +79,7 @@ pub trait FileFormatFactory: Sync + Send + GetExt + Debug {////// [`TableProvider`]: crate::catalog::TableProvider#[async_trait]-pub trait FileFormat: Send + Sync + fmt::Debug {+pub trait FileFormat: Send + Sync + Debug {/// Returns the table provider as [`Any`](std::any::Any) so that it can be/// downcast to a specific implementation.fn as_any(&self) -> &dyn Any;@@ -224,7 +224,7 @@ pub fn format_as_file_type(/// downcasted to a [DefaultFileType].pub fn file_type_to_format(file_type: &Arc<dyn FileType>,-) -> datafusion_common::Result<Arc<dyn FileFormatFactory>> {+) -> Result<Arc<dyn FileFormatFactory>> {match file_type.as_ref().as_any()@@ -447,8 +447,8 @@ pub(crate) mod test_util {iterations_detected: Arc<Mutex<usize>>,}- impl std::fmt::Display for VariableStream {- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ impl Display for VariableStream {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {write!(f, "VariableStream")}}diff --git a/datafusion/core/src/datasource/file_format/parquet.rs b/datafusion/core/src/datasource/file_format/parquet.rsindex 2d45c76ce9..9153e71a5c 100644--- a/datafusion/core/src/datasource/file_format/parquet.rs+++ b/datafusion/core/src/datasource/file_format/parquet.rs@@ -165,7 +165,7 @@ impl GetExt for ParquetFormatFactory {}}-impl fmt::Debug for ParquetFormatFactory {+impl Debug for ParquetFormatFactory {fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {f.debug_struct("ParquetFormatFactory").field("ParquetFormatFactory", &self.options)@@ -1439,7 +1439,7 @@ mod tests {}impl Display for RequestCountingObjectStore {- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {write!(f, "RequestCounting({})", self.inner)}}@@ -1707,7 +1707,7 @@ mod tests {let null_utf8 = if force_views {ScalarValue::Utf8View(None)} else {- ScalarValue::Utf8(None)+ Utf8(None)};// Fetch statistics for first file@@ -1720,7 +1720,7 @@ mod tests {let expected_type = if force_views {ScalarValue::Utf8View} else {- ScalarValue::Utf8+ Utf8};assert_eq!(c1_stats.max_value,diff --git a/datafusion/core/src/datasource/file_format/write/demux.rs b/datafusion/core/src/datasource/file_format/write/demux.rsindex 427b28db40..1746ffef82 100644--- a/datafusion/core/src/datasource/file_format/write/demux.rs+++ b/datafusion/core/src/datasource/file_format/write/demux.rs@@ -280,9 +280,8 @@ async fn hive_style_partitions_demuxer(Some(part_tx) => part_tx,None => {// Create channel for previously unseen distinct partition key and notify consumer of new file- let (part_tx, part_rx) = tokio::sync::mpsc::channel::<RecordBatch>(- max_buffered_recordbatches,- );+ let (part_tx, part_rx) =+ mpsc::channel::<RecordBatch>(max_buffered_recordbatches);let file_path = compute_hive_style_file_path(&part_key,&partition_by,diff --git a/datafusion/core/src/datasource/listing_table_factory.rs b/datafusion/core/src/datasource/listing_table_factory.rsindex 701a13477b..581d88d258 100644--- a/datafusion/core/src/datasource/listing_table_factory.rs+++ b/datafusion/core/src/datasource/listing_table_factory.rs@@ -91,7 +91,7 @@ impl TableProviderFactory for ListingTableFactory {.field_with_name(col).map_err(|e| arrow_datafusion_err!(e))})- .collect::<datafusion_common::Result<Vec<_>>>()?+ .collect::<Result<Vec<_>>>()?.into_iter().map(|f| (f.name().to_owned(), f.data_type().to_owned())).collect();diff --git a/datafusion/core/src/datasource/physical_plan/csv.rs b/datafusion/core/src/datasource/physical_plan/csv.rsindex 6cd1864deb..5beffc3b05 100644--- a/datafusion/core/src/datasource/physical_plan/csv.rs+++ b/datafusion/core/src/datasource/physical_plan/csv.rs@@ -1216,7 +1216,7 @@ mod tests {let session_ctx = SessionContext::new();let store = object_store::memory::InMemory::new();- let data = bytes::Bytes::from("a,b\n1,2\n3,4");+ let data = Bytes::from("a,b\n1,2\n3,4");let path = object_store::path::Path::from("a.csv");store.put(&path, data.into()).await.unwrap();@@ -1247,7 +1247,7 @@ mod tests {let session_ctx = SessionContext::new();let store = object_store::memory::InMemory::new();- let data = bytes::Bytes::from("a,b\r1,2\r3,4");+ let data = Bytes::from("a,b\r1,2\r3,4");let path = object_store::path::Path::from("a.csv");store.put(&path, data.into()).await.unwrap();diff --git a/datafusion/core/src/datasource/physical_plan/file_scan_config.rs b/datafusion/core/src/datasource/physical_plan/file_scan_config.rsindex 415ea62b3b..96c0e452e2 100644--- a/datafusion/core/src/datasource/physical_plan/file_scan_config.rs+++ b/datafusion/core/src/datasource/physical_plan/file_scan_config.rs@@ -19,7 +19,8 @@//! file sources.use std::{- borrow::Cow, collections::HashMap, fmt::Debug, marker::PhantomData, sync::Arc, vec,+ borrow::Cow, collections::HashMap, fmt::Debug, marker::PhantomData, mem::size_of,+ sync::Arc, vec,};use super::{get_projected_output_ordering, statistics::MinMaxStatistics};@@ -497,7 +498,7 @@ impl<T> ZeroBufferGenerator<T>whereT: ArrowNativeType,{- const SIZE: usize = std::mem::size_of::<T>();+ const SIZE: usize = size_of::<T>();fn get_buffer(&mut self, n_vals: usize) -> Buffer {match &mut self.cache {diff --git a/datafusion/core/src/datasource/physical_plan/mod.rs b/datafusion/core/src/datasource/physical_plan/mod.rsindex 6e8752ccfb..407a3b74f7 100644--- a/datafusion/core/src/datasource/physical_plan/mod.rs+++ b/datafusion/core/src/datasource/physical_plan/mod.rs@@ -763,7 +763,7 @@ mod tests {/// create a PartitionedFile for testingfn partitioned_file(path: &str) -> PartitionedFile {let object_meta = ObjectMeta {- location: object_store::path::Path::parse(path).unwrap(),+ location: Path::parse(path).unwrap(),last_modified: Utc::now(),size: 42,e_tag: None,diff --git a/datafusion/core/src/datasource/physical_plan/parquet/mod.rs b/datafusion/core/src/datasource/physical_plan/parquet/mod.rsindex 743dd58969..059f86ce11 100644--- a/datafusion/core/src/datasource/physical_plan/parquet/mod.rs+++ b/datafusion/core/src/datasource/physical_plan/parquet/mod.rs@@ -2227,7 +2227,7 @@ mod tests {// execute a simple query and write the results to parquetlet out_dir = tmp_dir.as_ref().to_str().unwrap().to_string() + "/out";- std::fs::create_dir(&out_dir).unwrap();+ fs::create_dir(&out_dir).unwrap();let df = ctx.sql("SELECT c1, c2 FROM test").await?;let schema: Schema = df.schema().into();// Register a listing table - this will use all files in the directory as data sourcesdiff --git a/datafusion/core/src/datasource/physical_plan/parquet/row_group_filter.rs b/datafusion/core/src/datasource/physical_plan/parquet/row_group_filter.rsindex a1d74cb543..7406676652 100644--- a/datafusion/core/src/datasource/physical_plan/parquet/row_group_filter.rs+++ b/datafusion/core/src/datasource/physical_plan/parquet/row_group_filter.rs@@ -779,11 +779,8 @@ mod tests {// INT32: c1 > 5, the c1 is decimal(9,2)// The type of scalar value if decimal(9,2), don't need to do cast- let schema = Arc::new(Schema::new(vec![Field::new(- "c1",- DataType::Decimal128(9, 2),- false,- )]));+ let schema =+ Arc::new(Schema::new(vec![Field::new("c1", Decimal128(9, 2), false)]));let field = PrimitiveTypeField::new("c1", PhysicalType::INT32).with_logical_type(LogicalType::Decimal {scale: 2,@@ -849,11 +846,8 @@ mod tests {// The c1 type is decimal(9,0) in the parquet file, and the type of scalar is decimal(5,2).// We should convert all type to the coercion type, which is decimal(11,2)// The decimal of arrow is decimal(5,2), the decimal of parquet is decimal(9,0)- let schema = Arc::new(Schema::new(vec![Field::new(- "c1",- DataType::Decimal128(9, 0),- false,- )]));+ let schema =+ Arc::new(Schema::new(vec![Field::new("c1", Decimal128(9, 0), false)]));let field = PrimitiveTypeField::new("c1", PhysicalType::INT32).with_logical_type(LogicalType::Decimal {@@ -863,7 +857,7 @@ mod tests {.with_scale(0).with_precision(9);let schema_descr = get_test_schema_descr(vec![field]);- let expr = cast(col("c1"), DataType::Decimal128(11, 2)).gt(cast(+ let expr = cast(col("c1"), Decimal128(11, 2)).gt(cast(lit(ScalarValue::Decimal128(Some(500), 5, 2)),Decimal128(11, 2),));@@ -947,7 +941,7 @@ mod tests {// INT64: c1 < 5, the c1 is decimal(18,2)let schema = Arc::new(Schema::new(vec![Field::new("c1",- DataType::Decimal128(18, 2),+ Decimal128(18, 2),false,)]));let field = PrimitiveTypeField::new("c1", PhysicalType::INT64)@@ -1005,7 +999,7 @@ mod tests {// the type of parquet is decimal(18,2)let schema = Arc::new(Schema::new(vec![Field::new("c1",- DataType::Decimal128(18, 2),+ Decimal128(18, 2),false,)]));let field = PrimitiveTypeField::new("c1", PhysicalType::FIXED_LEN_BYTE_ARRAY)@@ -1018,7 +1012,7 @@ mod tests {.with_byte_len(16);let schema_descr = get_test_schema_descr(vec![field]);// cast the type of c1 to decimal(28,3)- let left = cast(col("c1"), DataType::Decimal128(28, 3));+ let left = cast(col("c1"), Decimal128(28, 3));let expr = left.eq(lit(ScalarValue::Decimal128(Some(100000), 28, 3)));let expr = logical2physical(&expr, &schema);let pruning_predicate = PruningPredicate::try_new(expr, schema.clone()).unwrap();@@ -1083,7 +1077,7 @@ mod tests {// the type of parquet is decimal(18,2)let schema = Arc::new(Schema::new(vec![Field::new("c1",- DataType::Decimal128(18, 2),+ Decimal128(18, 2),false,)]));let field = PrimitiveTypeField::new("c1", PhysicalType::BYTE_ARRAY)@@ -1096,7 +1090,7 @@ mod tests {.with_byte_len(16);let schema_descr = get_test_schema_descr(vec![field]);// cast the type of c1 to decimal(28,3)- let left = cast(col("c1"), DataType::Decimal128(28, 3));+ let left = cast(col("c1"), Decimal128(28, 3));let expr = left.eq(lit(ScalarValue::Decimal128(Some(100000), 28, 3)));let expr = logical2physical(&expr, &schema);let pruning_predicate = PruningPredicate::try_new(expr, schema.clone()).unwrap();diff --git a/datafusion/core/src/datasource/physical_plan/statistics.rs b/datafusion/core/src/datasource/physical_plan/statistics.rsindex e1c61ec1a7..3ca3ba89f4 100644--- a/datafusion/core/src/datasource/physical_plan/statistics.rs+++ b/datafusion/core/src/datasource/physical_plan/statistics.rs@@ -278,13 +278,9 @@ impl MinMaxStatistics {fn sort_columns_from_physical_sort_exprs(sort_order: &[PhysicalSortExpr],-) -> Option<Vec<&datafusion_physical_plan::expressions::Column>> {+) -> Option<Vec<&Column>> {sort_order.iter()- .map(|expr| {- expr.expr- .as_any()- .downcast_ref::<datafusion_physical_expr::expressions::Column>()- })+ .map(|expr| expr.expr.as_any().downcast_ref::<Column>()).collect::<Option<Vec<_>>>()}diff --git a/datafusion/core/src/datasource/schema_adapter.rs b/datafusion/core/src/datasource/schema_adapter.rsindex 80d2bf9874..5ba597e4b5 100644--- a/datafusion/core/src/datasource/schema_adapter.rs+++ b/datafusion/core/src/datasource/schema_adapter.rs@@ -478,7 +478,7 @@ mod tests {writer.close().unwrap();let location = Path::parse(path.to_str().unwrap()).unwrap();- let metadata = std::fs::metadata(path.as_path()).expect("Local file metadata");+ let metadata = fs::metadata(path.as_path()).expect("Local file metadata");let meta = ObjectMeta {location,last_modified: metadata.modified().map(chrono::DateTime::from).unwrap(),diff --git a/datafusion/core/src/execution/context/mod.rs b/datafusion/core/src/execution/context/mod.rsindex 606759aae5..333f83c673 100644--- a/datafusion/core/src/execution/context/mod.rs+++ b/datafusion/core/src/execution/context/mod.rs@@ -2139,9 +2139,9 @@ mod tests {fn create_physical_expr(&self,_expr: &Expr,- _input_dfschema: &crate::common::DFSchema,+ _input_dfschema: &DFSchema,_session_state: &SessionState,- ) -> Result<Arc<dyn crate::physical_plan::PhysicalExpr>> {+ ) -> Result<Arc<dyn PhysicalExpr>> {unimplemented!()}}diff --git a/datafusion/core/src/execution/session_state.rs b/datafusion/core/src/execution/session_state.rsindex 4953eecd66..d50c912dd2 100644--- a/datafusion/core/src/execution/session_state.rs+++ b/datafusion/core/src/execution/session_state.rs@@ -512,7 +512,7 @@ impl SessionState {/// [`catalog::resolve_table_references`]: crate::catalog_common::resolve_table_referencespub fn resolve_table_references(&self,- statement: &datafusion_sql::parser::Statement,+ statement: &Statement,) -> datafusion_common::Result<Vec<TableReference>> {let enable_ident_normalization =self.config.options().sql_parser.enable_ident_normalization;@@ -526,7 +526,7 @@ impl SessionState {/// Convert an AST Statement into a LogicalPlanpub async fn statement_to_plan(&self,- statement: datafusion_sql::parser::Statement,+ statement: Statement,) -> datafusion_common::Result<LogicalPlan> {let references = self.resolve_table_references(&statement)?;diff --git a/datafusion/core/src/physical_optimizer/enforce_distribution.rs b/datafusion/core/src/physical_optimizer/enforce_distribution.rsindex c971e61506..aa4bcb6837 100644--- a/datafusion/core/src/physical_optimizer/enforce_distribution.rs+++ b/datafusion/core/src/physical_optimizer/enforce_distribution.rs@@ -1416,8 +1416,8 @@ pub(crate) mod tests {use datafusion_expr::Operator;use datafusion_physical_expr::expressions::{BinaryExpr, Literal};use datafusion_physical_expr::{- expressions, expressions::binary, expressions::lit, LexOrdering,- PhysicalSortExpr, PhysicalSortRequirement,+ expressions::binary, expressions::lit, LexOrdering, PhysicalSortExpr,+ PhysicalSortRequirement,};use datafusion_physical_expr_common::sort_expr::LexRequirement;use datafusion_physical_plan::PlanProperties;@@ -1646,8 +1646,7 @@ pub(crate) mod tests {.enumerate().map(|(index, (_col, name))| {(- Arc::new(expressions::Column::new(name, index))- as Arc<dyn PhysicalExpr>,+ Arc::new(Column::new(name, index)) as Arc<dyn PhysicalExpr>,name.clone(),)})diff --git a/datafusion/core/src/test/mod.rs b/datafusion/core/src/test/mod.rsindex 08740daa0c..9ac75c8f3e 100644--- a/datafusion/core/src/test/mod.rs+++ b/datafusion/core/src/test/mod.rs@@ -69,7 +69,7 @@ pub fn create_table_dual() -> Arc<dyn TableProvider> {let batch = RecordBatch::try_new(dual_schema.clone(),vec![- Arc::new(array::Int32Array::from(vec![1])),+ Arc::new(Int32Array::from(vec![1])),Arc::new(array::StringArray::from(vec!["a"])),],)diff --git a/datafusion/core/tests/dataframe/mod.rs b/datafusion/core/tests/dataframe/mod.rsindex 3520ab8fed..0c3c2a9951 100644--- a/datafusion/core/tests/dataframe/mod.rs+++ b/datafusion/core/tests/dataframe/mod.rs@@ -1434,9 +1434,7 @@ async fn unnest_analyze_metrics() -> Result<()> {.explain(false, true)?.collect().await?;- let formatted = arrow::util::pretty::pretty_format_batches(&results)- .unwrap()- .to_string();+ let formatted = pretty_format_batches(&results).unwrap().to_string();assert_contains!(&formatted, "elapsed_compute=");assert_contains!(&formatted, "input_batches=1");assert_contains!(&formatted, "input_rows=5");diff --git a/datafusion/core/tests/expr_api/simplification.rs b/datafusion/core/tests/expr_api/simplification.rsindex 800a087587..68785b7a5a 100644--- a/datafusion/core/tests/expr_api/simplification.rs+++ b/datafusion/core/tests/expr_api/simplification.rs@@ -29,10 +29,10 @@ use datafusion_expr::expr::ScalarFunction;use datafusion_expr::logical_plan::builder::table_scan_with_filters;use datafusion_expr::simplify::SimplifyInfo;use datafusion_expr::{- expr, table_scan, Cast, ColumnarValue, ExprSchemable, LogicalPlan,- LogicalPlanBuilder, ScalarUDF, Volatility,+ table_scan, Cast, ColumnarValue, ExprSchemable, LogicalPlan, LogicalPlanBuilder,+ ScalarUDF, Volatility,};-use datafusion_functions::{math, string};+use datafusion_functions::math;use datafusion_optimizer::optimizer::Optimizer;use datafusion_optimizer::simplify_expressions::{ExprSimplifier, SimplifyExpressions};use datafusion_optimizer::{OptimizerContext, OptimizerRule};@@ -368,13 +368,13 @@ fn test_const_evaluator() {#[test]fn test_const_evaluator_scalar_functions() {// concat("foo", "bar") --> "foobar"- let expr = string::expr_fn::concat(vec![lit("foo"), lit("bar")]);+ let expr = concat(vec![lit("foo"), lit("bar")]);test_evaluate(expr, lit("foobar"));// ensure arguments are also constant folded// concat("foo", concat("bar", "baz")) --> "foobarbaz"- let concat1 = string::expr_fn::concat(vec![lit("bar"), lit("baz")]);- let expr = string::expr_fn::concat(vec![lit("foo"), concat1]);+ let concat1 = concat(vec![lit("bar"), lit("baz")]);+ let expr = concat(vec![lit("foo"), concat1]);test_evaluate(expr, lit("foobarbaz"));// Check non string arguments@@ -407,7 +407,7 @@ fn test_const_evaluator_scalar_functions() {#[test]fn test_const_evaluator_now() {let ts_nanos = 1599566400000000000i64;- let time = chrono::Utc.timestamp_nanos(ts_nanos);+ let time = Utc.timestamp_nanos(ts_nanos);let ts_string = "2020-09-08T12:05:00+00:00";// now() --> tstest_evaluate_with_start_time(now(), lit_timestamp_nano(ts_nanos), &time);@@ -429,7 +429,7 @@ fn test_evaluator_udfs() {// immutable UDF should get folded// udf_add(1+2, 30+40) --> 73- let expr = Expr::ScalarFunction(expr::ScalarFunction::new_udf(+ let expr = Expr::ScalarFunction(ScalarFunction::new_udf(make_udf_add(Volatility::Immutable),args.clone(),));@@ -438,21 +438,16 @@ fn test_evaluator_udfs() {// stable UDF should be entirely folded// udf_add(1+2, 30+40) --> 73let fun = make_udf_add(Volatility::Stable);- let expr = Expr::ScalarFunction(expr::ScalarFunction::new_udf(- Arc::clone(&fun),- args.clone(),- ));+ let expr =+ Expr::ScalarFunction(ScalarFunction::new_udf(Arc::clone(&fun), args.clone()));test_evaluate(expr, lit(73));// volatile UDF should have args folded// udf_add(1+2, 30+40) --> udf_add(3, 70)let fun = make_udf_add(Volatility::Volatile);- let expr =- Expr::ScalarFunction(expr::ScalarFunction::new_udf(Arc::clone(&fun), args));- let expected_expr = Expr::ScalarFunction(expr::ScalarFunction::new_udf(- Arc::clone(&fun),- folded_args,- ));+ let expr = Expr::ScalarFunction(ScalarFunction::new_udf(Arc::clone(&fun), args));+ let expected_expr =+ Expr::ScalarFunction(ScalarFunction::new_udf(Arc::clone(&fun), folded_args));test_evaluate(expr, expected_expr);}diff --git a/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/fuzzer.rs b/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/fuzzer.rsindex 898d1081ff..0704bafa03 100644--- a/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/fuzzer.rs+++ b/datafusion/core/tests/fuzz_cases/aggregation_fuzzer/fuzzer.rs@@ -104,7 +104,7 @@ impl AggregationFuzzerBuilder {}}-impl std::default::Default for AggregationFuzzerBuilder {+impl Default for AggregationFuzzerBuilder {fn default() -> Self {Self::new()}@@ -375,7 +375,7 @@ pub struct QueryBuilder {}impl QueryBuilder {pub fn new() -> Self {- std::default::Default::default()+ Default::default()}/// return the table name if anydiff --git a/datafusion/core/tests/fuzz_cases/join_fuzz.rs b/datafusion/core/tests/fuzz_cases/join_fuzz.rsindex 44d34b674b..c8478db22b 100644--- a/datafusion/core/tests/fuzz_cases/join_fuzz.rs+++ b/datafusion/core/tests/fuzz_cases/join_fuzz.rs@@ -90,6 +90,7 @@ fn col_lt_col_filter(schema1: Arc<Schema>, schema2: Arc<Schema>) -> JoinFilter {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_inner_join_1k_filtered() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -102,6 +103,7 @@ async fn test_inner_join_1k_filtered() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_inner_join_1k() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -114,6 +116,7 @@ async fn test_inner_join_1k() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_left_join_1k() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -126,6 +129,7 @@ async fn test_left_join_1k() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_left_join_1k_filtered() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -138,6 +142,7 @@ async fn test_left_join_1k_filtered() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_right_join_1k() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -150,6 +155,7 @@ async fn test_right_join_1k() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_right_join_1k_filtered() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -162,6 +168,7 @@ async fn test_right_join_1k_filtered() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_full_join_1k() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -174,6 +181,7 @@ async fn test_full_join_1k() {}#[tokio::test]+#[allow(unused_qualifications)]// flaky for HjSmj case// https://github.com/apache/datafusion/issues/12359async fn test_full_join_1k_filtered() {@@ -188,6 +196,7 @@ async fn test_full_join_1k_filtered() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_semi_join_1k() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -200,6 +209,7 @@ async fn test_semi_join_1k() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_semi_join_1k_filtered() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -212,6 +222,7 @@ async fn test_semi_join_1k_filtered() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_anti_join_1k() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -224,6 +235,7 @@ async fn test_anti_join_1k() {}#[tokio::test]+#[allow(unused_qualifications)]async fn test_anti_join_1k_filtered() {JoinFuzzTestCase::new(make_staggered_batches(1000),@@ -449,6 +461,7 @@ impl JoinFuzzTestCase {/// `join_tests` - identifies what join types to test/// if `debug` flag is set the test will save randomly generated inputs and outputs to user folders,/// so it is easy to debug a test on top of the failed data+ #[allow(unused_qualifications)]async fn run_test(&self, join_tests: &[JoinTestType], debug: bool) {for batch_size in self.batch_sizes {let session_config = SessionConfig::new().with_batch_size(*batch_size);diff --git a/datafusion/core/tests/fuzz_cases/limit_fuzz.rs b/datafusion/core/tests/fuzz_cases/limit_fuzz.rsindex 95d97709f3..c52acdd827 100644--- a/datafusion/core/tests/fuzz_cases/limit_fuzz.rs+++ b/datafusion/core/tests/fuzz_cases/limit_fuzz.rs@@ -341,7 +341,7 @@ async fn run_limit_test(fetch: usize, data: &SortedData) {/// Return random ASCII String with lenfn get_random_string(len: usize) -> String {- rand::thread_rng()+ thread_rng().sample_iter(rand::distributions::Alphanumeric).take(len).map(char::from)diff --git a/datafusion/core/tests/fuzz_cases/sort_preserving_repartition_fuzz.rs b/datafusion/core/tests/fuzz_cases/sort_preserving_repartition_fuzz.rsindex a72affc2b0..353db86683 100644--- a/datafusion/core/tests/fuzz_cases/sort_preserving_repartition_fuzz.rs+++ b/datafusion/core/tests/fuzz_cases/sort_preserving_repartition_fuzz.rs@@ -174,7 +174,7 @@ mod sp_repartition_fuzz_tests {}).unzip();- let sort_arrs = arrow::compute::lexsort(&sort_columns, None)?;+ let sort_arrs = lexsort(&sort_columns, None)?;for (idx, arr) in izip!(indices, sort_arrs) {schema_vec[idx] = Some(arr);}diff --git a/datafusion/core/tests/fuzz_cases/window_fuzz.rs b/datafusion/core/tests/fuzz_cases/window_fuzz.rsindex d649919f1b..61b4e32ad6 100644--- a/datafusion/core/tests/fuzz_cases/window_fuzz.rs+++ b/datafusion/core/tests/fuzz_cases/window_fuzz.rs@@ -293,7 +293,7 @@ async fn bounded_window_causal_non_causal() -> Result<()> {vec![window_expr],memory_exec.clone(),vec![],- InputOrderMode::Linear,+ Linear,)?);let task_ctx = ctx.task_ctx();let mut collected_results =@@ -592,7 +592,7 @@ async fn run_window_test(orderby_columns: Vec<&str>,search_mode: InputOrderMode,) -> Result<()> {- let is_linear = !matches!(search_mode, InputOrderMode::Sorted);+ let is_linear = !matches!(search_mode, Sorted);let mut rng = StdRng::seed_from_u64(random_seed);let schema = input1[0].schema();let session_config = SessionConfig::new().with_batch_size(50);diff --git a/datafusion/core/tests/parquet/file_statistics.rs b/datafusion/core/tests/parquet/file_statistics.rsindex 18d8300fb2..4b5d22bfa7 100644--- a/datafusion/core/tests/parquet/file_statistics.rs+++ b/datafusion/core/tests/parquet/file_statistics.rs@@ -28,7 +28,6 @@ use datafusion::execution::context::SessionState;use datafusion::prelude::SessionContext;use datafusion_common::stats::Precision;use datafusion_execution::cache::cache_manager::CacheManagerConfig;-use datafusion_execution::cache::cache_unit;use datafusion_execution::cache::cache_unit::{DefaultFileStatisticsCache, DefaultListFilesCache,};@@ -211,8 +210,8 @@ fn get_cache_runtime_state() -> (SessionState,) {let cache_config = CacheManagerConfig::default();- let file_static_cache = Arc::new(cache_unit::DefaultFileStatisticsCache::default());- let list_file_cache = Arc::new(cache_unit::DefaultListFilesCache::default());+ let file_static_cache = Arc::new(DefaultFileStatisticsCache::default());+ let list_file_cache = Arc::new(DefaultListFilesCache::default());let cache_config = cache_config.with_files_statistics_cache(Some(file_static_cache.clone()))diff --git a/datafusion/core/tests/physical_optimizer/limited_distinct_aggregation.rs b/datafusion/core/tests/physical_optimizer/limited_distinct_aggregation.rsindex d6991711f5..6859e2f146 100644--- a/datafusion/core/tests/physical_optimizer/limited_distinct_aggregation.rs+++ b/datafusion/core/tests/physical_optimizer/limited_distinct_aggregation.rs@@ -375,7 +375,7 @@ fn test_has_filter() -> Result<()> {// `SELECT a FROM MemoryExec WHERE a > 1 GROUP BY a LIMIT 10;`, Single AggregateExec// the `a > 1` filter is applied in the AggregateExeclet filter_expr = Some(expressions::binary(- expressions::col("a", &schema)?,+ col("a", &schema)?,Operator::Gt,cast(expressions::lit(1u32), &schema, DataType::Int32)?,&schema,@@ -408,7 +408,7 @@ fn test_has_filter() -> Result<()> {#[test]fn test_has_order_by() -> Result<()> {let sort_key = vec![PhysicalSortExpr {- expr: expressions::col("a", &schema()).unwrap(),+ expr: col("a", &schema()).unwrap(),options: SortOptions::default(),}];let source = parquet_exec_with_sort(vec![sort_key]);diff --git a/datafusion/core/tests/sql/joins.rs b/datafusion/core/tests/sql/joins.rsindex addabc8a36..fab92c0f9c 100644--- a/datafusion/core/tests/sql/joins.rs+++ b/datafusion/core/tests/sql/joins.rs@@ -33,7 +33,7 @@ async fn join_change_in_planner() -> Result<()> {Field::new("a2", DataType::UInt32, false),]));// Specify the ordering:- let file_sort_order = vec![[datafusion_expr::col("a1")]+ let file_sort_order = vec![[col("a1")].into_iter().map(|e| {let ascending = true;@@ -101,7 +101,7 @@ async fn join_no_order_on_filter() -> Result<()> {Field::new("a3", DataType::UInt32, false),]));// Specify the ordering:- let file_sort_order = vec![[datafusion_expr::col("a1")]+ let file_sort_order = vec![[col("a1")].into_iter().map(|e| {let ascending = true;diff --git a/datafusion/core/tests/sql/mod.rs b/datafusion/core/tests/sql/mod.rsindex dc9d047860..177427b47d 100644--- a/datafusion/core/tests/sql/mod.rs+++ b/datafusion/core/tests/sql/mod.rs@@ -65,7 +65,7 @@ pub mod select;mod sql_api;async fn register_aggregate_csv_by_sql(ctx: &SessionContext) {- let testdata = datafusion::test_util::arrow_test_data();+ let testdata = test_util::arrow_test_data();let df = ctx.sql(&format!(@@ -103,7 +103,7 @@ async fn register_aggregate_csv_by_sql(ctx: &SessionContext) {}async fn register_aggregate_csv(ctx: &SessionContext) -> Result<()> {- let testdata = datafusion::test_util::arrow_test_data();+ let testdata = test_util::arrow_test_data();let schema = test_util::aggr_test_schema();ctx.register_csv("aggregate_test_100",@@ -227,7 +227,7 @@ fn result_vec(results: &[RecordBatch]) -> Vec<Vec<String>> {}async fn register_alltypes_parquet(ctx: &SessionContext) {- let testdata = datafusion::test_util::parquet_test_data();+ let testdata = test_util::parquet_test_data();ctx.register_parquet("alltypes_plain",&format!("{testdata}/alltypes_plain.parquet"),diff --git a/datafusion/core/tests/user_defined/user_defined_aggregates.rs b/datafusion/core/tests/user_defined/user_defined_aggregates.rsindex 1e0d3d9d51..497addd230 100644--- a/datafusion/core/tests/user_defined/user_defined_aggregates.rs+++ b/datafusion/core/tests/user_defined/user_defined_aggregates.rs@@ -747,7 +747,7 @@ impl Accumulator for FirstSelector {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}@@ -816,7 +816,7 @@ impl Accumulator for TestGroupsAccumulator {}fn size(&self) -> usize {- std::mem::size_of::<u64>()+ size_of::<u64>()}fn state(&mut self) -> Result<Vec<ScalarValue>> {@@ -864,6 +864,6 @@ impl GroupsAccumulator for TestGroupsAccumulator {}fn size(&self) -> usize {- std::mem::size_of::<u64>()+ size_of::<u64>()}}diff --git a/datafusion/core/tests/user_defined/user_defined_plan.rs b/datafusion/core/tests/user_defined/user_defined_plan.rsindex 6c4e3c66e3..c962567844 100644--- a/datafusion/core/tests/user_defined/user_defined_plan.rs+++ b/datafusion/core/tests/user_defined/user_defined_plan.rs@@ -513,11 +513,7 @@ impl Debug for TopKExec {}impl DisplayAs for TopKExec {- fn fmt_as(- &self,- t: DisplayFormatType,- f: &mut std::fmt::Formatter,- ) -> std::fmt::Result {+ fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter) -> fmt::Result {match t {DisplayFormatType::Default | DisplayFormatType::Verbose => {write!(f, "TopKExec: k={}", self.k)diff --git a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rsindex 0887645b8c..f1b1728623 100644--- a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs+++ b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs@@ -936,11 +936,11 @@ struct ScalarFunctionWrapper {name: String,expr: Expr,signature: Signature,- return_type: arrow_schema::DataType,+ return_type: DataType,}impl ScalarUDFImpl for ScalarFunctionWrapper {- fn as_any(&self) -> &dyn std::any::Any {+ fn as_any(&self) -> &dyn Any {self}@@ -948,21 +948,15 @@ impl ScalarUDFImpl for ScalarFunctionWrapper {&self.name}- fn signature(&self) -> &datafusion_expr::Signature {+ fn signature(&self) -> &Signature {&self.signature}- fn return_type(- &self,- _arg_types: &[arrow_schema::DataType],- ) -> Result<arrow_schema::DataType> {+ fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {Ok(self.return_type.clone())}- fn invoke(- &self,- _args: &[datafusion_expr::ColumnarValue],- ) -> Result<datafusion_expr::ColumnarValue> {+ fn invoke(&self, _args: &[ColumnarValue]) -> Result<ColumnarValue> {internal_err!("This function should not get invoked!")}@@ -1042,10 +1036,7 @@ impl TryFrom<CreateFunction> for ScalarFunctionWrapper {.into_iter().map(|a| a.data_type).collect(),- definition- .params- .behavior- .unwrap_or(datafusion_expr::Volatility::Volatile),+ definition.params.behavior.unwrap_or(Volatility::Volatile),),})}@@ -1350,7 +1341,7 @@ fn custom_sqrt(args: &[ColumnarValue]) -> Result<ColumnarValue> {}async fn register_aggregate_csv(ctx: &SessionContext) -> Result<()> {- let testdata = datafusion::test_util::arrow_test_data();+ let testdata = test_util::arrow_test_data();let schema = test_util::aggr_test_schema();ctx.register_csv("aggregate_test_100",@@ -1362,7 +1353,7 @@ async fn register_aggregate_csv(ctx: &SessionContext) -> Result<()> {}async fn register_alltypes_parquet(ctx: &SessionContext) -> Result<()> {- let testdata = datafusion::test_util::parquet_test_data();+ let testdata = test_util::parquet_test_data();ctx.register_parquet("alltypes_plain",&format!("{testdata}/alltypes_plain.parquet"),diff --git a/datafusion/core/tests/user_defined/user_defined_window_functions.rs b/datafusion/core/tests/user_defined/user_defined_window_functions.rsindex 3760328934..8fe028eedd 100644--- a/datafusion/core/tests/user_defined/user_defined_window_functions.rs+++ b/datafusion/core/tests/user_defined/user_defined_window_functions.rs@@ -593,11 +593,7 @@ impl PartitionEvaluator for OddCounter {Ok(scalar)}- fn evaluate_all(- &mut self,- values: &[arrow_array::ArrayRef],- num_rows: usize,- ) -> Result<arrow_array::ArrayRef> {+ fn evaluate_all(&mut self, values: &[ArrayRef], num_rows: usize) -> Result<ArrayRef> {println!("evaluate_all, values: {values:#?}, num_rows: {num_rows}");self.test_state.inc_evaluate_all_called();@@ -641,7 +637,7 @@ fn odd_count(arr: &Int64Array) -> i64 {}/// returns an array of num_rows that has the number of odd values in `arr`-fn odd_count_arr(arr: &Int64Array, num_rows: usize) -> arrow_array::ArrayRef {+fn odd_count_arr(arr: &Int64Array, num_rows: usize) -> ArrayRef {let array: Int64Array = std::iter::repeat(odd_count(arr)).take(num_rows).collect();Arc::new(array)}diff --git a/datafusion/execution/src/disk_manager.rs b/datafusion/execution/src/disk_manager.rsindex c98d7e5579..38c259fcbd 100644--- a/datafusion/execution/src/disk_manager.rs+++ b/datafusion/execution/src/disk_manager.rs@@ -173,7 +173,7 @@ fn create_local_dirs(local_dirs: Vec<PathBuf>) -> Result<Vec<Arc<TempDir>>> {local_dirs.iter().map(|root| {- if !std::path::Path::new(root).exists() {+ if !Path::new(root).exists() {std::fs::create_dir(root)?;}Builder::new()diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rsindex 2f806bf76d..31fe6a59ba 100644--- a/datafusion/expr-common/src/type_coercion/binary.rs+++ b/datafusion/expr-common/src/type_coercion/binary.rs@@ -89,7 +89,7 @@ fn signature(lhs: &DataType, op: &Operator, rhs: &DataType) -> Result<Signature>And | Or => if matches!((lhs, rhs), (Boolean | Null, Boolean | Null)) {// Logical binary boolean operators can only be evaluated for// boolean or null arguments.- Ok(Signature::uniform(DataType::Boolean))+ Ok(Signature::uniform(Boolean))} else {plan_err!("Cannot infer common argument type for logical boolean operation {lhs} {op} {rhs}"@@ -1225,9 +1225,9 @@ pub fn like_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataTypfn regex_null_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {use arrow::datatypes::DataType::*;match (lhs_type, rhs_type) {- (DataType::Null, Utf8View | Utf8 | LargeUtf8) => Some(rhs_type.clone()),- (Utf8View | Utf8 | LargeUtf8, DataType::Null) => Some(lhs_type.clone()),- (DataType::Null, DataType::Null) => Some(Utf8),+ (Null, Utf8View | Utf8 | LargeUtf8) => Some(rhs_type.clone()),+ (Utf8View | Utf8 | LargeUtf8, Null) => Some(lhs_type.clone()),+ (Null, Null) => Some(Utf8),_ => None,}}diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rsindex 4d73c2a044..bda4d7ae3d 100644--- a/datafusion/expr/src/expr.rs+++ b/datafusion/expr/src/expr.rs@@ -29,8 +29,8 @@ use crate::logical_plan::Subquery;use crate::utils::expr_to_columns;use crate::Volatility;use crate::{- built_in_window_function, udaf, BuiltInWindowFunction, ExprSchemable, Operator,- Signature, WindowFrame, WindowUDF,+ udaf, BuiltInWindowFunction, ExprSchemable, Operator, Signature, WindowFrame,+ WindowUDF,};use arrow::datatypes::{DataType, FieldRef};@@ -695,11 +695,11 @@ impl AggregateFunction {pub enum WindowFunctionDefinition {/// A built in aggregate function that leverages an aggregate function/// A a built-in window function- BuiltInWindowFunction(built_in_window_function::BuiltInWindowFunction),+ BuiltInWindowFunction(BuiltInWindowFunction),/// A user defined aggregate functionAggregateUDF(Arc<crate::AggregateUDF>),/// A user defined aggregate function- WindowUDF(Arc<crate::WindowUDF>),+ WindowUDF(Arc<WindowUDF>),}impl WindowFunctionDefinition {@@ -742,14 +742,12 @@ impl WindowFunctionDefinition {}}-impl fmt::Display for WindowFunctionDefinition {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+impl Display for WindowFunctionDefinition {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {match self {- WindowFunctionDefinition::BuiltInWindowFunction(fun) => {- std::fmt::Display::fmt(fun, f)- }- WindowFunctionDefinition::AggregateUDF(fun) => std::fmt::Display::fmt(fun, f),- WindowFunctionDefinition::WindowUDF(fun) => std::fmt::Display::fmt(fun, f),+ WindowFunctionDefinition::BuiltInWindowFunction(fun) => Display::fmt(fun, f),+ WindowFunctionDefinition::AggregateUDF(fun) => Display::fmt(fun, f),+ WindowFunctionDefinition::WindowUDF(fun) => Display::fmt(fun, f),}}}@@ -833,9 +831,7 @@ pub fn find_df_window_func(name: &str) -> Option<WindowFunctionDefinition> {// may have different implementations for these cases. If the sought// function is not found among built-in window functions, we search for// it among aggregate functions.- if let Ok(built_in_function) =- built_in_window_function::BuiltInWindowFunction::from_str(name.as_str())- {+ if let Ok(built_in_function) = BuiltInWindowFunction::from_str(name.as_str()) {Some(WindowFunctionDefinition::BuiltInWindowFunction(built_in_function,))@@ -2141,8 +2137,8 @@ pub fn schema_name_from_sorts(sorts: &[Sort]) -> Result<String, fmt::Error> {/// Format expressions for display as part of a logical plan. In many cases, this will produce/// similar output to `Expr.name()` except that column names will be prefixed with '#'.-impl fmt::Display for Expr {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+impl Display for Expr {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {match self {Expr::Alias(Alias { expr, name, .. }) => write!(f, "{expr} AS {name}"),Expr::Column(c) => write!(f, "{c}"),@@ -2346,7 +2342,7 @@ impl fmt::Display for Expr {}fn fmt_function(- f: &mut fmt::Formatter,+ f: &mut Formatter,fun: &str,distinct: bool,args: &[Expr],@@ -2588,13 +2584,13 @@ mod test {assert_eq!(find_df_window_func("first_value"),Some(WindowFunctionDefinition::BuiltInWindowFunction(- built_in_window_function::BuiltInWindowFunction::FirstValue+ BuiltInWindowFunction::FirstValue)));assert_eq!(find_df_window_func("LAST_value"),Some(WindowFunctionDefinition::BuiltInWindowFunction(- built_in_window_function::BuiltInWindowFunction::LastValue+ BuiltInWindowFunction::LastValue)));assert_eq!(find_df_window_func("not_exist"), None)diff --git a/datafusion/expr/src/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rsindex 1f67162687..2547aa23d3 100644--- a/datafusion/expr/src/logical_plan/builder.rs+++ b/datafusion/expr/src/logical_plan/builder.rs@@ -1678,7 +1678,7 @@ impl TableSource for LogicalTableSource {fn supports_filters_pushdown(&self,filters: &[&Expr],- ) -> Result<Vec<crate::TableProviderFilterPushDown>> {+ ) -> Result<Vec<TableProviderFilterPushDown>> {Ok(vec![TableProviderFilterPushDown::Exact; filters.len()])}}diff --git a/datafusion/expr/src/logical_plan/ddl.rs b/datafusion/expr/src/logical_plan/ddl.rsindex c4fa9f4c3f..93e8b5fd04 100644--- a/datafusion/expr/src/logical_plan/ddl.rs+++ b/datafusion/expr/src/logical_plan/ddl.rs@@ -120,7 +120,7 @@ impl DdlStatement {/// children.////// See [crate::LogicalPlan::display] for an example- pub fn display(&self) -> impl fmt::Display + '_ {+ pub fn display(&self) -> impl Display + '_ {struct Wrapper<'a>(&'a DdlStatement);impl<'a> Display for Wrapper<'a> {fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {diff --git a/datafusion/expr/src/logical_plan/dml.rs b/datafusion/expr/src/logical_plan/dml.rsindex 68b3ac41fa..669bc8e8a7 100644--- a/datafusion/expr/src/logical_plan/dml.rs+++ b/datafusion/expr/src/logical_plan/dml.rs@@ -165,7 +165,7 @@ impl WriteOp {}impl Display for WriteOp {- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {write!(f, "{}", self.name())}}@@ -196,7 +196,7 @@ impl InsertOp {}impl Display for InsertOp {- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {write!(f, "{}", self.name())}}diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rsindex 572285defb..a301c48659 100644--- a/datafusion/expr/src/logical_plan/plan.rs+++ b/datafusion/expr/src/logical_plan/plan.rs@@ -3382,8 +3382,8 @@ pub struct ColumnUnnestList {pub depth: usize,}-impl fmt::Display for ColumnUnnestList {- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+impl Display for ColumnUnnestList {+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {write!(f, "{}|depth={}", self.output_column, self.depth)}}diff --git a/datafusion/expr/src/logical_plan/statement.rs b/datafusion/expr/src/logical_plan/statement.rsindex ed06375157..7ad18ce7bb 100644--- a/datafusion/expr/src/logical_plan/statement.rs+++ b/datafusion/expr/src/logical_plan/statement.rs@@ -61,7 +61,7 @@ impl Statement {/// children.////// See [crate::LogicalPlan::display] for an example- pub fn display(&self) -> impl fmt::Display + '_ {+ pub fn display(&self) -> impl Display + '_ {struct Wrapper<'a>(&'a Statement);impl<'a> Display for Wrapper<'a> {fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {diff --git a/datafusion/expr/src/test/function_stub.rs b/datafusion/expr/src/test/function_stub.rsindex b4f768085f..262aa99e50 100644--- a/datafusion/expr/src/test/function_stub.rs+++ b/datafusion/expr/src/test/function_stub.rs@@ -34,7 +34,6 @@ use crate::{function::{AccumulatorArgs, StateFieldsArgs},utils::AggregateOrderSensitivity,Accumulator, AggregateUDFImpl, Expr, GroupsAccumulator, ReversedUDAF, Signature,- Volatility,};macro_rules! create_func {@@ -106,7 +105,7 @@ pub struct Sum {impl Sum {pub fn new() -> Self {Self {- signature: Signature::user_defined(Volatility::Immutable),+ signature: Signature::user_defined(Immutable),}}}@@ -236,13 +235,13 @@ impl Count {pub fn new() -> Self {Self {aliases: vec!["count".to_string()],- signature: Signature::variadic_any(Volatility::Immutable),+ signature: Signature::variadic_any(Immutable),}}}impl AggregateUDFImpl for Count {- fn as_any(&self) -> &dyn std::any::Any {+ fn as_any(&self) -> &dyn Any {self}@@ -318,13 +317,13 @@ impl Default for Min {impl Min {pub fn new() -> Self {Self {- signature: Signature::variadic_any(Volatility::Immutable),+ signature: Signature::variadic_any(Immutable),}}}impl AggregateUDFImpl for Min {- fn as_any(&self) -> &dyn std::any::Any {+ fn as_any(&self) -> &dyn Any {self}@@ -403,13 +402,13 @@ impl Default for Max {impl Max {pub fn new() -> Self {Self {- signature: Signature::variadic_any(Volatility::Immutable),+ signature: Signature::variadic_any(Immutable),}}}impl AggregateUDFImpl for Max {- fn as_any(&self) -> &dyn std::any::Any {+ fn as_any(&self) -> &dyn Any {self}diff --git a/datafusion/expr/src/utils.rs b/datafusion/expr/src/utils.rsindex 9207ad0099..29c62440ab 100644--- a/datafusion/expr/src/utils.rs+++ b/datafusion/expr/src/utils.rs@@ -1399,7 +1399,7 @@ pub fn format_state_name(name: &str, state_name: &str) -> String {mod tests {use super::*;use crate::{- col, cube, expr, expr_vec_fmt, grouping_set, lit, rollup,+ col, cube, expr_vec_fmt, grouping_set, lit, rollup,test::function_stub::max_udaf, test::function_stub::min_udaf,test::function_stub::sum_udaf, Cast, ExprFunctionExt, WindowFunctionDefinition,};@@ -1414,19 +1414,19 @@ mod tests {#[test]fn test_group_window_expr_by_sort_keys_empty_window() -> Result<()> {- let max1 = Expr::WindowFunction(expr::WindowFunction::new(+ let max1 = Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::AggregateUDF(max_udaf()),vec![col("name")],));- let max2 = Expr::WindowFunction(expr::WindowFunction::new(+ let max2 = Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::AggregateUDF(max_udaf()),vec![col("name")],));- let min3 = Expr::WindowFunction(expr::WindowFunction::new(+ let min3 = Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::AggregateUDF(min_udaf()),vec![col("name")],));- let sum4 = Expr::WindowFunction(expr::WindowFunction::new(+ let sum4 = Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::AggregateUDF(sum_udaf()),vec![col("age")],));@@ -1441,28 +1441,28 @@ mod tests {#[test]fn test_group_window_expr_by_sort_keys() -> Result<()> {- let age_asc = expr::Sort::new(col("age"), true, true);- let name_desc = expr::Sort::new(col("name"), false, true);- let created_at_desc = expr::Sort::new(col("created_at"), false, true);- let max1 = Expr::WindowFunction(expr::WindowFunction::new(+ let age_asc = Sort::new(col("age"), true, true);+ let name_desc = Sort::new(col("name"), false, true);+ let created_at_desc = Sort::new(col("created_at"), false, true);+ let max1 = Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::AggregateUDF(max_udaf()),vec![col("name")],)).order_by(vec![age_asc.clone(), name_desc.clone()]).build().unwrap();- let max2 = Expr::WindowFunction(expr::WindowFunction::new(+ let max2 = Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::AggregateUDF(max_udaf()),vec![col("name")],));- let min3 = Expr::WindowFunction(expr::WindowFunction::new(+ let min3 = Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::AggregateUDF(min_udaf()),vec![col("name")],)).order_by(vec![age_asc.clone(), name_desc.clone()]).build().unwrap();- let sum4 = Expr::WindowFunction(expr::WindowFunction::new(+ let sum4 = Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::AggregateUDF(sum_udaf()),vec![col("age")],))diff --git a/datafusion/expr/src/window_frame.rs b/datafusion/expr/src/window_frame.rsindex 349968c3fa..222914315d 100644--- a/datafusion/expr/src/window_frame.rs+++ b/datafusion/expr/src/window_frame.rs@@ -94,7 +94,7 @@ pub struct WindowFrame {}impl fmt::Display for WindowFrame {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {write!(f,"{} BETWEEN {} AND {}",@@ -416,7 +416,7 @@ fn convert_frame_bound_to_scalar_value(}impl fmt::Display for WindowFrameBound {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {match self {WindowFrameBound::Preceding(n) => {if n.is_null() {@@ -457,7 +457,7 @@ pub enum WindowFrameUnits {}impl fmt::Display for WindowFrameUnits {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {f.write_str(match self {WindowFrameUnits::Rows => "ROWS",WindowFrameUnits::Range => "RANGE",diff --git a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/bytes.rs b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/bytes.rsindex ee61128979..07fa4efc99 100644--- a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/bytes.rs+++ b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/bytes.rs@@ -25,6 +25,7 @@ use datafusion_expr_common::accumulator::Accumulator;use datafusion_physical_expr_common::binary_map::{ArrowBytesSet, OutputType};use datafusion_physical_expr_common::binary_view_map::ArrowBytesViewSet;use std::fmt::Debug;+use std::mem::size_of_val;use std::sync::Arc;/// Specialized implementation of@@ -86,7 +87,7 @@ impl<O: OffsetSizeTrait> Accumulator for BytesDistinctCountAccumulator<O> {}fn size(&self) -> usize {- std::mem::size_of_val(self) + self.0.size()+ size_of_val(self) + self.0.size()}}@@ -146,6 +147,6 @@ impl Accumulator for BytesViewDistinctCountAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) + self.0.size()+ size_of_val(self) + self.0.size()}}diff --git a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rsindex d128a8af58..405b2c2db7 100644--- a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs+++ b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs@@ -23,6 +23,7 @@use std::collections::HashSet;use std::fmt::Debug;use std::hash::Hash;+use std::mem::size_of_val;use std::sync::Arc;use ahash::RandomState;@@ -117,8 +118,7 @@ wherefn size(&self) -> usize {let num_elements = self.values.len();- let fixed_size =- std::mem::size_of_val(self) + std::mem::size_of_val(&self.values);+ let fixed_size = size_of_val(self) + size_of_val(&self.values);estimate_memory_size::<T::Native>(num_elements, fixed_size).unwrap()}@@ -206,8 +206,7 @@ wherefn size(&self) -> usize {let num_elements = self.values.len();- let fixed_size =- std::mem::size_of_val(self) + std::mem::size_of_val(&self.values);+ let fixed_size = size_of_val(self) + size_of_val(&self.values);estimate_memory_size::<T::Native>(num_elements, fixed_size).unwrap()}diff --git a/datafusion/functions-aggregate-common/src/aggregate/groups_accumulator.rs b/datafusion/functions-aggregate-common/src/aggregate/groups_accumulator.rsindex c936c80cbe..03e4ef5572 100644--- a/datafusion/functions-aggregate-common/src/aggregate/groups_accumulator.rs+++ b/datafusion/functions-aggregate-common/src/aggregate/groups_accumulator.rs@@ -23,6 +23,8 @@ pub mod bool_op;pub mod nulls;pub mod prim_op;+use std::mem::{size_of, size_of_val};+use arrow::array::new_empty_array;use arrow::{array::{ArrayRef, AsArray, BooleanArray, PrimitiveArray},@@ -122,9 +124,7 @@ impl AccumulatorState {/// Returns the amount of memory taken by this structure and its accumulatorfn size(&self) -> usize {- self.accumulator.size()- + std::mem::size_of_val(self)- + self.indices.allocated_size()+ self.accumulator.size() + size_of_val(self) + self.indices.allocated_size()}}@@ -464,7 +464,7 @@ pub trait VecAllocExt {impl<T> VecAllocExt for Vec<T> {type T = T;fn allocated_size(&self) -> usize {- std::mem::size_of::<T>() * self.capacity()+ size_of::<T>() * self.capacity()}}diff --git a/datafusion/functions-aggregate-common/src/aggregate/groups_accumulator/prim_op.rs b/datafusion/functions-aggregate-common/src/aggregate/groups_accumulator/prim_op.rsindex 8bbcf756c3..078982c983 100644--- a/datafusion/functions-aggregate-common/src/aggregate/groups_accumulator/prim_op.rs+++ b/datafusion/functions-aggregate-common/src/aggregate/groups_accumulator/prim_op.rs@@ -15,6 +15,7 @@// specific language governing permissions and limitations// under the License.+use std::mem::size_of;use std::sync::Arc;use arrow::array::{ArrayRef, AsArray, BooleanArray, PrimitiveArray};@@ -195,6 +196,6 @@ where}fn size(&self) -> usize {- self.values.capacity() * std::mem::size_of::<T::Native>() + self.null_state.size()+ self.values.capacity() * size_of::<T::Native>() + self.null_state.size()}}diff --git a/datafusion/functions-aggregate-common/src/tdigest.rs b/datafusion/functions-aggregate-common/src/tdigest.rsindex e6723b54b3..786d7ea3e3 100644--- a/datafusion/functions-aggregate-common/src/tdigest.rs+++ b/datafusion/functions-aggregate-common/src/tdigest.rs@@ -33,6 +33,7 @@ use datafusion_common::cast::as_primitive_array;use datafusion_common::Result;use datafusion_common::ScalarValue;use std::cmp::Ordering;+use std::mem::{size_of, size_of_val};pub const DEFAULT_MAX_SIZE: usize = 100;@@ -203,8 +204,7 @@ impl TDigest {/// Size in bytes including `Self`.pub fn size(&self) -> usize {- std::mem::size_of_val(self)- + (std::mem::size_of::<Centroid>() * self.centroids.capacity())+ size_of_val(self) + (size_of::<Centroid>() * self.centroids.capacity())}}diff --git a/datafusion/functions-aggregate/src/approx_percentile_cont.rs b/datafusion/functions-aggregate/src/approx_percentile_cont.rsindex 83b9f714fa..53fcfd641d 100644--- a/datafusion/functions-aggregate/src/approx_percentile_cont.rs+++ b/datafusion/functions-aggregate/src/approx_percentile_cont.rs@@ -17,6 +17,7 @@use std::any::Any;use std::fmt::{Debug, Formatter};+use std::mem::size_of_val;use std::sync::{Arc, OnceLock};use arrow::array::{Array, RecordBatch};@@ -486,10 +487,9 @@ impl Accumulator for ApproxPercentileAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) + self.digest.size()- - std::mem::size_of_val(&self.digest)+ size_of_val(self) + self.digest.size() - size_of_val(&self.digest)+ self.return_type.size()- - std::mem::size_of_val(&self.return_type)+ - size_of_val(&self.return_type)}}diff --git a/datafusion/functions-aggregate/src/approx_percentile_cont_with_weight.rs b/datafusion/functions-aggregate/src/approx_percentile_cont_with_weight.rsindex b86fec1e03..5458d0f792 100644--- a/datafusion/functions-aggregate/src/approx_percentile_cont_with_weight.rs+++ b/datafusion/functions-aggregate/src/approx_percentile_cont_with_weight.rs@@ -17,6 +17,7 @@use std::any::Any;use std::fmt::{Debug, Formatter};+use std::mem::size_of_val;use std::sync::{Arc, OnceLock};use arrow::{@@ -239,8 +240,7 @@ impl Accumulator for ApproxPercentileWithWeightAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)- - std::mem::size_of_val(&self.approx_percentile_cont_accumulator)+ size_of_val(self) - size_of_val(&self.approx_percentile_cont_accumulator)+ self.approx_percentile_cont_accumulator.size()}}diff --git a/datafusion/functions-aggregate/src/array_agg.rs b/datafusion/functions-aggregate/src/array_agg.rsindex 6f52375683..b3e04c5584 100644--- a/datafusion/functions-aggregate/src/array_agg.rs+++ b/datafusion/functions-aggregate/src/array_agg.rs@@ -34,6 +34,7 @@ use datafusion_functions_aggregate_common::merge_arrays::merge_ordered_arrays;use datafusion_functions_aggregate_common::utils::ordering_fields;use datafusion_physical_expr_common::sort_expr::{LexOrdering, PhysicalSortExpr};use std::collections::{HashSet, VecDeque};+use std::mem::{size_of, size_of_val};use std::sync::{Arc, OnceLock};make_udaf_expr_and_func!(@@ -245,15 +246,15 @@ impl Accumulator for ArrayAggAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)- + (std::mem::size_of::<ArrayRef>() * self.values.capacity())+ size_of_val(self)+ + (size_of::<ArrayRef>() * self.values.capacity())+ self.values.iter().map(|arr| arr.get_array_memory_size()).sum::<usize>()+ self.datatype.size()- - std::mem::size_of_val(&self.datatype)+ - size_of_val(&self.datatype)}}@@ -318,10 +319,10 @@ impl Accumulator for DistinctArrayAggAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) + ScalarValue::size_of_hashset(&self.values)- - std::mem::size_of_val(&self.values)+ size_of_val(self) + ScalarValue::size_of_hashset(&self.values)+ - size_of_val(&self.values)+ self.datatype.size()- - std::mem::size_of_val(&self.datatype)+ - size_of_val(&self.datatype)}}@@ -486,25 +487,23 @@ impl Accumulator for OrderSensitiveArrayAggAccumulator {}fn size(&self) -> usize {- let mut total = std::mem::size_of_val(self)- + ScalarValue::size_of_vec(&self.values)- - std::mem::size_of_val(&self.values);+ let mut total = size_of_val(self) + ScalarValue::size_of_vec(&self.values)+ - size_of_val(&self.values);// Add size of the `self.ordering_values`- total +=- std::mem::size_of::<Vec<ScalarValue>>() * self.ordering_values.capacity();+ total += size_of::<Vec<ScalarValue>>() * self.ordering_values.capacity();for row in &self.ordering_values {- total += ScalarValue::size_of_vec(row) - std::mem::size_of_val(row);+ total += ScalarValue::size_of_vec(row) - size_of_val(row);}// Add size of the `self.datatypes`- total += std::mem::size_of::<DataType>() * self.datatypes.capacity();+ total += size_of::<DataType>() * self.datatypes.capacity();for dtype in &self.datatypes {- total += dtype.size() - std::mem::size_of_val(dtype);+ total += dtype.size() - size_of_val(dtype);}// Add size of the `self.ordering_req`- total += std::mem::size_of::<PhysicalSortExpr>() * self.ordering_req.capacity();+ total += size_of::<PhysicalSortExpr>() * self.ordering_req.capacity();// TODO: Calculate size of each `PhysicalSortExpr` more accurately.total}diff --git a/datafusion/functions-aggregate/src/average.rs b/datafusion/functions-aggregate/src/average.rsindex 67b824c2ea..710b7e69ac 100644--- a/datafusion/functions-aggregate/src/average.rs+++ b/datafusion/functions-aggregate/src/average.rs@@ -18,8 +18,8 @@//! Defines `Avg` & `Mean` aggregate & accumulatorsuse arrow::array::{- self, Array, ArrayRef, ArrowNativeTypeOp, ArrowNumericType, ArrowPrimitiveType,- AsArray, BooleanArray, PrimitiveArray, PrimitiveBuilder, UInt64Array,+ Array, ArrayRef, ArrowNativeTypeOp, ArrowNumericType, ArrowPrimitiveType, AsArray,+ BooleanArray, PrimitiveArray, PrimitiveBuilder, UInt64Array,};use arrow::compute::sum;@@ -47,6 +47,7 @@ use datafusion_functions_aggregate_common::utils::DecimalAverager;use log::debug;use std::any::Any;use std::fmt::Debug;+use std::mem::{size_of, size_of_val};use std::sync::{Arc, OnceLock};make_udaf_expr_and_func!(@@ -294,7 +295,7 @@ impl Accumulator for AvgAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}fn state(&mut self) -> Result<Vec<ScalarValue>> {@@ -372,7 +373,7 @@ impl<T: DecimalType + ArrowNumericType + Debug> Accumulator for DecimalAvgAccumu}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}fn state(&mut self) -> Result<Vec<ScalarValue>> {@@ -471,7 +472,7 @@ where&mut self,values: &[ArrayRef],group_indices: &[usize],- opt_filter: Option<&array::BooleanArray>,+ opt_filter: Option<&BooleanArray>,total_num_groups: usize,) -> Result<()> {assert_eq!(values.len(), 1, "single argument to update_batch");@@ -554,7 +555,7 @@ where&mut self,values: &[ArrayRef],group_indices: &[usize],- opt_filter: Option<&array::BooleanArray>,+ opt_filter: Option<&BooleanArray>,total_num_groups: usize,) -> Result<()> {assert_eq!(values.len(), 2, "two arguments to merge_batch");@@ -614,7 +615,6 @@ where}fn size(&self) -> usize {- self.counts.capacity() * std::mem::size_of::<u64>()- + self.sums.capacity() * std::mem::size_of::<T>()+ self.counts.capacity() * size_of::<u64>() + self.sums.capacity() * size_of::<T>()}}diff --git a/datafusion/functions-aggregate/src/bit_and_or_xor.rs b/datafusion/functions-aggregate/src/bit_and_or_xor.rsindex 0a281ad814..249ff02e72 100644--- a/datafusion/functions-aggregate/src/bit_and_or_xor.rs+++ b/datafusion/functions-aggregate/src/bit_and_or_xor.rs@@ -20,6 +20,7 @@use std::any::Any;use std::collections::HashSet;use std::fmt::{Display, Formatter};+use std::mem::{size_of, size_of_val};use ahash::RandomState;use arrow::array::{downcast_integer, Array, ArrayRef, AsArray};@@ -347,7 +348,7 @@ where}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}fn state(&mut self) -> Result<Vec<ScalarValue>> {@@ -392,7 +393,7 @@ where}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}fn state(&mut self) -> Result<Vec<ScalarValue>> {@@ -446,7 +447,7 @@ where}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}fn state(&mut self) -> Result<Vec<ScalarValue>> {@@ -509,8 +510,7 @@ where}fn size(&self) -> usize {- std::mem::size_of_val(self)- + self.values.capacity() * std::mem::size_of::<T::Native>()+ size_of_val(self) + self.values.capacity() * size_of::<T::Native>()}fn state(&mut self) -> Result<Vec<ScalarValue>> {diff --git a/datafusion/functions-aggregate/src/bool_and_or.rs b/datafusion/functions-aggregate/src/bool_and_or.rsindex b410bfa139..87293ccfa2 100644--- a/datafusion/functions-aggregate/src/bool_and_or.rs+++ b/datafusion/functions-aggregate/src/bool_and_or.rs@@ -18,6 +18,7 @@//! Defines physical expressions that can evaluated at runtime during query executionuse std::any::Any;+use std::mem::size_of_val;use std::sync::OnceLock;use arrow::array::ArrayRef;@@ -229,7 +230,7 @@ impl Accumulator for BoolAndAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}fn state(&mut self) -> Result<Vec<ScalarValue>> {@@ -378,7 +379,7 @@ impl Accumulator for BoolOrAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}fn state(&mut self) -> Result<Vec<ScalarValue>> {diff --git a/datafusion/functions-aggregate/src/correlation.rs b/datafusion/functions-aggregate/src/correlation.rsindex 40429289d7..187a43ecbe 100644--- a/datafusion/functions-aggregate/src/correlation.rs+++ b/datafusion/functions-aggregate/src/correlation.rs@@ -19,6 +19,7 @@use std::any::Any;use std::fmt::Debug;+use std::mem::size_of_val;use std::sync::{Arc, OnceLock};use arrow::compute::{and, filter, is_not_null};@@ -204,11 +205,10 @@ impl Accumulator for CorrelationAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) - std::mem::size_of_val(&self.covar)- + self.covar.size()- - std::mem::size_of_val(&self.stddev1)+ size_of_val(self) - size_of_val(&self.covar) + self.covar.size()+ - size_of_val(&self.stddev1)+ self.stddev1.size()- - std::mem::size_of_val(&self.stddev2)+ - size_of_val(&self.stddev2)+ self.stddev2.size()}diff --git a/datafusion/functions-aggregate/src/count.rs b/datafusion/functions-aggregate/src/count.rsindex b4eeb937d4..bade589a90 100644--- a/datafusion/functions-aggregate/src/count.rs+++ b/datafusion/functions-aggregate/src/count.rs@@ -21,6 +21,7 @@ use datafusion_functions_aggregate_common::aggregate::count_distinct::BytesViewDuse datafusion_physical_expr::expressions;use std::collections::HashSet;use std::fmt::Debug;+use std::mem::{size_of, size_of_val};use std::ops::BitAnd;use std::sync::{Arc, OnceLock};@@ -394,7 +395,7 @@ impl Accumulator for CountAccumulator {fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<()> {let counts = downcast_value!(states[0], Int64Array);- let delta = &arrow::compute::sum(counts);+ let delta = &compute::sum(counts);if let Some(d) = delta {self.count += *d;}@@ -410,7 +411,7 @@ impl Accumulator for CountAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}@@ -583,7 +584,7 @@ impl GroupsAccumulator for CountGroupsAccumulator {}fn size(&self) -> usize {- self.counts.capacity() * std::mem::size_of::<usize>()+ self.counts.capacity() * size_of::<usize>()}}@@ -627,28 +628,28 @@ impl DistinctCountAccumulator {// number of batches This method is faster than .full_size(), however it is// not suitable for variable length values like strings or complex typesfn fixed_size(&self) -> usize {- std::mem::size_of_val(self)- + (std::mem::size_of::<ScalarValue>() * self.values.capacity())+ size_of_val(self)+ + (size_of::<ScalarValue>() * self.values.capacity())+ self.values.iter().next()- .map(|vals| ScalarValue::size(vals) - std::mem::size_of_val(vals))+ .map(|vals| ScalarValue::size(vals) - size_of_val(vals)).unwrap_or(0)- + std::mem::size_of::<DataType>()+ + size_of::<DataType>()}// calculates the size as accurately as possible. Note that calling this// method is expensivefn full_size(&self) -> usize {- std::mem::size_of_val(self)- + (std::mem::size_of::<ScalarValue>() * self.values.capacity())+ size_of_val(self)+ + (size_of::<ScalarValue>() * self.values.capacity())+ self.values.iter()- .map(|vals| ScalarValue::size(vals) - std::mem::size_of_val(vals))+ .map(|vals| ScalarValue::size(vals) - size_of_val(vals)).sum::<usize>()- + std::mem::size_of::<DataType>()+ + size_of::<DataType>()}}diff --git a/datafusion/functions-aggregate/src/covariance.rs b/datafusion/functions-aggregate/src/covariance.rsindex 4b2b21059d..063aaa9205 100644--- a/datafusion/functions-aggregate/src/covariance.rs+++ b/datafusion/functions-aggregate/src/covariance.rs@@ -18,6 +18,7 @@//! [`CovarianceSample`]: covariance sample aggregations.use std::fmt::Debug;+use std::mem::size_of_val;use std::sync::OnceLock;use arrow::{@@ -448,6 +449,6 @@ impl Accumulator for CovarianceAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}diff --git a/datafusion/functions-aggregate/src/first_last.rs b/datafusion/functions-aggregate/src/first_last.rsindex c708d23ae6..da3fc62f8c 100644--- a/datafusion/functions-aggregate/src/first_last.rs+++ b/datafusion/functions-aggregate/src/first_last.rs@@ -19,6 +19,7 @@use std::any::Any;use std::fmt::Debug;+use std::mem::size_of_val;use std::sync::{Arc, OnceLock};use arrow::array::{ArrayRef, AsArray, BooleanArray};@@ -365,10 +366,10 @@ impl Accumulator for FirstValueAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) - std::mem::size_of_val(&self.first)+ size_of_val(self) - size_of_val(&self.first)+ self.first.size()+ ScalarValue::size_of_vec(&self.orderings)- - std::mem::size_of_val(&self.orderings)+ - size_of_val(&self.orderings)}}@@ -698,10 +699,10 @@ impl Accumulator for LastValueAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) - std::mem::size_of_val(&self.last)+ size_of_val(self) - size_of_val(&self.last)+ self.last.size()+ ScalarValue::size_of_vec(&self.orderings)- - std::mem::size_of_val(&self.orderings)+ - size_of_val(&self.orderings)}}@@ -795,7 +796,7 @@ mod tests {let mut states = vec![];for idx in 0..state1.len() {- states.push(arrow::compute::concat(&[+ states.push(compute::concat(&[&state1[idx].to_array()?,&state2[idx].to_array()?,])?);@@ -825,7 +826,7 @@ mod tests {let mut states = vec![];for idx in 0..state1.len() {- states.push(arrow::compute::concat(&[+ states.push(compute::concat(&[&state1[idx].to_array()?,&state2[idx].to_array()?,])?);diff --git a/datafusion/functions-aggregate/src/grouping.rs b/datafusion/functions-aggregate/src/grouping.rsindex 558d3055f1..27949aa3df 100644--- a/datafusion/functions-aggregate/src/grouping.rs+++ b/datafusion/functions-aggregate/src/grouping.rs@@ -45,7 +45,7 @@ pub struct Grouping {}impl fmt::Debug for Grouping {- fn fmt(&self, f: &mut std::fmt::Formatter) -> fmt::Result {+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {f.debug_struct("Grouping").field("name", &self.name()).field("signature", &self.signature)diff --git a/datafusion/functions-aggregate/src/median.rs b/datafusion/functions-aggregate/src/median.rsindex e0011e2e0f..ff0a930d49 100644--- a/datafusion/functions-aggregate/src/median.rs+++ b/datafusion/functions-aggregate/src/median.rs@@ -17,6 +17,7 @@use std::collections::HashSet;use std::fmt::{Debug, Formatter};+use std::mem::{size_of, size_of_val};use std::sync::{Arc, OnceLock};use arrow::array::{downcast_integer, ArrowNumericType};@@ -62,7 +63,7 @@ pub struct Median {}impl Debug for Median {- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {f.debug_struct("Median").field("name", &self.name()).field("signature", &self.signature)@@ -195,7 +196,7 @@ struct MedianAccumulator<T: ArrowNumericType> {all_values: Vec<T::Native>,}-impl<T: ArrowNumericType> std::fmt::Debug for MedianAccumulator<T> {+impl<T: ArrowNumericType> Debug for MedianAccumulator<T> {fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {write!(f, "MedianAccumulator({})", self.data_type)}@@ -235,8 +236,7 @@ impl<T: ArrowNumericType> Accumulator for MedianAccumulator<T> {}fn size(&self) -> usize {- std::mem::size_of_val(self)- + self.all_values.capacity() * std::mem::size_of::<T::Native>()+ size_of_val(self) + self.all_values.capacity() * size_of::<T::Native>()}}@@ -252,7 +252,7 @@ struct DistinctMedianAccumulator<T: ArrowNumericType> {distinct_values: HashSet<Hashable<T::Native>>,}-impl<T: ArrowNumericType> std::fmt::Debug for DistinctMedianAccumulator<T> {+impl<T: ArrowNumericType> Debug for DistinctMedianAccumulator<T> {fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {write!(f, "DistinctMedianAccumulator({})", self.data_type)}@@ -307,8 +307,7 @@ impl<T: ArrowNumericType> Accumulator for DistinctMedianAccumulator<T> {}fn size(&self) -> usize {- std::mem::size_of_val(self)- + self.distinct_values.capacity() * std::mem::size_of::<T::Native>()+ size_of_val(self) + self.distinct_values.capacity() * size_of::<T::Native>()}}diff --git a/datafusion/functions-aggregate/src/min_max.rs b/datafusion/functions-aggregate/src/min_max.rsindex 8102d0e479..b4256508e3 100644--- a/datafusion/functions-aggregate/src/min_max.rs+++ b/datafusion/functions-aggregate/src/min_max.rs@@ -60,6 +60,7 @@ use datafusion_expr::{};use datafusion_expr::{GroupsAccumulator, StatisticsArgs};use half::f16;+use std::mem::size_of_val;use std::ops::Deref;use std::sync::OnceLock;@@ -923,7 +924,7 @@ impl Accumulator for MaxAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) - std::mem::size_of_val(&self.max) + self.max.size()+ size_of_val(self) - size_of_val(&self.max) + self.max.size()}}@@ -982,7 +983,7 @@ impl Accumulator for SlidingMaxAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) - std::mem::size_of_val(&self.max) + self.max.size()+ size_of_val(self) - size_of_val(&self.max) + self.max.size()}}@@ -1231,7 +1232,7 @@ impl Accumulator for MinAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) - std::mem::size_of_val(&self.min) + self.min.size()+ size_of_val(self) - size_of_val(&self.min) + self.min.size()}}@@ -1294,7 +1295,7 @@ impl Accumulator for SlidingMinAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self) - std::mem::size_of_val(&self.min) + self.min.size()+ size_of_val(self) - size_of_val(&self.min) + self.min.size()}}diff --git a/datafusion/functions-aggregate/src/min_max/min_max_bytes.rs b/datafusion/functions-aggregate/src/min_max/min_max_bytes.rsindex e3f01b91bf..501454edf7 100644--- a/datafusion/functions-aggregate/src/min_max/min_max_bytes.rs+++ b/datafusion/functions-aggregate/src/min_max/min_max_bytes.rs@@ -22,6 +22,7 @@ use arrow_schema::DataType;use datafusion_common::{internal_err, Result};use datafusion_expr::{EmitTo, GroupsAccumulator};use datafusion_functions_aggregate_common::aggregate::groups_accumulator::nulls::apply_filter_as_nulls;+use std::mem::size_of;use std::sync::Arc;/// Implements fast Min/Max [`GroupsAccumulator`] for "bytes" types ([`StringArray`],@@ -509,7 +510,6 @@ impl MinMaxBytesState {}fn size(&self) -> usize {- self.total_data_bytes- + self.min_max.len() * std::mem::size_of::<Option<Vec<u8>>>()+ self.total_data_bytes + self.min_max.len() * size_of::<Option<Vec<u8>>>()}}diff --git a/datafusion/functions-aggregate/src/nth_value.rs b/datafusion/functions-aggregate/src/nth_value.rsindex 3e7f51af52..2a1778d8b2 100644--- a/datafusion/functions-aggregate/src/nth_value.rs+++ b/datafusion/functions-aggregate/src/nth_value.rs@@ -20,6 +20,7 @@use std::any::Any;use std::collections::VecDeque;+use std::mem::{size_of, size_of_val};use std::sync::{Arc, OnceLock};use arrow::array::{new_empty_array, ArrayRef, AsArray, StructArray};@@ -378,25 +379,23 @@ impl Accumulator for NthValueAccumulator {}fn size(&self) -> usize {- let mut total = std::mem::size_of_val(self)- + ScalarValue::size_of_vec_deque(&self.values)- - std::mem::size_of_val(&self.values);+ let mut total = size_of_val(self) + ScalarValue::size_of_vec_deque(&self.values)+ - size_of_val(&self.values);// Add size of the `self.ordering_values`- total +=- std::mem::size_of::<Vec<ScalarValue>>() * self.ordering_values.capacity();+ total += size_of::<Vec<ScalarValue>>() * self.ordering_values.capacity();for row in &self.ordering_values {- total += ScalarValue::size_of_vec(row) - std::mem::size_of_val(row);+ total += ScalarValue::size_of_vec(row) - size_of_val(row);}// Add size of the `self.datatypes`- total += std::mem::size_of::<DataType>() * self.datatypes.capacity();+ total += size_of::<DataType>() * self.datatypes.capacity();for dtype in &self.datatypes {- total += dtype.size() - std::mem::size_of_val(dtype);+ total += dtype.size() - size_of_val(dtype);}// Add size of the `self.ordering_req`- total += std::mem::size_of::<PhysicalSortExpr>() * self.ordering_req.capacity();+ total += size_of::<PhysicalSortExpr>() * self.ordering_req.capacity();// TODO: Calculate size of each `PhysicalSortExpr` more accurately.total}diff --git a/datafusion/functions-aggregate/src/regr.rs b/datafusion/functions-aggregate/src/regr.rsindex a1fc5b0942..bf1e81949d 100644--- a/datafusion/functions-aggregate/src/regr.rs+++ b/datafusion/functions-aggregate/src/regr.rs@@ -36,6 +36,7 @@ use datafusion_expr::{use std::any::Any;use std::collections::HashMap;use std::fmt::Debug;+use std::mem::size_of_val;use std::sync::OnceLock;macro_rules! make_regr_udaf_expr_and_func {@@ -614,6 +615,6 @@ impl Accumulator for RegrAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}diff --git a/datafusion/functions-aggregate/src/stddev.rs b/datafusion/functions-aggregate/src/stddev.rsindex 0d18216875..355d1d5ad2 100644--- a/datafusion/functions-aggregate/src/stddev.rs+++ b/datafusion/functions-aggregate/src/stddev.rs@@ -19,6 +19,7 @@use std::any::Any;use std::fmt::{Debug, Formatter};+use std::mem::align_of_val;use std::sync::{Arc, OnceLock};use arrow::array::Float64Array;@@ -343,8 +344,7 @@ impl Accumulator for StddevAccumulator {}fn size(&self) -> usize {- std::mem::align_of_val(self) - std::mem::align_of_val(&self.variance)- + self.variance.size()+ align_of_val(self) - align_of_val(&self.variance) + self.variance.size()}fn supports_retract_batch(&self) -> bool {diff --git a/datafusion/functions-aggregate/src/string_agg.rs b/datafusion/functions-aggregate/src/string_agg.rsindex 66fc199106..68267b9f72 100644--- a/datafusion/functions-aggregate/src/string_agg.rs+++ b/datafusion/functions-aggregate/src/string_agg.rs@@ -29,6 +29,7 @@ use datafusion_expr::{};use datafusion_physical_expr::expressions::Literal;use std::any::Any;+use std::mem::size_of_val;use std::sync::OnceLock;make_udaf_expr_and_func!(@@ -179,7 +180,7 @@ impl Accumulator for StringAggAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)+ self.values.as_ref().map(|v| v.capacity()).unwrap_or(0)+ self.delimiter.capacity()}diff --git a/datafusion/functions-aggregate/src/sum.rs b/datafusion/functions-aggregate/src/sum.rsindex 943f66a92c..6ad376db4f 100644--- a/datafusion/functions-aggregate/src/sum.rs+++ b/datafusion/functions-aggregate/src/sum.rs@@ -21,6 +21,7 @@ use ahash::RandomState;use datafusion_expr::utils::AggregateOrderSensitivity;use std::any::Any;use std::collections::HashSet;+use std::mem::{size_of, size_of_val};use std::sync::OnceLock;use arrow::array::Array;@@ -310,7 +311,7 @@ impl<T: ArrowNumericType> Accumulator for SumAccumulator<T> {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}@@ -370,7 +371,7 @@ impl<T: ArrowNumericType> Accumulator for SlidingSumAccumulator<T> {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}fn retract_batch(&mut self, values: &[ArrayRef]) -> Result<()> {@@ -464,7 +465,6 @@ impl<T: ArrowPrimitiveType> Accumulator for DistinctSumAccumulator<T> {}fn size(&self) -> usize {- std::mem::size_of_val(self)- + self.values.capacity() * std::mem::size_of::<T::Native>()+ size_of_val(self) + self.values.capacity() * size_of::<T::Native>()}}diff --git a/datafusion/functions-aggregate/src/variance.rs b/datafusion/functions-aggregate/src/variance.rsindex 8453c9d301..810247a288 100644--- a/datafusion/functions-aggregate/src/variance.rs+++ b/datafusion/functions-aggregate/src/variance.rs@@ -24,6 +24,7 @@ use arrow::{compute::kernels::cast,datatypes::{DataType, Field},};+use std::mem::{size_of, size_of_val};use std::sync::OnceLock;use std::{fmt::Debug, sync::Arc};@@ -424,7 +425,7 @@ impl Accumulator for VarianceAccumulator {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}fn supports_retract_batch(&self) -> bool {@@ -529,7 +530,7 @@ impl GroupsAccumulator for VarianceGroupsAccumulator {&mut self,values: &[ArrayRef],group_indices: &[usize],- opt_filter: Option<&arrow::array::BooleanArray>,+ opt_filter: Option<&BooleanArray>,total_num_groups: usize,) -> Result<()> {assert_eq!(values.len(), 1, "single argument to update_batch");@@ -555,7 +556,7 @@ impl GroupsAccumulator for VarianceGroupsAccumulator {&mut self,values: &[ArrayRef],group_indices: &[usize],- opt_filter: Option<&arrow::array::BooleanArray>,+ opt_filter: Option<&BooleanArray>,total_num_groups: usize,) -> Result<()> {assert_eq!(values.len(), 3, "two arguments to merge_batch");@@ -606,8 +607,8 @@ impl GroupsAccumulator for VarianceGroupsAccumulator {}fn size(&self) -> usize {- self.m2s.capacity() * std::mem::size_of::<f64>()- + self.means.capacity() * std::mem::size_of::<f64>()- + self.counts.capacity() * std::mem::size_of::<u64>()+ self.m2s.capacity() * size_of::<f64>()+ + self.means.capacity() * size_of::<f64>()+ + self.counts.capacity() * size_of::<u64>()}}diff --git a/datafusion/functions-nested/src/distance.rs b/datafusion/functions-nested/src/distance.rsindex 19a2269098..4f890e4166 100644--- a/datafusion/functions-nested/src/distance.rs+++ b/datafusion/functions-nested/src/distance.rs@@ -247,7 +247,7 @@ fn compute_array_distance(/// Converts an array of any numeric type to a Float64Array.fn convert_to_f64_array(array: &ArrayRef) -> Result<Float64Array> {match array.data_type() {- DataType::Float64 => Ok(as_float64_array(array)?.clone()),+ Float64 => Ok(as_float64_array(array)?.clone()),DataType::Float32 => {let array = as_float32_array(array)?;let converted: Float64Array =diff --git a/datafusion/functions-nested/src/make_array.rs b/datafusion/functions-nested/src/make_array.rsindex abd7649e9e..c2c6f24948 100644--- a/datafusion/functions-nested/src/make_array.rs+++ b/datafusion/functions-nested/src/make_array.rs@@ -122,7 +122,7 @@ impl ScalarUDFImpl for MakeArray {if let Some(new_type) = type_union_resolution(arg_types) {// TODO: Move FixedSizeList to List in type_union_resolutionif let DataType::FixedSizeList(field, _) = new_type {- Ok(vec![DataType::List(field); arg_types.len()])+ Ok(vec![List(field); arg_types.len()])} else if new_type.is_null() {Ok(vec![DataType::Int64; arg_types.len()])} else {@@ -174,7 +174,7 @@ fn get_make_array_doc() -> &'static Documentation {// Empty array is a special case that is useful for many other array functionspub(super) fn empty_array_type() -> DataType {- DataType::List(Arc::new(Field::new("item", DataType::Int64, true)))+ List(Arc::new(Field::new("item", DataType::Int64, true)))}/// `make_array_inner` is the implementation of the `make_array` function.diff --git a/datafusion/functions-nested/src/map_keys.rs b/datafusion/functions-nested/src/map_keys.rsindex f28de1c3b2..03e381e372 100644--- a/datafusion/functions-nested/src/map_keys.rs+++ b/datafusion/functions-nested/src/map_keys.rs@@ -66,7 +66,7 @@ impl ScalarUDFImpl for MapKeysFunc {&self.signature}- fn return_type(&self, arg_types: &[DataType]) -> datafusion_common::Result<DataType> {+ fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {if arg_types.len() != 1 {return exec_err!("map_keys expects single argument");}@@ -79,7 +79,7 @@ impl ScalarUDFImpl for MapKeysFunc {))))}- fn invoke(&self, args: &[ColumnarValue]) -> datafusion_common::Result<ColumnarValue> {+ fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {make_scalar_function(map_keys_inner)(args)}diff --git a/datafusion/functions-nested/src/map_values.rs b/datafusion/functions-nested/src/map_values.rsindex 2b19d9fbbc..dc7d9c9db8 100644--- a/datafusion/functions-nested/src/map_values.rs+++ b/datafusion/functions-nested/src/map_values.rs@@ -66,7 +66,7 @@ impl ScalarUDFImpl for MapValuesFunc {&self.signature}- fn return_type(&self, arg_types: &[DataType]) -> datafusion_common::Result<DataType> {+ fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {if arg_types.len() != 1 {return exec_err!("map_values expects single argument");}@@ -79,7 +79,7 @@ impl ScalarUDFImpl for MapValuesFunc {))))}- fn invoke(&self, args: &[ColumnarValue]) -> datafusion_common::Result<ColumnarValue> {+ fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {make_scalar_function(map_values_inner)(args)}diff --git a/datafusion/functions/src/core/named_struct.rs b/datafusion/functions/src/core/named_struct.rsindex 342f99274a..b2c7f06d58 100644--- a/datafusion/functions/src/core/named_struct.rs+++ b/datafusion/functions/src/core/named_struct.rs@@ -124,7 +124,7 @@ impl ScalarUDFImpl for NamedStructFunc {fn return_type_from_exprs(&self,- args: &[datafusion_expr::Expr],+ args: &[Expr],schema: &dyn datafusion_common::ExprSchema,_arg_types: &[DataType],) -> Result<DataType> {diff --git a/datafusion/functions/src/core/planner.rs b/datafusion/functions/src/core/planner.rsindex 5873b4e1af..717a74797c 100644--- a/datafusion/functions/src/core/planner.rs+++ b/datafusion/functions/src/core/planner.rs@@ -49,7 +49,7 @@ impl ExprPlanner for CoreFunctionPlanner {Ok(PlannerResult::Planned(Expr::ScalarFunction(ScalarFunction::new_udf(if is_named_struct {- crate::core::named_struct()+ named_struct()} else {crate::core::r#struct()},diff --git a/datafusion/functions/src/datetime/make_date.rs b/datafusion/functions/src/datetime/make_date.rsindex 78bd7c63a4..c8ef349dfb 100644--- a/datafusion/functions/src/datetime/make_date.rs+++ b/datafusion/functions/src/datetime/make_date.rs@@ -89,9 +89,9 @@ impl ScalarUDFImpl for MakeDateFunc {ColumnarValue::Array(a) => Some(a.len()),});- let years = args[0].cast_to(&DataType::Int32, None)?;- let months = args[1].cast_to(&DataType::Int32, None)?;- let days = args[2].cast_to(&DataType::Int32, None)?;+ let years = args[0].cast_to(&Int32, None)?;+ let months = args[1].cast_to(&Int32, None)?;+ let days = args[2].cast_to(&Int32, None)?;let scalar_value_fn = |col: &ColumnarValue| -> Result<i32> {let ColumnarValue::Scalar(s) = col else {diff --git a/datafusion/functions/src/datetime/to_char.rs b/datafusion/functions/src/datetime/to_char.rsindex 430dcedd92..2fbfb22611 100644--- a/datafusion/functions/src/datetime/to_char.rs+++ b/datafusion/functions/src/datetime/to_char.rs@@ -222,10 +222,7 @@ fn _to_char_scalar(if is_scalar_expression {return Ok(ColumnarValue::Scalar(ScalarValue::Utf8(None)));} else {- return Ok(ColumnarValue::Array(new_null_array(- &DataType::Utf8,- array.len(),- )));+ return Ok(ColumnarValue::Array(new_null_array(&Utf8, array.len())));}}diff --git a/datafusion/functions/src/datetime/to_local_time.rs b/datafusion/functions/src/datetime/to_local_time.rsindex 7646137ce6..376cb6f5f2 100644--- a/datafusion/functions/src/datetime/to_local_time.rs+++ b/datafusion/functions/src/datetime/to_local_time.rs@@ -68,7 +68,7 @@ impl ToLocalTimeFunc {let time_value = &args[0];let arg_type = time_value.data_type();match arg_type {- DataType::Timestamp(_, None) => {+ Timestamp(_, None) => {// if no timezone specified, just return the inputOk(time_value.clone())}@@ -78,7 +78,7 @@ impl ToLocalTimeFunc {// for more details.//// Then remove the timezone in return type, i.e. return None- DataType::Timestamp(_, Some(timezone)) => {+ Timestamp(_, Some(timezone)) => {let tz: Tz = timezone.parse()?;match time_value {diff --git a/datafusion/functions/src/datetime/to_timestamp.rs b/datafusion/functions/src/datetime/to_timestamp.rsindex 9479e25fe6..60482ee3c7 100644--- a/datafusion/functions/src/datetime/to_timestamp.rs+++ b/datafusion/functions/src/datetime/to_timestamp.rs@@ -374,7 +374,7 @@ impl ScalarUDFImpl for ToTimestampMillisFunc {static TO_TIMESTAMP_MILLIS_DOC: OnceLock<Documentation> = OnceLock::new();fn get_to_timestamp_millis_doc() -> &'static Documentation {- crate::datetime::to_timestamp::TO_TIMESTAMP_MILLIS_DOC.get_or_init(|| {+ TO_TIMESTAMP_MILLIS_DOC.get_or_init(|| {Documentation::builder().with_doc_section(DOC_SECTION_DATETIME).with_description("Converts a value to a timestamp (`YYYY-MM-DDT00:00:00.000Z`). Supports strings, integer, and unsigned integer types as input. Strings are parsed as RFC3339 (e.g. '2023-07-20T05:44:00') if no [Chrono formats](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) are provided. Integers and unsigned integers are interpreted as milliseconds since the unix epoch (`1970-01-01T00:00:00Z`). Returns the corresponding timestamp.")@@ -1008,7 +1008,7 @@ mod tests {for udf in &udfs {for array in arrays {let rt = udf.return_type(&[array.data_type()]).unwrap();- assert!(matches!(rt, DataType::Timestamp(_, Some(_))));+ assert!(matches!(rt, Timestamp(_, Some(_))));let res = udf.invoke(&[array.clone()])@@ -1018,7 +1018,7 @@ mod tests {_ => panic!("Expected a columnar array"),};let ty = array.data_type();- assert!(matches!(ty, DataType::Timestamp(_, Some(_))));+ assert!(matches!(ty, Timestamp(_, Some(_))));}}@@ -1051,7 +1051,7 @@ mod tests {for udf in &udfs {for array in arrays {let rt = udf.return_type(&[array.data_type()]).unwrap();- assert!(matches!(rt, DataType::Timestamp(_, None)));+ assert!(matches!(rt, Timestamp(_, None)));let res = udf.invoke(&[array.clone()])@@ -1061,7 +1061,7 @@ mod tests {_ => panic!("Expected a columnar array"),};let ty = array.data_type();- assert!(matches!(ty, DataType::Timestamp(_, None)));+ assert!(matches!(ty, Timestamp(_, None)));}}}@@ -1137,10 +1137,7 @@ mod tests {.expect("that to_timestamp with format args parsed values without error");if let ColumnarValue::Array(parsed_array) = parsed_timestamps {assert_eq!(parsed_array.len(), 1);- assert!(matches!(- parsed_array.data_type(),- DataType::Timestamp(_, None)- ));+ assert!(matches!(parsed_array.data_type(), Timestamp(_, None)));match time_unit {Nanosecond => {diff --git a/datafusion/functions/src/math/factorial.rs b/datafusion/functions/src/math/factorial.rsindex 4b87284744..bacdf47524 100644--- a/datafusion/functions/src/math/factorial.rs+++ b/datafusion/functions/src/math/factorial.rs@@ -94,7 +94,7 @@ fn get_factorial_doc() -> &'static Documentation {/// Factorial SQL functionfn factorial(args: &[ArrayRef]) -> Result<ArrayRef> {match args[0].data_type() {- DataType::Int64 => {+ Int64 => {let arg = downcast_arg!((&args[0]), "value", Int64Array);Ok(arg.iter()diff --git a/datafusion/functions/src/math/round.rs b/datafusion/functions/src/math/round.rsindex cf0f53a80a..6000e5d765 100644--- a/datafusion/functions/src/math/round.rs+++ b/datafusion/functions/src/math/round.rs@@ -138,7 +138,7 @@ pub fn round(args: &[ArrayRef]) -> Result<ArrayRef> {}match args[0].data_type() {- DataType::Float64 => match decimal_places {+ Float64 => match decimal_places {ColumnarValue::Scalar(ScalarValue::Int64(Some(decimal_places))) => {let decimal_places: i32 = decimal_places.try_into().map_err(|e| {exec_datafusion_err!(@@ -181,7 +181,7 @@ pub fn round(args: &[ArrayRef]) -> Result<ArrayRef> {}},- DataType::Float32 => match decimal_places {+ Float32 => match decimal_places {ColumnarValue::Scalar(ScalarValue::Int64(Some(decimal_places))) => {let decimal_places: i32 = decimal_places.try_into().map_err(|e| {exec_datafusion_err!(diff --git a/datafusion/functions/src/strings.rs b/datafusion/functions/src/strings.rsindex 2e0e2c4839..e0cec3cb57 100644--- a/datafusion/functions/src/strings.rs+++ b/datafusion/functions/src/strings.rs@@ -15,6 +15,8 @@// specific language governing permissions and limitations// under the License.+use std::mem::size_of;+use arrow::array::{make_view, Array, ArrayAccessor, ArrayDataBuilder, ArrayIter, ByteView,GenericStringArray, LargeStringArray, OffsetSizeTrait, StringArray, StringViewArray,@@ -122,9 +124,8 @@ pub struct StringArrayBuilder {impl StringArrayBuilder {pub fn with_capacity(item_capacity: usize, data_capacity: usize) -> Self {- let mut offsets_buffer = MutableBuffer::with_capacity(- (item_capacity + 1) * std::mem::size_of::<i32>(),- );+ let mut offsets_buffer =+ MutableBuffer::with_capacity((item_capacity + 1) * size_of::<i32>());// SAFETY: the first offset value is definitely not going to exceed the bounds.unsafe { offsets_buffer.push_unchecked(0_i32) };Self {@@ -186,7 +187,7 @@ impl StringArrayBuilder {pub fn finish(self, null_buffer: Option<NullBuffer>) -> StringArray {let array_builder = ArrayDataBuilder::new(DataType::Utf8)- .len(self.offsets_buffer.len() / std::mem::size_of::<i32>() - 1)+ .len(self.offsets_buffer.len() / size_of::<i32>() - 1).add_buffer(self.offsets_buffer.into()).add_buffer(self.value_buffer.into()).nulls(null_buffer);@@ -273,9 +274,8 @@ pub struct LargeStringArrayBuilder {impl LargeStringArrayBuilder {pub fn with_capacity(item_capacity: usize, data_capacity: usize) -> Self {- let mut offsets_buffer = MutableBuffer::with_capacity(- (item_capacity + 1) * std::mem::size_of::<i64>(),- );+ let mut offsets_buffer =+ MutableBuffer::with_capacity((item_capacity + 1) * size_of::<i64>());// SAFETY: the first offset value is definitely not going to exceed the bounds.unsafe { offsets_buffer.push_unchecked(0_i64) };Self {@@ -337,7 +337,7 @@ impl LargeStringArrayBuilder {pub fn finish(self, null_buffer: Option<NullBuffer>) -> LargeStringArray {let array_builder = ArrayDataBuilder::new(DataType::LargeUtf8)- .len(self.offsets_buffer.len() / std::mem::size_of::<i64>() - 1)+ .len(self.offsets_buffer.len() / size_of::<i64>() - 1).add_buffer(self.offsets_buffer.into()).add_buffer(self.value_buffer.into()).nulls(null_buffer);diff --git a/datafusion/functions/src/utils.rs b/datafusion/functions/src/utils.rsindex 818b4c64bd..4d6574d2bd 100644--- a/datafusion/functions/src/utils.rs+++ b/datafusion/functions/src/utils.rs@@ -107,7 +107,7 @@ where};arg.clone().into_array(expansion_len)})- .collect::<datafusion_common::Result<Vec<_>>>()?;+ .collect::<Result<Vec<_>>>()?;let result = (inner)(&args);if is_scalar {diff --git a/datafusion/optimizer/src/analyzer/count_wildcard_rule.rs b/datafusion/optimizer/src/analyzer/count_wildcard_rule.rsindex b3b2472455..454afa24b6 100644--- a/datafusion/optimizer/src/analyzer/count_wildcard_rule.rs+++ b/datafusion/optimizer/src/analyzer/count_wildcard_rule.rs@@ -101,7 +101,7 @@ mod tests {use datafusion_expr::expr::Sort;use datafusion_expr::ExprFunctionExt;use datafusion_expr::{- col, exists, expr, in_subquery, logical_plan::LogicalPlanBuilder, out_ref_col,+ col, exists, in_subquery, logical_plan::LogicalPlanBuilder, out_ref_col,scalar_subquery, wildcard, WindowFrame, WindowFrameBound, WindowFrameUnits,};use datafusion_functions_aggregate::count::count_udaf;@@ -219,7 +219,7 @@ mod tests {let table_scan = test_table_scan()?;let plan = LogicalPlanBuilder::from(table_scan)- .window(vec![Expr::WindowFunction(expr::WindowFunction::new(+ .window(vec![Expr::WindowFunction(WindowFunction::new(WindowFunctionDefinition::AggregateUDF(count_udaf()),vec![wildcard()],))diff --git a/datafusion/optimizer/src/analyzer/subquery.rs b/datafusion/optimizer/src/analyzer/subquery.rsindex 7c0bddf115..0ffc954388 100644--- a/datafusion/optimizer/src/analyzer/subquery.rs+++ b/datafusion/optimizer/src/analyzer/subquery.rs@@ -305,7 +305,7 @@ mod test {vec![]}- fn schema(&self) -> &datafusion_common::DFSchemaRef {+ fn schema(&self) -> &DFSchemaRef {&self.empty_schema}diff --git a/datafusion/optimizer/src/analyzer/type_coercion.rs b/datafusion/optimizer/src/analyzer/type_coercion.rsindex 33eea1a661..5d33b58a02 100644--- a/datafusion/optimizer/src/analyzer/type_coercion.rs+++ b/datafusion/optimizer/src/analyzer/type_coercion.rs@@ -1243,7 +1243,7 @@ mod test {}fn return_type(&self, _args: &[DataType]) -> Result<DataType> {- Ok(DataType::Utf8)+ Ok(Utf8)}fn invoke(&self, _args: &[ColumnarValue]) -> Result<ColumnarValue> {@@ -1446,7 +1446,7 @@ mod test {cast(lit("2002-05-08"), DataType::Date32)+ lit(ScalarValue::new_interval_ym(0, 1)),);- let empty = empty_with_type(DataType::Utf8);+ let empty = empty_with_type(Utf8);let plan = LogicalPlan::Filter(Filter::try_new(expr, empty)?);let expected ="Filter: a BETWEEN Utf8(\"2002-05-08\") AND CAST(CAST(Utf8(\"2002-05-08\") AS Date32) + IntervalYearMonth(\"1\") AS Utf8)\@@ -1462,7 +1462,7 @@ mod test {+ lit(ScalarValue::new_interval_ym(0, 1)),lit("2002-12-08"),);- let empty = empty_with_type(DataType::Utf8);+ let empty = empty_with_type(Utf8);let plan = LogicalPlan::Filter(Filter::try_new(expr, empty)?);// TODO: we should cast col(a).let expected =@@ -1517,7 +1517,7 @@ mod test {let expr = Box::new(col("a"));let pattern = Box::new(lit(ScalarValue::new_utf8("abc")));let like_expr = Expr::Like(Like::new(false, expr, pattern, None, false));- let empty = empty_with_type(DataType::Utf8);+ let empty = empty_with_type(Utf8);let plan = LogicalPlan::Projection(Projection::try_new(vec![like_expr], empty)?);let expected = "Projection: a LIKE Utf8(\"abc\")\n EmptyRelation";assert_analyzed_plan_eq(Arc::new(TypeCoercion::new()), plan, expected)?;@@ -1525,7 +1525,7 @@ mod test {let expr = Box::new(col("a"));let pattern = Box::new(lit(ScalarValue::Null));let like_expr = Expr::Like(Like::new(false, expr, pattern, None, false));- let empty = empty_with_type(DataType::Utf8);+ let empty = empty_with_type(Utf8);let plan = LogicalPlan::Projection(Projection::try_new(vec![like_expr], empty)?);let expected = "Projection: a LIKE CAST(NULL AS Utf8)\n EmptyRelation";assert_analyzed_plan_eq(Arc::new(TypeCoercion::new()), plan, expected)?;@@ -1545,7 +1545,7 @@ mod test {let expr = Box::new(col("a"));let pattern = Box::new(lit(ScalarValue::new_utf8("abc")));let ilike_expr = Expr::Like(Like::new(false, expr, pattern, None, true));- let empty = empty_with_type(DataType::Utf8);+ let empty = empty_with_type(Utf8);let plan = LogicalPlan::Projection(Projection::try_new(vec![ilike_expr], empty)?);let expected = "Projection: a ILIKE Utf8(\"abc\")\n EmptyRelation";assert_analyzed_plan_eq(Arc::new(TypeCoercion::new()), plan, expected)?;@@ -1553,7 +1553,7 @@ mod test {let expr = Box::new(col("a"));let pattern = Box::new(lit(ScalarValue::Null));let ilike_expr = Expr::Like(Like::new(false, expr, pattern, None, true));- let empty = empty_with_type(DataType::Utf8);+ let empty = empty_with_type(Utf8);let plan = LogicalPlan::Projection(Projection::try_new(vec![ilike_expr], empty)?);let expected = "Projection: a ILIKE CAST(NULL AS Utf8)\n EmptyRelation";assert_analyzed_plan_eq(Arc::new(TypeCoercion::new()), plan, expected)?;@@ -1581,7 +1581,7 @@ mod test {let expected = "Projection: a IS UNKNOWN\n EmptyRelation";assert_analyzed_plan_eq(Arc::new(TypeCoercion::new()), plan, expected)?;- let empty = empty_with_type(DataType::Utf8);+ let empty = empty_with_type(Utf8);let plan = LogicalPlan::Projection(Projection::try_new(vec![expr], empty)?);let ret = assert_analyzed_plan_eq(Arc::new(TypeCoercion::new()), plan, expected);let err = ret.unwrap_err().to_string();@@ -1599,7 +1599,7 @@ mod test {#[test]fn concat_for_type_coercion() -> Result<()> {- let empty = empty_with_type(DataType::Utf8);+ let empty = empty_with_type(Utf8);let args = [col("a"), lit("b"), lit(true), lit(false), lit(13)];// concat-type signature@@ -1734,7 +1734,7 @@ mod test {true,),Field::new("binary", DataType::Binary, true),- Field::new("string", DataType::Utf8, true),+ Field::new("string", Utf8, true),Field::new("decimal", DataType::Decimal128(10, 10), true),].into(),@@ -1751,7 +1751,7 @@ mod test {else_expr: None,};let case_when_common_type = DataType::Boolean;- let then_else_common_type = DataType::Utf8;+ let then_else_common_type = Utf8;let expected = cast_helper(case.clone(),&case_when_common_type,@@ -1770,8 +1770,8 @@ mod test {],else_expr: Some(Box::new(col("string"))),};- let case_when_common_type = DataType::Utf8;- let then_else_common_type = DataType::Utf8;+ let case_when_common_type = Utf8;+ let then_else_common_type = Utf8;let expected = cast_helper(case.clone(),&case_when_common_type,@@ -1861,7 +1861,7 @@ mod test {Some("list"),vec![(Box::new(col("large_list")), Box::new(lit("1")))],DataType::LargeList(Arc::new(Field::new("item", DataType::Int64, true))),- DataType::Utf8,+ Utf8,schema);@@ -1869,7 +1869,7 @@ mod test {Some("large_list"),vec![(Box::new(col("list")), Box::new(lit("1")))],DataType::LargeList(Arc::new(Field::new("item", DataType::Int64, true))),- DataType::Utf8,+ Utf8,schema);@@ -1877,7 +1877,7 @@ mod test {Some("list"),vec![(Box::new(col("fixed_list")), Box::new(lit("1")))],DataType::List(Arc::new(Field::new("item", DataType::Int64, true))),- DataType::Utf8,+ Utf8,schema);@@ -1885,7 +1885,7 @@ mod test {Some("fixed_list"),vec![(Box::new(col("list")), Box::new(lit("1")))],DataType::List(Arc::new(Field::new("item", DataType::Int64, true))),- DataType::Utf8,+ Utf8,schema);@@ -1893,7 +1893,7 @@ mod test {Some("fixed_list"),vec![(Box::new(col("large_list")), Box::new(lit("1")))],DataType::LargeList(Arc::new(Field::new("item", DataType::Int64, true))),- DataType::Utf8,+ Utf8,schema);@@ -1901,7 +1901,7 @@ mod test {Some("large_list"),vec![(Box::new(col("fixed_list")), Box::new(lit("1")))],DataType::LargeList(Arc::new(Field::new("item", DataType::Int64, true))),- DataType::Utf8,+ Utf8,schema);Ok(())diff --git a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs b/datafusion/optimizer/src/decorrelate_predicate_subquery.rsindex cdffa8c645..cc1687cffe 100644--- a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs+++ b/datafusion/optimizer/src/decorrelate_predicate_subquery.rs@@ -357,9 +357,9 @@ fn build_join(.for_each(|cols| all_correlated_cols.extend(cols.clone()));// alias the join filter- let join_filter_opt =- conjunction(pull_up.join_filters).map_or(Ok(None), |filter| {- replace_qualified_name(filter, &all_correlated_cols, &alias).map(Option::Some)+ let join_filter_opt = conjunction(pull_up.join_filters)+ .map_or(Ok(None), |filter| {+ replace_qualified_name(filter, &all_correlated_cols, &alias).map(Some)})?;if let Some(join_filter) = match (join_filter_opt, in_predicate_opt) {diff --git a/datafusion/optimizer/src/eliminate_limit.rs b/datafusion/optimizer/src/eliminate_limit.rsindex 829d4c2d22..267615c3e0 100644--- a/datafusion/optimizer/src/eliminate_limit.rs+++ b/datafusion/optimizer/src/eliminate_limit.rs@@ -57,10 +57,7 @@ impl OptimizerRule for EliminateLimit {&self,plan: LogicalPlan,_config: &dyn OptimizerConfig,- ) -> Result<- datafusion_common::tree_node::Transformed<LogicalPlan>,- datafusion_common::DataFusionError,- > {+ ) -> Result<Transformed<LogicalPlan>, datafusion_common::DataFusionError> {match plan {LogicalPlan::Limit(limit) => {// Only supports rewriting for literal fetchdiff --git a/datafusion/optimizer/src/push_down_filter.rs b/datafusion/optimizer/src/push_down_filter.rsindex a6c0a73106..f8e614a0aa 100644--- a/datafusion/optimizer/src/push_down_filter.rs+++ b/datafusion/optimizer/src/push_down_filter.rs@@ -2387,7 +2387,7 @@ mod tests {.collect())}- fn as_any(&self) -> &dyn std::any::Any {+ fn as_any(&self) -> &dyn Any {self}}diff --git a/datafusion/optimizer/src/scalar_subquery_to_join.rs b/datafusion/optimizer/src/scalar_subquery_to_join.rsindex 7b931e73ab..2e2c8fb1d6 100644--- a/datafusion/optimizer/src/scalar_subquery_to_join.rs+++ b/datafusion/optimizer/src/scalar_subquery_to_join.rs@@ -318,8 +318,7 @@ fn build_join(// alias the join filterlet join_filter_opt =conjunction(pull_up.join_filters).map_or(Ok(None), |filter| {- replace_qualified_name(filter, &all_correlated_cols, subquery_alias)- .map(Option::Some)+ replace_qualified_name(filter, &all_correlated_cols, subquery_alias).map(Some)})?;// join our sub query into the main plandiff --git a/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs b/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rsindex f9dfadc708..ce6734616b 100644--- a/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs+++ b/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs@@ -1537,7 +1537,7 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for Simplifier<'a, S> {// i.e. `a = 1 OR a = 2 OR a = 3` -> `a IN (1, 2, 3)`Expr::BinaryExpr(BinaryExpr {left,- op: Operator::Or,+ op: Or,right,}) if are_inlist_and_eq(left.as_ref(), right.as_ref()) => {let lhs = to_inlist(*left).unwrap();@@ -1577,7 +1577,7 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for Simplifier<'a, S> {// 8. `a in (1,2,3,4) AND a not in (5,6,7,8) -> a in (1,2,3,4)`Expr::BinaryExpr(BinaryExpr {left,- op: Operator::And,+ op: And,right,}) if are_inlist_and_eq_and_match_neg(left.as_ref(),@@ -1597,7 +1597,7 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for Simplifier<'a, S> {Expr::BinaryExpr(BinaryExpr {left,- op: Operator::And,+ op: And,right,}) if are_inlist_and_eq_and_match_neg(left.as_ref(),@@ -1617,7 +1617,7 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for Simplifier<'a, S> {Expr::BinaryExpr(BinaryExpr {left,- op: Operator::And,+ op: And,right,}) if are_inlist_and_eq_and_match_neg(left.as_ref(),@@ -1637,7 +1637,7 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for Simplifier<'a, S> {Expr::BinaryExpr(BinaryExpr {left,- op: Operator::And,+ op: And,right,}) if are_inlist_and_eq_and_match_neg(left.as_ref(),@@ -1657,7 +1657,7 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for Simplifier<'a, S> {Expr::BinaryExpr(BinaryExpr {left,- op: Operator::Or,+ op: Or,right,}) if are_inlist_and_eq_and_match_neg(left.as_ref(),@@ -3818,7 +3818,7 @@ mod tests {fn test_simplify_udaf() {let udaf = AggregateUDF::new_from_impl(SimplifyMockUdaf::new_with_simplify());let aggregate_function_expr =- Expr::AggregateFunction(datafusion_expr::expr::AggregateFunction::new_udf(+ Expr::AggregateFunction(expr::AggregateFunction::new_udf(udaf.into(),vec![],false,@@ -3832,7 +3832,7 @@ mod tests {let udaf = AggregateUDF::new_from_impl(SimplifyMockUdaf::new_without_simplify());let aggregate_function_expr =- Expr::AggregateFunction(datafusion_expr::expr::AggregateFunction::new_udf(+ Expr::AggregateFunction(expr::AggregateFunction::new_udf(udaf.into(),vec![],false,@@ -3882,7 +3882,7 @@ mod tests {fn accumulator(&self,- _acc_args: function::AccumulatorArgs,+ _acc_args: AccumulatorArgs,) -> Result<Box<dyn Accumulator>> {unimplemented!("not needed for tests")}@@ -3912,9 +3912,8 @@ mod tests {let udwf = WindowFunctionDefinition::WindowUDF(WindowUDF::new_from_impl(SimplifyMockUdwf::new_with_simplify()).into(),);- let window_function_expr = Expr::WindowFunction(- datafusion_expr::expr::WindowFunction::new(udwf, vec![]),- );+ let window_function_expr =+ Expr::WindowFunction(WindowFunction::new(udwf, vec![]));let expected = col("result_column");assert_eq!(simplify(window_function_expr), expected);@@ -3922,9 +3921,8 @@ mod tests {let udwf = WindowFunctionDefinition::WindowUDF(WindowUDF::new_from_impl(SimplifyMockUdwf::new_without_simplify()).into(),);- let window_function_expr = Expr::WindowFunction(- datafusion_expr::expr::WindowFunction::new(udwf, vec![]),- );+ let window_function_expr =+ Expr::WindowFunction(WindowFunction::new(udwf, vec![]));let expected = window_function_expr.clone();assert_eq!(simplify(window_function_expr), expected);diff --git a/datafusion/optimizer/src/single_distinct_to_groupby.rs b/datafusion/optimizer/src/single_distinct_to_groupby.rsindex 74251e5caa..01875349c9 100644--- a/datafusion/optimizer/src/single_distinct_to_groupby.rs+++ b/datafusion/optimizer/src/single_distinct_to_groupby.rs@@ -279,7 +279,7 @@ impl OptimizerRule for SingleDistinctToGroupBy {mod tests {use super::*;use crate::test::*;- use datafusion_expr::expr::{self, GroupingSet};+ use datafusion_expr::expr::GroupingSet;use datafusion_expr::ExprFunctionExt;use datafusion_expr::{lit, logical_plan::builder::LogicalPlanBuilder};use datafusion_functions_aggregate::count::count_udaf;@@ -288,7 +288,7 @@ mod tests {use datafusion_functions_aggregate::sum::sum_udaf;fn max_distinct(expr: Expr) -> Expr {- Expr::AggregateFunction(datafusion_expr::expr::AggregateFunction::new_udf(+ Expr::AggregateFunction(AggregateFunction::new_udf(max_udaf(),vec![expr],true,@@ -569,7 +569,7 @@ mod tests {let table_scan = test_table_scan()?;// sum(a) FILTER (WHERE a > 5)- let expr = Expr::AggregateFunction(expr::AggregateFunction::new_udf(+ let expr = Expr::AggregateFunction(AggregateFunction::new_udf(sum_udaf(),vec![col("a")],false,@@ -612,7 +612,7 @@ mod tests {let table_scan = test_table_scan()?;// SUM(a ORDER BY a)- let expr = Expr::AggregateFunction(expr::AggregateFunction::new_udf(+ let expr = Expr::AggregateFunction(AggregateFunction::new_udf(sum_udaf(),vec![col("a")],false,diff --git a/datafusion/physical-expr-common/src/binary_map.rs b/datafusion/physical-expr-common/src/binary_map.rsindex 03ac4769d9..80c4963ae0 100644--- a/datafusion/physical-expr-common/src/binary_map.rs+++ b/datafusion/physical-expr-common/src/binary_map.rs@@ -31,7 +31,7 @@ use datafusion_common::hash_utils::create_hashes;use datafusion_common::utils::proxy::{RawTableAllocExt, VecAllocExt};use std::any::type_name;use std::fmt::Debug;-use std::mem;+use std::mem::{size_of, swap};use std::ops::Range;use std::sync::Arc;@@ -260,7 +260,7 @@ where/// the same output typepub fn take(&mut self) -> Self {let mut new_self = Self::new(self.output_type);- mem::swap(self, &mut new_self);+ swap(self, &mut new_self);new_self}@@ -545,7 +545,7 @@ where/// this set, not including `self`pub fn size(&self) -> usize {self.map_size- + self.buffer.capacity() * mem::size_of::<u8>()+ + self.buffer.capacity() * size_of::<u8>()+ self.offsets.allocated_size()+ self.hashes_buffer.allocated_size()}@@ -575,7 +575,7 @@ where}/// Maximum size of a value that can be inlined in the hash table-const SHORT_VALUE_LEN: usize = mem::size_of::<usize>();+const SHORT_VALUE_LEN: usize = size_of::<usize>();/// Entry in the hash table -- see [`ArrowBytesMap`] for more details#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]diff --git a/datafusion/physical-expr-common/src/sort_expr.rs b/datafusion/physical-expr-common/src/sort_expr.rsindex 6c4bf156ce..d825bfe7e2 100644--- a/datafusion/physical-expr-common/src/sort_expr.rs+++ b/datafusion/physical-expr-common/src/sort_expr.rs@@ -143,7 +143,7 @@ impl Hash for PhysicalSortExpr {}impl Display for PhysicalSortExpr {- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {write!(f, "{} {}", self.expr, to_str(&self.options))}}@@ -188,7 +188,7 @@ impl PhysicalSortExpr {pub fn format_list(input: &[PhysicalSortExpr]) -> impl Display + '_ {struct DisplayableList<'a>(&'a [PhysicalSortExpr]);impl<'a> Display for DisplayableList<'a> {- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {let mut first = true;for sort_expr in self.0 {if first {@@ -260,7 +260,7 @@ impl PartialEq for PhysicalSortRequirement {}impl Display for PhysicalSortRequirement {- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {let opts_string = self.options.as_ref().map_or("NA", to_str);write!(f, "{} {}", self.expr, opts_string)}diff --git a/datafusion/physical-expr/src/equivalence/properties.rs b/datafusion/physical-expr/src/equivalence/properties.rsindex a0cc29685f..9a16b205ae 100644--- a/datafusion/physical-expr/src/equivalence/properties.rs+++ b/datafusion/physical-expr/src/equivalence/properties.rs@@ -1113,7 +1113,7 @@ impl EquivalenceProperties {/// order: [[a ASC, b ASC], [a ASC, c ASC]], eq: [[a = b], [a = c]], const: [a = 1]/// ```impl Display for EquivalenceProperties {- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {if self.eq_group.is_empty()&& self.oeq_class.is_empty()&& self.constants.is_empty()diff --git a/datafusion/physical-expr/src/expressions/case.rs b/datafusion/physical-expr/src/expressions/case.rsindex ffb431b200..981e49d737 100644--- a/datafusion/physical-expr/src/expressions/case.rs+++ b/datafusion/physical-expr/src/expressions/case.rs@@ -1096,16 +1096,15 @@ mod tests {let expr2 = Arc::clone(&expr).transform(|e| {- let transformed =- match e.as_any().downcast_ref::<crate::expressions::Literal>() {- Some(lit_value) => match lit_value.value() {- ScalarValue::Utf8(Some(str_value)) => {- Some(lit(str_value.to_uppercase()))- }- _ => None,- },+ let transformed = match e.as_any().downcast_ref::<Literal>() {+ Some(lit_value) => match lit_value.value() {+ ScalarValue::Utf8(Some(str_value)) => {+ Some(lit(str_value.to_uppercase()))+ }_ => None,- };+ },+ _ => None,+ };Ok(if let Some(transformed) = transformed {Transformed::yes(transformed)} else {@@ -1117,16 +1116,15 @@ mod tests {let expr3 = Arc::clone(&expr).transform_down(|e| {- let transformed =- match e.as_any().downcast_ref::<crate::expressions::Literal>() {- Some(lit_value) => match lit_value.value() {- ScalarValue::Utf8(Some(str_value)) => {- Some(lit(str_value.to_uppercase()))- }- _ => None,- },+ let transformed = match e.as_any().downcast_ref::<Literal>() {+ Some(lit_value) => match lit_value.value() {+ ScalarValue::Utf8(Some(str_value)) => {+ Some(lit(str_value.to_uppercase()))+ }_ => None,- };+ },+ _ => None,+ };Ok(if let Some(transformed) = transformed {Transformed::yes(transformed)} else {diff --git a/datafusion/physical-expr/src/expressions/cast.rs b/datafusion/physical-expr/src/expressions/cast.rsindex 5621473c4f..457c47097a 100644--- a/datafusion/physical-expr/src/expressions/cast.rs+++ b/datafusion/physical-expr/src/expressions/cast.rs@@ -693,7 +693,7 @@ mod tests {let result = cast(col("a", &schema).unwrap(),&schema,- DataType::Interval(IntervalUnit::MonthDayNano),+ Interval(IntervalUnit::MonthDayNano),);result.expect_err("expected Invalid CAST");}diff --git a/datafusion/physical-expr/src/expressions/column.rs b/datafusion/physical-expr/src/expressions/column.rsindex 4aad959584..3e2d49e9fa 100644--- a/datafusion/physical-expr/src/expressions/column.rs+++ b/datafusion/physical-expr/src/expressions/column.rs@@ -107,7 +107,7 @@ impl std::fmt::Display for Column {impl PhysicalExpr for Column {/// Return a reference to Any that can be used for downcasting- fn as_any(&self) -> &dyn std::any::Any {+ fn as_any(&self) -> &dyn Any {self}diff --git a/datafusion/physical-expr/src/expressions/in_list.rs b/datafusion/physical-expr/src/expressions/in_list.rsindex 0a3e5fcefc..cf57ce3e0e 100644--- a/datafusion/physical-expr/src/expressions/in_list.rs+++ b/datafusion/physical-expr/src/expressions/in_list.rs@@ -1102,7 +1102,7 @@ mod tests {let mut phy_exprs = vec![lit(1i64),expressions::cast(lit(2i32), &schema, DataType::Int64)?,- expressions::try_cast(lit(3.13f32), &schema, DataType::Int64)?,+ try_cast(lit(3.13f32), &schema, DataType::Int64)?,];let result = try_cast_static_filter_to_set(&phy_exprs, &schema).unwrap();@@ -1130,7 +1130,7 @@ mod tests {try_cast_static_filter_to_set(&phy_exprs, &schema).unwrap();// column- phy_exprs.push(expressions::col("a", &schema)?);+ phy_exprs.push(col("a", &schema)?);assert!(try_cast_static_filter_to_set(&phy_exprs, &schema).is_err());Ok(())diff --git a/datafusion/physical-expr/src/expressions/negative.rs b/datafusion/physical-expr/src/expressions/negative.rsindex b5ebc250cb..399ebde9f7 100644--- a/datafusion/physical-expr/src/expressions/negative.rs+++ b/datafusion/physical-expr/src/expressions/negative.rs@@ -257,7 +257,7 @@ mod tests {#[test]fn test_negation_valid_types() -> Result<()> {let negatable_types = [- DataType::Int8,+ Int8,DataType::Timestamp(TimeUnit::Second, None),DataType::Interval(IntervalUnit::YearMonth),];diff --git a/datafusion/physical-expr/src/expressions/unknown_column.rs b/datafusion/physical-expr/src/expressions/unknown_column.rsindex cb7221e7fa..590efd5779 100644--- a/datafusion/physical-expr/src/expressions/unknown_column.rs+++ b/datafusion/physical-expr/src/expressions/unknown_column.rs@@ -57,7 +57,7 @@ impl std::fmt::Display for UnKnownColumn {impl PhysicalExpr for UnKnownColumn {/// Return a reference to Any that can be used for downcasting- fn as_any(&self) -> &dyn std::any::Any {+ fn as_any(&self) -> &dyn Any {self}diff --git a/datafusion/physical-expr/src/intervals/cp_solver.rs b/datafusion/physical-expr/src/intervals/cp_solver.rsindex f05ac3624b..8084a52c78 100644--- a/datafusion/physical-expr/src/intervals/cp_solver.rs+++ b/datafusion/physical-expr/src/intervals/cp_solver.rs@@ -19,6 +19,7 @@use std::collections::HashSet;use std::fmt::{Display, Formatter};+use std::mem::{size_of, size_of_val};use std::sync::Arc;use super::utils::{@@ -128,12 +129,11 @@ impl ExprIntervalGraph {/// Estimate size of bytes including `Self`.pub fn size(&self) -> usize {let node_memory_usage = self.graph.node_count()- * (std::mem::size_of::<ExprIntervalGraphNode>()- + std::mem::size_of::<NodeIndex>());- let edge_memory_usage = self.graph.edge_count()- * (std::mem::size_of::<usize>() + std::mem::size_of::<NodeIndex>() * 2);+ * (size_of::<ExprIntervalGraphNode>() + size_of::<NodeIndex>());+ let edge_memory_usage =+ self.graph.edge_count() * (size_of::<usize>() + size_of::<NodeIndex>() * 2);- std::mem::size_of_val(self) + node_memory_usage + edge_memory_usage+ size_of_val(self) + node_memory_usage + edge_memory_usage}}diff --git a/datafusion/physical-expr/src/partitioning.rs b/datafusion/physical-expr/src/partitioning.rsindex 01f72a8efd..98c0c864b9 100644--- a/datafusion/physical-expr/src/partitioning.rs+++ b/datafusion/physical-expr/src/partitioning.rs@@ -121,8 +121,8 @@ pub enum Partitioning {UnknownPartitioning(usize),}-impl fmt::Display for Partitioning {- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {+impl Display for Partitioning {+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {match self {Partitioning::RoundRobinBatch(size) => write!(f, "RoundRobinBatch({size})"),Partitioning::Hash(phy_exprs, size) => {diff --git a/datafusion/physical-plan/src/aggregates/group_values/bytes.rs b/datafusion/physical-plan/src/aggregates/group_values/bytes.rsindex f789af8b8a..013c027e73 100644--- a/datafusion/physical-plan/src/aggregates/group_values/bytes.rs+++ b/datafusion/physical-plan/src/aggregates/group_values/bytes.rs@@ -19,6 +19,7 @@ use crate::aggregates::group_values::GroupValues;use arrow_array::{Array, ArrayRef, OffsetSizeTrait, RecordBatch};use datafusion_expr::EmitTo;use datafusion_physical_expr_common::binary_map::{ArrowBytesMap, OutputType};+use std::mem::size_of;/// A [`GroupValues`] storing single column of Utf8/LargeUtf8/Binary/LargeBinary values///@@ -73,7 +74,7 @@ impl<O: OffsetSizeTrait> GroupValues for GroupValuesByes<O> {}fn size(&self) -> usize {- self.map.size() + std::mem::size_of::<Self>()+ self.map.size() + size_of::<Self>()}fn is_empty(&self) -> bool {diff --git a/datafusion/physical-plan/src/aggregates/group_values/bytes_view.rs b/datafusion/physical-plan/src/aggregates/group_values/bytes_view.rsindex 1a0cb90a16..7379b7a538 100644--- a/datafusion/physical-plan/src/aggregates/group_values/bytes_view.rs+++ b/datafusion/physical-plan/src/aggregates/group_values/bytes_view.rs@@ -20,6 +20,7 @@ use arrow_array::{Array, ArrayRef, RecordBatch};use datafusion_expr::EmitTo;use datafusion_physical_expr::binary_map::OutputType;use datafusion_physical_expr_common::binary_view_map::ArrowBytesViewMap;+use std::mem::size_of;/// A [`GroupValues`] storing single column of Utf8View/BinaryView values///@@ -74,7 +75,7 @@ impl GroupValues for GroupValuesBytesView {}fn size(&self) -> usize {- self.map.size() + std::mem::size_of::<Self>()+ self.map.size() + size_of::<Self>()}fn is_empty(&self) -> bool {diff --git a/datafusion/physical-plan/src/aggregates/group_values/column.rs b/datafusion/physical-plan/src/aggregates/group_values/column.rsindex 4ad75844f7..958a4b58d8 100644--- a/datafusion/physical-plan/src/aggregates/group_values/column.rs+++ b/datafusion/physical-plan/src/aggregates/group_values/column.rs@@ -35,8 +35,8 @@ use datafusion_common::{not_impl_err, DataFusionError, Result};use datafusion_execution::memory_pool::proxy::{RawTableAllocExt, VecAllocExt};use datafusion_expr::EmitTo;use datafusion_physical_expr::binary_map::OutputType;-use hashbrown::raw::RawTable;+use std::mem::size_of;/// A [`GroupValues`] that stores multiple columns of group values.///@@ -351,7 +351,7 @@ impl GroupValues for GroupValuesColumn {self.group_values.clear();self.map.clear();self.map.shrink_to(count, |_| 0); // hasher does not matter since the map is cleared- self.map_size = self.map.capacity() * std::mem::size_of::<(u64, usize)>();+ self.map_size = self.map.capacity() * size_of::<(u64, usize)>();self.hashes_buffer.clear();self.hashes_buffer.shrink_to(count);}diff --git a/datafusion/physical-plan/src/aggregates/group_values/group_column.rs b/datafusion/physical-plan/src/aggregates/group_values/group_column.rsindex 4153495860..bba59b6d0c 100644--- a/datafusion/physical-plan/src/aggregates/group_values/group_column.rs+++ b/datafusion/physical-plan/src/aggregates/group_values/group_column.rs@@ -37,7 +37,7 @@ use crate::aggregates::group_values::null_builder::MaybeNullBufferBuilder;use arrow_array::types::GenericStringType;use datafusion_physical_expr_common::binary_map::{OutputType, INITIAL_BUFFER_CAPACITY};use std::marker::PhantomData;-use std::mem;+use std::mem::{replace, size_of};use std::sync::Arc;use std::vec;@@ -292,7 +292,7 @@ where}fn size(&self) -> usize {- self.buffer.capacity() * std::mem::size_of::<u8>()+ self.buffer.capacity() * size_of::<u8>()+ self.offsets.allocated_size()+ self.nulls.allocated_size()}@@ -488,7 +488,7 @@ impl<B: ByteViewType> ByteViewGroupValueBuilder<B> {// If current block isn't big enough, flush it and create a new in progress blockif require_cap > self.max_block_size {- let flushed_block = mem::replace(+ let flushed_block = replace(&mut self.in_progress,Vec::with_capacity(self.max_block_size),);@@ -611,7 +611,7 @@ impl<B: ByteViewType> ByteViewGroupValueBuilder<B> {// The `n == len` case, we need to take allif self.len() == n {let new_builder = Self::new().with_max_block_size(self.max_block_size);- let cur_builder = std::mem::replace(self, new_builder);+ let cur_builder = replace(self, new_builder);return cur_builder.build_inner();}@@ -759,7 +759,7 @@ impl<B: ByteViewType> ByteViewGroupValueBuilder<B> {}fn flush_in_progress(&mut self) {- let flushed_block = mem::replace(+ let flushed_block = replace(&mut self.in_progress,Vec::with_capacity(self.max_block_size),);@@ -785,14 +785,14 @@ impl<B: ByteViewType> GroupColumn for ByteViewGroupValueBuilder<B> {let buffers_size = self.completed.iter()- .map(|buf| buf.capacity() * std::mem::size_of::<u8>())+ .map(|buf| buf.capacity() * size_of::<u8>()).sum::<usize>();self.nulls.allocated_size()- + self.views.capacity() * std::mem::size_of::<u128>()- + self.in_progress.capacity() * std::mem::size_of::<u8>()+ + self.views.capacity() * size_of::<u128>()+ + self.in_progress.capacity() * size_of::<u8>()+ buffers_size- + std::mem::size_of::<Self>()+ + size_of::<Self>()}fn build(self: Box<Self>) -> ArrayRef {diff --git a/datafusion/physical-plan/src/aggregates/group_values/primitive.rs b/datafusion/physical-plan/src/aggregates/group_values/primitive.rsindex d5b7f1b11a..05214ec10d 100644--- a/datafusion/physical-plan/src/aggregates/group_values/primitive.rs+++ b/datafusion/physical-plan/src/aggregates/group_values/primitive.rs@@ -30,6 +30,7 @@ use datafusion_execution::memory_pool::proxy::VecAllocExt;use datafusion_expr::EmitTo;use half::f16;use hashbrown::raw::RawTable;+use std::mem::size_of;use std::sync::Arc;/// A trait to allow hashing of floating point numbers@@ -151,7 +152,7 @@ where}fn size(&self) -> usize {- self.map.capacity() * std::mem::size_of::<usize>() + self.values.allocated_size()+ self.map.capacity() * size_of::<usize>() + self.values.allocated_size()}fn is_empty(&self) -> bool {diff --git a/datafusion/physical-plan/src/aggregates/group_values/row.rs b/datafusion/physical-plan/src/aggregates/group_values/row.rsindex 8ca88257bf..de0ae2e07d 100644--- a/datafusion/physical-plan/src/aggregates/group_values/row.rs+++ b/datafusion/physical-plan/src/aggregates/group_values/row.rs@@ -27,6 +27,7 @@ use datafusion_common::Result;use datafusion_execution::memory_pool::proxy::{RawTableAllocExt, VecAllocExt};use datafusion_expr::EmitTo;use hashbrown::raw::RawTable;+use std::mem::size_of;use std::sync::Arc;/// A [`GroupValues`] making use of [`Rows`]@@ -231,10 +232,8 @@ impl GroupValues for GroupValuesRows {// https://github.com/apache/datafusion/issues/7647for (field, array) in self.schema.fields.iter().zip(&mut output) {let expected = field.data_type();- *array = dictionary_encode_if_necessary(- Arc::<dyn arrow_array::Array>::clone(array),- expected,- )?;+ *array =+ dictionary_encode_if_necessary(Arc::<dyn Array>::clone(array), expected)?;}self.group_values = Some(group_values);@@ -249,7 +248,7 @@ impl GroupValues for GroupValuesRows {});self.map.clear();self.map.shrink_to(count, |_| 0); // hasher does not matter since the map is cleared- self.map_size = self.map.capacity() * std::mem::size_of::<(u64, usize)>();+ self.map_size = self.map.capacity() * size_of::<(u64, usize)>();self.hashes_buffer.clear();self.hashes_buffer.shrink_to(count);}@@ -267,7 +266,7 @@ fn dictionary_encode_if_necessary(.zip(struct_array.columns()).map(|(expected_field, column)| {dictionary_encode_if_necessary(- Arc::<dyn arrow_array::Array>::clone(column),+ Arc::<dyn Array>::clone(column),expected_field.data_type(),)})@@ -286,13 +285,13 @@ fn dictionary_encode_if_necessary(Arc::<arrow_schema::Field>::clone(expected_field),list.offsets().clone(),dictionary_encode_if_necessary(- Arc::<dyn arrow_array::Array>::clone(list.values()),+ Arc::<dyn Array>::clone(list.values()),expected_field.data_type(),)?,list.nulls().cloned(),)?))}(DataType::Dictionary(_, _), _) => Ok(cast(array.as_ref(), expected)?),- (_, _) => Ok(Arc::<dyn arrow_array::Array>::clone(&array)),+ (_, _) => Ok(Arc::<dyn Array>::clone(&array)),}}diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rsindex f36bd920e8..48a03af19d 100644--- a/datafusion/physical-plan/src/aggregates/mod.rs+++ b/datafusion/physical-plan/src/aggregates/mod.rs@@ -1485,7 +1485,7 @@ mod tests {)?);let result =- common::collect(partial_aggregate.execute(0, Arc::clone(&task_ctx))?).await?;+ collect(partial_aggregate.execute(0, Arc::clone(&task_ctx))?).await?;let expected = if spill {// In spill mode, we test with the limited memory, if the mem usage exceeds,@@ -1557,8 +1557,7 @@ mod tests {input_schema,)?);- let result =- common::collect(merged_aggregate.execute(0, Arc::clone(&task_ctx))?).await?;+ let result = collect(merged_aggregate.execute(0, Arc::clone(&task_ctx))?).await?;let batch = concat_batches(&result[0].schema(), &result)?;assert_eq!(batch.num_columns(), 4);assert_eq!(batch.num_rows(), 12);@@ -1625,7 +1624,7 @@ mod tests {)?);let result =- common::collect(partial_aggregate.execute(0, Arc::clone(&task_ctx))?).await?;+ collect(partial_aggregate.execute(0, Arc::clone(&task_ctx))?).await?;let expected = if spill {vec![@@ -1671,7 +1670,7 @@ mod tests {} else {Arc::clone(&task_ctx)};- let result = common::collect(merged_aggregate.execute(0, task_ctx)?).await?;+ let result = collect(merged_aggregate.execute(0, task_ctx)?).await?;let batch = concat_batches(&result[0].schema(), &result)?;assert_eq!(batch.num_columns(), 2);assert_eq!(batch.num_rows(), 3);@@ -1971,7 +1970,7 @@ mod tests {}let stream: SendableRecordBatchStream = stream.into();- let err = common::collect(stream).await.unwrap_err();+ let err = collect(stream).await.unwrap_err();// error root cause traversal is a bit complicated, see #4172.let err = err.find_root();@@ -2522,7 +2521,7 @@ mod tests {let input = Arc::new(MemoryExec::try_new(&[vec![batch.clone()]],- Arc::<arrow_schema::Schema>::clone(&batch.schema()),+ Arc::<Schema>::clone(&batch.schema()),None,)?);let aggregate_exec = Arc::new(AggregateExec::try_new(diff --git a/datafusion/physical-plan/src/aggregates/order/full.rs b/datafusion/physical-plan/src/aggregates/order/full.rsindex d64c99ba1b..218855459b 100644--- a/datafusion/physical-plan/src/aggregates/order/full.rs+++ b/datafusion/physical-plan/src/aggregates/order/full.rs@@ -16,6 +16,7 @@// under the License.use datafusion_expr::EmitTo;+use std::mem::size_of;/// Tracks grouping state when the data is ordered entirely by its/// group keys@@ -139,7 +140,7 @@ impl GroupOrderingFull {}pub(crate) fn size(&self) -> usize {- std::mem::size_of::<Self>()+ size_of::<Self>()}}diff --git a/datafusion/physical-plan/src/aggregates/order/mod.rs b/datafusion/physical-plan/src/aggregates/order/mod.rsindex 483150ee61..accb2fda11 100644--- a/datafusion/physical-plan/src/aggregates/order/mod.rs+++ b/datafusion/physical-plan/src/aggregates/order/mod.rs@@ -20,6 +20,7 @@ use arrow_schema::Schema;use datafusion_common::Result;use datafusion_expr::EmitTo;use datafusion_physical_expr::PhysicalSortExpr;+use std::mem::size_of;mod full;mod partial;@@ -118,7 +119,7 @@ impl GroupOrdering {/// Return the size of memory used by the ordering state, in bytespub fn size(&self) -> usize {- std::mem::size_of::<Self>()+ size_of::<Self>()+ match self {GroupOrdering::None => 0,GroupOrdering::Partial(partial) => partial.size(),diff --git a/datafusion/physical-plan/src/aggregates/order/partial.rs b/datafusion/physical-plan/src/aggregates/order/partial.rsindex 2cbe3bbb78..2dd1ea8a54 100644--- a/datafusion/physical-plan/src/aggregates/order/partial.rs+++ b/datafusion/physical-plan/src/aggregates/order/partial.rs@@ -22,6 +22,7 @@ use datafusion_common::Result;use datafusion_execution::memory_pool::proxy::VecAllocExt;use datafusion_expr::EmitTo;use datafusion_physical_expr::PhysicalSortExpr;+use std::mem::size_of;use std::sync::Arc;/// Tracks grouping state when the data is ordered by some subset of@@ -244,7 +245,7 @@ impl GroupOrderingPartial {/// Return the size of memory allocated by this structurepub(crate) fn size(&self) -> usize {- std::mem::size_of::<Self>()+ size_of::<Self>()+ self.order_indices.allocated_size()+ self.row_converter.size()}diff --git a/datafusion/physical-plan/src/aggregates/topk/hash_table.rs b/datafusion/physical-plan/src/aggregates/topk/hash_table.rsindex 232b87de32..34df643b6c 100644--- a/datafusion/physical-plan/src/aggregates/topk/hash_table.rs+++ b/datafusion/physical-plan/src/aggregates/topk/hash_table.rs@@ -109,7 +109,7 @@ impl StringHashTable {Self {owned,map: TopKHashTable::new(limit, limit * 10),- rnd: ahash::RandomState::default(),+ rnd: RandomState::default(),}}}@@ -181,7 +181,7 @@ whereSelf {owned,map: TopKHashTable::new(limit, limit * 10),- rnd: ahash::RandomState::default(),+ rnd: RandomState::default(),}}}diff --git a/datafusion/physical-plan/src/display.rs b/datafusion/physical-plan/src/display.rsindex 4e936fb37a..e79b3c817b 100644--- a/datafusion/physical-plan/src/display.rs+++ b/datafusion/physical-plan/src/display.rs@@ -125,7 +125,7 @@ impl<'a> DisplayableExecutionPlan<'a> {show_schema: bool,}impl<'a> fmt::Display for Wrapper<'a> {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {let mut visitor = IndentVisitor {t: self.format_type,f,@@ -164,7 +164,7 @@ impl<'a> DisplayableExecutionPlan<'a> {show_statistics: bool,}impl<'a> fmt::Display for Wrapper<'a> {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {let t = DisplayFormatType::Default;let mut visitor = GraphvizVisitor {@@ -203,7 +203,7 @@ impl<'a> DisplayableExecutionPlan<'a> {}impl<'a> fmt::Display for Wrapper<'a> {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {let mut visitor = IndentVisitor {f,t: DisplayFormatType::Default,@@ -257,7 +257,7 @@ struct IndentVisitor<'a, 'b> {/// How to format each nodet: DisplayFormatType,/// Write to this formatter- f: &'a mut fmt::Formatter<'b>,+ f: &'a mut Formatter<'b>,/// Indent sizeindent: usize,/// How to show metrics@@ -318,7 +318,7 @@ impl<'a, 'b> ExecutionPlanVisitor for IndentVisitor<'a, 'b> {}struct GraphvizVisitor<'a, 'b> {- f: &'a mut fmt::Formatter<'b>,+ f: &'a mut Formatter<'b>,/// How to format each nodet: DisplayFormatType,/// How to show metrics@@ -349,8 +349,8 @@ impl ExecutionPlanVisitor for GraphvizVisitor<'_, '_> {struct Wrapper<'a>(&'a dyn ExecutionPlan, DisplayFormatType);- impl<'a> std::fmt::Display for Wrapper<'a> {- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ impl<'a> fmt::Display for Wrapper<'a> {+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {self.0.fmt_as(self.1, f)}}@@ -422,14 +422,14 @@ pub trait DisplayAs {/// different from the default one////// Should not include a newline- fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter) -> fmt::Result;+ fn fmt_as(&self, t: DisplayFormatType, f: &mut Formatter) -> fmt::Result;}/// A newtype wrapper to display `T` implementing`DisplayAs` using the `Default` modepub struct DefaultDisplay<T>(pub T);impl<T: DisplayAs> fmt::Display for DefaultDisplay<T> {- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {self.0.fmt_as(DisplayFormatType::Default, f)}}@@ -438,7 +438,7 @@ impl<T: DisplayAs> fmt::Display for DefaultDisplay<T> {pub struct VerboseDisplay<T>(pub T);impl<T: DisplayAs> fmt::Display for VerboseDisplay<T> {- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {self.0.fmt_as(DisplayFormatType::Verbose, f)}}@@ -448,7 +448,7 @@ impl<T: DisplayAs> fmt::Display for VerboseDisplay<T> {pub struct ProjectSchemaDisplay<'a>(pub &'a SchemaRef);impl<'a> fmt::Display for ProjectSchemaDisplay<'a> {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {let parts: Vec<_> = self.0.fields()@@ -464,7 +464,7 @@ impl<'a> fmt::Display for ProjectSchemaDisplay<'a> {pub struct OutputOrderingDisplay<'a>(pub &'a [PhysicalSortExpr]);impl<'a> fmt::Display for OutputOrderingDisplay<'a> {- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {write!(f, "[")?;for (i, e) in self.0.iter().enumerate() {if i > 0 {diff --git a/datafusion/physical-plan/src/insert.rs b/datafusion/physical-plan/src/insert.rsindex dda45ebebb..8b3ef5ae01 100644--- a/datafusion/physical-plan/src/insert.rs+++ b/datafusion/physical-plan/src/insert.rs@@ -93,7 +93,7 @@ pub struct DataSinkExec {cache: PlanProperties,}-impl fmt::Debug for DataSinkExec {+impl Debug for DataSinkExec {fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {write!(f, "DataSinkExec schema: {:?}", self.count_schema)}@@ -148,11 +148,7 @@ impl DataSinkExec {}impl DisplayAs for DataSinkExec {- fn fmt_as(- &self,- t: DisplayFormatType,- f: &mut std::fmt::Formatter,- ) -> std::fmt::Result {+ fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter) -> fmt::Result {match t {DisplayFormatType::Default | DisplayFormatType::Verbose => {write!(f, "DataSinkExec: sink=")?;diff --git a/datafusion/physical-plan/src/joins/cross_join.rs b/datafusion/physical-plan/src/joins/cross_join.rsindex 8f2bef56da..8f49885068 100644--- a/datafusion/physical-plan/src/joins/cross_join.rs+++ b/datafusion/physical-plan/src/joins/cross_join.rs@@ -418,7 +418,7 @@ impl<T: BatchTransformer + Unpin + Send> Stream for CrossJoinStream<T> {fn poll_next(mut self: std::pin::Pin<&mut Self>,cx: &mut std::task::Context<'_>,- ) -> std::task::Poll<Option<Self::Item>> {+ ) -> Poll<Option<Self::Item>> {self.poll_next_impl(cx)}}@@ -429,7 +429,7 @@ impl<T: BatchTransformer> CrossJoinStream<T> {fn poll_next_impl(&mut self,cx: &mut std::task::Context<'_>,- ) -> std::task::Poll<Option<Result<RecordBatch>>> {+ ) -> Poll<Option<Result<RecordBatch>>> {loop {return match self.state {CrossJoinStreamState::WaitBuildSide => {diff --git a/datafusion/physical-plan/src/joins/hash_join.rs b/datafusion/physical-plan/src/joins/hash_join.rsindex 3b730c0129..2d11e03814 100644--- a/datafusion/physical-plan/src/joins/hash_join.rs+++ b/datafusion/physical-plan/src/joins/hash_join.rs@@ -18,6 +18,7 @@//! [`HashJoinExec`] Partitioned Hash Join Operatoruse std::fmt;+use std::mem::size_of;use std::sync::atomic::{AtomicUsize, Ordering};use std::sync::Arc;use std::task::Poll;@@ -849,7 +850,7 @@ async fn collect_left_input(// Estimation of memory size, required for hashtable, prior to allocation.// Final result can be verified using `RawTable.allocation_info()`- let fixed_size = std::mem::size_of::<JoinHashMap>();+ let fixed_size = size_of::<JoinHashMap>();let estimated_hashtable_size =estimate_memory_size::<(u64, u64)>(num_rows, fixed_size)?;@@ -1524,7 +1525,7 @@ impl Stream for HashJoinStream {fn poll_next(mut self: std::pin::Pin<&mut Self>,cx: &mut std::task::Context<'_>,- ) -> std::task::Poll<Option<Self::Item>> {+ ) -> Poll<Option<Self::Item>> {self.poll_next_impl(cx)}}@@ -3594,10 +3595,7 @@ mod tests {let stream = join.execute(0, task_ctx).unwrap();// Expect that an error is returned- let result_string = crate::common::collect(stream)- .await- .unwrap_err()- .to_string();+ let result_string = common::collect(stream).await.unwrap_err().to_string();assert!(result_string.contains("bad data error"),"actual: {result_string}"diff --git a/datafusion/physical-plan/src/joins/sort_merge_join.rs b/datafusion/physical-plan/src/joins/sort_merge_join.rsindex 7b7b7462f7..b299b495c5 100644--- a/datafusion/physical-plan/src/joins/sort_merge_join.rs+++ b/datafusion/physical-plan/src/joins/sort_merge_join.rs@@ -26,7 +26,7 @@ use std::collections::{HashMap, VecDeque};use std::fmt::Formatter;use std::fs::File;use std::io::BufReader;-use std::mem;+use std::mem::size_of;use std::ops::Range;use std::pin::Pin;use std::sync::atomic::AtomicUsize;@@ -411,13 +411,13 @@ struct SortMergeJoinMetrics {/// Total time for joining probe-side batches to the build-side batchesjoin_time: metrics::Time,/// Number of batches consumed by this operator- input_batches: metrics::Count,+ input_batches: Count,/// Number of rows consumed by this operator- input_rows: metrics::Count,+ input_rows: Count,/// Number of batches produced by this operator- output_batches: metrics::Count,+ output_batches: Count,/// Number of rows produced by this operator- output_rows: metrics::Count,+ output_rows: Count,/// Peak memory used for buffered data./// Calculated as sum of peak memory values across partitionspeak_mem_used: metrics::Gauge,@@ -630,9 +630,9 @@ impl BufferedBatch {.iter().map(|arr| arr.get_array_memory_size()).sum::<usize>()- + batch.num_rows().next_power_of_two() * mem::size_of::<usize>()- + mem::size_of::<Range<usize>>()- + mem::size_of::<usize>();+ + batch.num_rows().next_power_of_two() * size_of::<usize>()+ + size_of::<Range<usize>>()+ + size_of::<usize>();let num_rows = batch.num_rows();BufferedBatch {@@ -2332,7 +2332,7 @@ mod tests {Arc::new(Column::new_with_schema("b1", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Inner).await?;+ let (_, batches) = join_collect(left, right, on, Inner).await?;let expected = ["+----+----+----+----+----+----+",@@ -2371,7 +2371,7 @@ mod tests {),];- let (_columns, batches) = join_collect(left, right, on, JoinType::Inner).await?;+ let (_columns, batches) = join_collect(left, right, on, Inner).await?;let expected = ["+----+----+----+----+----+----+","| a1 | b2 | c1 | a1 | b2 | c2 |",@@ -2409,7 +2409,7 @@ mod tests {),];- let (_columns, batches) = join_collect(left, right, on, JoinType::Inner).await?;+ let (_columns, batches) = join_collect(left, right, on, Inner).await?;let expected = ["+----+----+----+----+----+----+","| a1 | b2 | c1 | a1 | b2 | c2 |",@@ -2448,7 +2448,7 @@ mod tests {),];- let (_, batches) = join_collect(left, right, on, JoinType::Inner).await?;+ let (_, batches) = join_collect(left, right, on, Inner).await?;let expected = ["+----+----+----+----+----+----+","| a1 | b2 | c1 | a1 | b2 | c2 |",@@ -2489,7 +2489,7 @@ mod tests {left,right,on,- JoinType::Inner,+ Inner,vec![SortOptions {descending: true,@@ -2539,7 +2539,7 @@ mod tests {];let (_, batches) =- join_collect_batch_size_equals_two(left, right, on, JoinType::Inner).await?;+ join_collect_batch_size_equals_two(left, right, on, Inner).await?;let expected = ["+----+----+----+----+----+----+","| a1 | b2 | c1 | a1 | b2 | c2 |",@@ -2574,7 +2574,7 @@ mod tests {Arc::new(Column::new_with_schema("b1", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Left).await?;+ let (_, batches) = join_collect(left, right, on, Left).await?;let expected = ["+----+----+----+----+----+----+","| a1 | b1 | c1 | a2 | b1 | c2 |",@@ -2606,7 +2606,7 @@ mod tests {Arc::new(Column::new_with_schema("b1", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Right).await?;+ let (_, batches) = join_collect(left, right, on, Right).await?;let expected = ["+----+----+----+----+----+----+","| a1 | b1 | c1 | a2 | b1 | c2 |",@@ -2638,7 +2638,7 @@ mod tests {Arc::new(Column::new_with_schema("b2", &right.schema()).unwrap()) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Full).await?;+ let (_, batches) = join_collect(left, right, on, Full).await?;let expected = ["+----+----+----+----+----+----+","| a1 | b1 | c1 | a2 | b2 | c2 |",@@ -2670,7 +2670,7 @@ mod tests {Arc::new(Column::new_with_schema("b1", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::LeftAnti).await?;+ let (_, batches) = join_collect(left, right, on, LeftAnti).await?;let expected = ["+----+----+----+","| a1 | b1 | c1 |",@@ -2701,7 +2701,7 @@ mod tests {Arc::new(Column::new_with_schema("b1", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::LeftSemi).await?;+ let (_, batches) = join_collect(left, right, on, LeftSemi).await?;let expected = ["+----+----+----+","| a1 | b1 | c1 |",@@ -2734,7 +2734,7 @@ mod tests {Arc::new(Column::new_with_schema("b", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Inner).await?;+ let (_, batches) = join_collect(left, right, on, Inner).await?;let expected = ["+---+---+---+----+---+----+","| a | b | c | a | b | c |",@@ -2766,7 +2766,7 @@ mod tests {Arc::new(Column::new_with_schema("b1", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Inner).await?;+ let (_, batches) = join_collect(left, right, on, Inner).await?;let expected = ["+------------+------------+------------+------------+------------+------------+","| a1 | b1 | c1 | a2 | b1 | c2 |",@@ -2798,7 +2798,7 @@ mod tests {Arc::new(Column::new_with_schema("b1", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Inner).await?;+ let (_, batches) = join_collect(left, right, on, Inner).await?;let expected = ["+-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+","| a1 | b1 | c1 | a2 | b1 | c2 |",@@ -2829,7 +2829,7 @@ mod tests {Arc::new(Column::new_with_schema("b2", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Left).await?;+ let (_, batches) = join_collect(left, right, on, Left).await?;let expected = ["+----+----+----+----+----+----+","| a1 | b1 | c1 | a2 | b2 | c2 |",@@ -2865,7 +2865,7 @@ mod tests {Arc::new(Column::new_with_schema("b2", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Right).await?;+ let (_, batches) = join_collect(left, right, on, Right).await?;let expected = ["+----+----+----+----+----+----+","| a1 | b1 | c1 | a2 | b2 | c2 |",@@ -2909,7 +2909,7 @@ mod tests {Arc::new(Column::new_with_schema("b2", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Left).await?;+ let (_, batches) = join_collect(left, right, on, Left).await?;let expected = vec!["+----+----+----+----+----+----+","| a1 | b1 | c1 | a2 | b2 | c2 |",@@ -2958,7 +2958,7 @@ mod tests {Arc::new(Column::new_with_schema("b2", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Right).await?;+ let (_, batches) = join_collect(left, right, on, Right).await?;let expected = vec!["+----+----+----+----+----+----+","| a1 | b1 | c1 | a2 | b2 | c2 |",@@ -3007,7 +3007,7 @@ mod tests {Arc::new(Column::new_with_schema("b2", &right.schema())?) as _,)];- let (_, batches) = join_collect(left, right, on, JoinType::Full).await?;+ let (_, batches) = join_collect(left, right, on, Full).await?;let expected = vec!["+----+----+----+----+----+----+","| a1 | b1 | c1 | a2 | b2 | c2 |",@@ -3047,14 +3047,7 @@ mod tests {)];let sort_options = vec![SortOptions::default(); on.len()];- let join_types = vec![- JoinType::Inner,- JoinType::Left,- JoinType::Right,- JoinType::Full,- JoinType::LeftSemi,- JoinType::LeftAnti,- ];+ let join_types = vec![Inner, Left, Right, Full, LeftSemi, LeftAnti];// Disable DiskManager to prevent spillinglet runtime = RuntimeEnvBuilder::new()@@ -3132,14 +3125,7 @@ mod tests {)];let sort_options = vec![SortOptions::default(); on.len()];- let join_types = vec![- JoinType::Inner,- JoinType::Left,- JoinType::Right,- JoinType::Full,- JoinType::LeftSemi,- JoinType::LeftAnti,- ];+ let join_types = vec![Inner, Left, Right, Full, LeftSemi, LeftAnti];// Disable DiskManager to prevent spillinglet runtime = RuntimeEnvBuilder::new()@@ -3195,14 +3181,7 @@ mod tests {)];let sort_options = vec![SortOptions::default(); on.len()];- let join_types = [- JoinType::Inner,- JoinType::Left,- JoinType::Right,- JoinType::Full,- JoinType::LeftSemi,- JoinType::LeftAnti,- ];+ let join_types = [Inner, Left, Right, Full, LeftSemi, LeftAnti];// Enable DiskManager to allow spillinglet runtime = RuntimeEnvBuilder::new()@@ -3303,14 +3282,7 @@ mod tests {)];let sort_options = vec![SortOptions::default(); on.len()];- let join_types = [- JoinType::Inner,- JoinType::Left,- JoinType::Right,- JoinType::Full,- JoinType::LeftSemi,- JoinType::LeftAnti,- ];+ let join_types = [Inner, Left, Right, Full, LeftSemi, LeftAnti];// Enable DiskManager to allow spillinglet runtime = RuntimeEnvBuilder::new()diff --git a/datafusion/physical-plan/src/joins/stream_join_utils.rs b/datafusion/physical-plan/src/joins/stream_join_utils.rsindex bddd152341..02c71dab3d 100644--- a/datafusion/physical-plan/src/joins/stream_join_utils.rs+++ b/datafusion/physical-plan/src/joins/stream_join_utils.rs@@ -19,6 +19,7 @@//! related functionality, used both in join calculations and optimization rules.use std::collections::{HashMap, VecDeque};+use std::mem::size_of;use std::sync::Arc;use crate::joins::utils::{JoinFilter, JoinHashMapType};@@ -153,8 +154,7 @@ impl PruningJoinHashMap {/// # Returns/// The size of the hash map in bytes.pub(crate) fn size(&self) -> usize {- self.map.allocation_info().1.size()- + self.next.capacity() * std::mem::size_of::<u64>()+ self.map.allocation_info().1.size() + self.next.capacity() * size_of::<u64>()}/// Removes hash values from the map and the list based on the given pruningdiff --git a/datafusion/physical-plan/src/joins/symmetric_hash_join.rs b/datafusion/physical-plan/src/joins/symmetric_hash_join.rsindex 70ada3892a..eb6a30d17e 100644--- a/datafusion/physical-plan/src/joins/symmetric_hash_join.rs+++ b/datafusion/physical-plan/src/joins/symmetric_hash_join.rs@@ -27,6 +27,7 @@use std::any::Any;use std::fmt::{self, Debug};+use std::mem::{size_of, size_of_val};use std::sync::Arc;use std::task::{Context, Poll};use std::vec;@@ -604,7 +605,7 @@ impl<T: BatchTransformer + Unpin + Send> Stream for SymmetricHashJoinStream<T> {fn poll_next(mut self: std::pin::Pin<&mut Self>,- cx: &mut std::task::Context<'_>,+ cx: &mut Context<'_>,) -> Poll<Option<Self::Item>> {self.poll_next_impl(cx)}@@ -1004,15 +1005,15 @@ pub struct OneSideHashJoiner {impl OneSideHashJoiner {pub fn size(&self) -> usize {let mut size = 0;- size += std::mem::size_of_val(self);- size += std::mem::size_of_val(&self.build_side);+ size += size_of_val(self);+ size += size_of_val(&self.build_side);size += self.input_buffer.get_array_memory_size();- size += std::mem::size_of_val(&self.on);+ size += size_of_val(&self.on);size += self.hashmap.size();- size += self.hashes_buffer.capacity() * std::mem::size_of::<u64>();- size += self.visited_rows.capacity() * std::mem::size_of::<usize>();- size += std::mem::size_of_val(&self.offset);- size += std::mem::size_of_val(&self.deleted_offset);+ size += self.hashes_buffer.capacity() * size_of::<u64>();+ size += self.visited_rows.capacity() * size_of::<usize>();+ size += size_of_val(&self.offset);+ size += size_of_val(&self.deleted_offset);size}pub fn new(@@ -1463,18 +1464,18 @@ impl<T: BatchTransformer> SymmetricHashJoinStream<T> {fn size(&self) -> usize {let mut size = 0;- size += std::mem::size_of_val(&self.schema);- size += std::mem::size_of_val(&self.filter);- size += std::mem::size_of_val(&self.join_type);+ size += size_of_val(&self.schema);+ size += size_of_val(&self.filter);+ size += size_of_val(&self.join_type);size += self.left.size();size += self.right.size();- size += std::mem::size_of_val(&self.column_indices);+ size += size_of_val(&self.column_indices);size += self.graph.as_ref().map(|g| g.size()).unwrap_or(0);- size += std::mem::size_of_val(&self.left_sorted_filter_expr);- size += std::mem::size_of_val(&self.right_sorted_filter_expr);- size += std::mem::size_of_val(&self.random_state);- size += std::mem::size_of_val(&self.null_equals_null);- size += std::mem::size_of_val(&self.metrics);+ size += size_of_val(&self.left_sorted_filter_expr);+ size += size_of_val(&self.right_sorted_filter_expr);+ size += size_of_val(&self.random_state);+ size += size_of_val(&self.null_equals_null);+ size += size_of_val(&self.metrics);size}diff --git a/datafusion/physical-plan/src/joins/utils.rs b/datafusion/physical-plan/src/joins/utils.rsindex 17a32a67c7..090cf9aa62 100644--- a/datafusion/physical-plan/src/joins/utils.rs+++ b/datafusion/physical-plan/src/joins/utils.rs@@ -369,7 +369,7 @@ impl JoinHashMapType for JoinHashMap {}}-impl fmt::Debug for JoinHashMap {+impl Debug for JoinHashMap {fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {Ok(())}@@ -727,8 +727,8 @@ impl<T> Default for OnceAsync<T> {}}-impl<T> std::fmt::Debug for OnceAsync<T> {- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+impl<T> Debug for OnceAsync<T> {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {write!(f, "OnceAsync")}}@@ -1952,13 +1952,13 @@ mod tests {) -> Statistics {Statistics {num_rows: if is_exact {- num_rows.map(Precision::Exact)+ num_rows.map(Exact)} else {- num_rows.map(Precision::Inexact)+ num_rows.map(Inexact)}- .unwrap_or(Precision::Absent),+ .unwrap_or(Absent),column_statistics: column_stats,- total_byte_size: Precision::Absent,+ total_byte_size: Absent,}}@@ -2204,17 +2204,17 @@ mod tests {assert_eq!(estimate_inner_join_cardinality(Statistics {- num_rows: Precision::Inexact(400),- total_byte_size: Precision::Absent,+ num_rows: Inexact(400),+ total_byte_size: Absent,column_statistics: left_col_stats,},Statistics {- num_rows: Precision::Inexact(400),- total_byte_size: Precision::Absent,+ num_rows: Inexact(400),+ total_byte_size: Absent,column_statistics: right_col_stats,},),- Some(Precision::Inexact((400 * 400) / 200))+ Some(Inexact((400 * 400) / 200)));Ok(())}@@ -2222,33 +2222,33 @@ mod tests {#[test]fn test_inner_join_cardinality_decimal_range() -> Result<()> {let left_col_stats = vec![ColumnStatistics {- distinct_count: Precision::Absent,- min_value: Precision::Inexact(ScalarValue::Decimal128(Some(32500), 14, 4)),- max_value: Precision::Inexact(ScalarValue::Decimal128(Some(35000), 14, 4)),+ distinct_count: Absent,+ min_value: Inexact(ScalarValue::Decimal128(Some(32500), 14, 4)),+ max_value: Inexact(ScalarValue::Decimal128(Some(35000), 14, 4)),..Default::default()}];let right_col_stats = vec![ColumnStatistics {- distinct_count: Precision::Absent,- min_value: Precision::Inexact(ScalarValue::Decimal128(Some(33500), 14, 4)),- max_value: Precision::Inexact(ScalarValue::Decimal128(Some(34000), 14, 4)),+ distinct_count: Absent,+ min_value: Inexact(ScalarValue::Decimal128(Some(33500), 14, 4)),+ max_value: Inexact(ScalarValue::Decimal128(Some(34000), 14, 4)),..Default::default()}];assert_eq!(estimate_inner_join_cardinality(Statistics {- num_rows: Precision::Inexact(100),- total_byte_size: Precision::Absent,+ num_rows: Inexact(100),+ total_byte_size: Absent,column_statistics: left_col_stats,},Statistics {- num_rows: Precision::Inexact(100),- total_byte_size: Precision::Absent,+ num_rows: Inexact(100),+ total_byte_size: Absent,column_statistics: right_col_stats,},),- Some(Precision::Inexact(100))+ Some(Inexact(100)));Ok(())}diff --git a/datafusion/physical-plan/src/limit.rs b/datafusion/physical-plan/src/limit.rsindex eda75b37fe..1fe550a930 100644--- a/datafusion/physical-plan/src/limit.rs+++ b/datafusion/physical-plan/src/limit.rs@@ -473,7 +473,7 @@ mod tests {use super::*;use crate::coalesce_partitions::CoalescePartitionsExec;use crate::common::collect;- use crate::{common, test};+ use crate::test;use crate::aggregates::{AggregateExec, AggregateMode, PhysicalGroupBy};use arrow_array::RecordBatchOptions;@@ -497,7 +497,7 @@ mod tests {// The result should contain 4 batches (one per input partition)let iter = limit.execute(0, task_ctx)?;- let batches = common::collect(iter).await?;+ let batches = collect(iter).await?;// There should be a total of 100 rowslet row_count: usize = batches.iter().map(|batch| batch.num_rows()).sum();@@ -613,7 +613,7 @@ mod tests {// The result should contain 4 batches (one per input partition)let iter = offset.execute(0, task_ctx)?;- let batches = common::collect(iter).await?;+ let batches = collect(iter).await?;Ok(batches.iter().map(|batch| batch.num_rows()).sum())}diff --git a/datafusion/physical-plan/src/memory.rs b/datafusion/physical-plan/src/memory.rsindex 52a8631d5a..dd4868d1bf 100644--- a/datafusion/physical-plan/src/memory.rs+++ b/datafusion/physical-plan/src/memory.rs@@ -69,11 +69,7 @@ impl fmt::Debug for MemoryExec {}impl DisplayAs for MemoryExec {- fn fmt_as(- &self,- t: DisplayFormatType,- f: &mut std::fmt::Formatter,- ) -> std::fmt::Result {+ fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter) -> fmt::Result {match t {DisplayFormatType::Default | DisplayFormatType::Verbose => {let partition_sizes: Vec<_> =diff --git a/datafusion/physical-plan/src/metrics/value.rs b/datafusion/physical-plan/src/metrics/value.rsindex 5a335d9f99..2eb01914ee 100644--- a/datafusion/physical-plan/src/metrics/value.rs+++ b/datafusion/physical-plan/src/metrics/value.rs@@ -168,7 +168,7 @@ impl PartialEq for Time {impl Display for Time {fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {- let duration = std::time::Duration::from_nanos(self.value() as u64);+ let duration = Duration::from_nanos(self.value() as u64);write!(f, "{duration:?}")}}diff --git a/datafusion/physical-plan/src/projection.rs b/datafusion/physical-plan/src/projection.rsindex 936cf742a7..c1d3f36836 100644--- a/datafusion/physical-plan/src/projection.rs+++ b/datafusion/physical-plan/src/projection.rs@@ -356,7 +356,6 @@ impl RecordBatchStream for ProjectionStream {mod tests {use super::*;use crate::common::collect;- use crate::expressions;use crate::test;use arrow_schema::DataType;@@ -418,8 +417,8 @@ mod tests {let schema = get_schema();let exprs: Vec<Arc<dyn PhysicalExpr>> = vec![- Arc::new(expressions::Column::new("col1", 1)),- Arc::new(expressions::Column::new("col0", 0)),+ Arc::new(Column::new("col1", 1)),+ Arc::new(Column::new("col0", 0)),];let result = stats_projection(source, exprs.into_iter(), Arc::new(schema));@@ -452,8 +451,8 @@ mod tests {let schema = get_schema();let exprs: Vec<Arc<dyn PhysicalExpr>> = vec![- Arc::new(expressions::Column::new("col2", 2)),- Arc::new(expressions::Column::new("col0", 0)),+ Arc::new(Column::new("col2", 2)),+ Arc::new(Column::new("col0", 0)),];let result = stats_projection(source, exprs.into_iter(), Arc::new(schema));diff --git a/datafusion/physical-plan/src/repartition/distributor_channels.rs b/datafusion/physical-plan/src/repartition/distributor_channels.rsindex 675d26bbfb..2e5ef24bea 100644--- a/datafusion/physical-plan/src/repartition/distributor_channels.rs+++ b/datafusion/physical-plan/src/repartition/distributor_channels.rs@@ -829,7 +829,7 @@ mod tests {{let test_waker = Arc::new(TestWaker::default());let waker = futures::task::waker(Arc::clone(&test_waker));- let mut cx = std::task::Context::from_waker(&waker);+ let mut cx = Context::from_waker(&waker);let res = fut.poll_unpin(&mut cx);(res, test_waker)}diff --git a/datafusion/physical-plan/src/repartition/mod.rs b/datafusion/physical-plan/src/repartition/mod.rsindex 90e62d6f11..601c1e8731 100644--- a/datafusion/physical-plan/src/repartition/mod.rs+++ b/datafusion/physical-plan/src/repartition/mod.rs@@ -1326,7 +1326,7 @@ mod tests {// now, purposely drop output stream 0// *before* any outputs are produced- std::mem::drop(output_stream0);+ drop(output_stream0);// Now, start sending inputlet mut background_task = JoinSet::new();@@ -1401,7 +1401,7 @@ mod tests {let output_stream1 = exec.execute(1, Arc::clone(&task_ctx)).unwrap();// now, purposely drop output stream 0// *before* any outputs are produced- std::mem::drop(output_stream0);+ drop(output_stream0);let mut background_task = JoinSet::new();background_task.spawn(async move {input.wait().await;diff --git a/datafusion/physical-plan/src/sorts/sort.rs b/datafusion/physical-plan/src/sorts/sort.rsindex 8e13a2e07e..921678a4ad 100644--- a/datafusion/physical-plan/src/sorts/sort.rs+++ b/datafusion/physical-plan/src/sorts/sort.rs@@ -815,11 +815,7 @@ impl SortExec {}impl DisplayAs for SortExec {- fn fmt_as(- &self,- t: DisplayFormatType,- f: &mut std::fmt::Formatter,- ) -> std::fmt::Result {+ fn fmt_as(&self, t: DisplayFormatType, f: &mut Formatter) -> fmt::Result {match t {DisplayFormatType::Default | DisplayFormatType::Verbose => {let expr = PhysicalSortExpr::format_list(&self.expr);@@ -1018,7 +1014,7 @@ mod tests {}impl DisplayAs for SortedUnboundedExec {- fn fmt_as(&self, t: DisplayFormatType, f: &mut Formatter) -> std::fmt::Result {+ fn fmt_as(&self, t: DisplayFormatType, f: &mut Formatter) -> fmt::Result {match t {DisplayFormatType::Default | DisplayFormatType::Verbose => {write!(f, "UnboundableExec",).unwrap()diff --git a/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs b/datafusion/physical-plan/src/sorts/sort_preserving_merge.rsindex 3d3f9dcb98..31a4ed61cf 100644--- a/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs+++ b/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs@@ -946,7 +946,7 @@ mod tests {while let Some(batch) = stream.next().await {sender.send(batch).await.unwrap();// This causes the MergeStream to wait for more input- tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;+ tokio::time::sleep(Duration::from_millis(10)).await;}Ok(())diff --git a/datafusion/physical-plan/src/stream.rs b/datafusion/physical-plan/src/stream.rsindex 9220646653..ec4c9dd502 100644--- a/datafusion/physical-plan/src/stream.rs+++ b/datafusion/physical-plan/src/stream.rs@@ -437,12 +437,12 @@ impl ObservedStream {}impl RecordBatchStream for ObservedStream {- fn schema(&self) -> arrow::datatypes::SchemaRef {+ fn schema(&self) -> SchemaRef {self.inner.schema()}}-impl futures::Stream for ObservedStream {+impl Stream for ObservedStream {type Item = Result<RecordBatch>;fn poll_next(diff --git a/datafusion/physical-plan/src/streaming.rs b/datafusion/physical-plan/src/streaming.rsindex 0f7c75c2c9..cdb94af1fe 100644--- a/datafusion/physical-plan/src/streaming.rs+++ b/datafusion/physical-plan/src/streaming.rs@@ -163,7 +163,7 @@ impl StreamingTableExec {}}-impl std::fmt::Debug for StreamingTableExec {+impl Debug for StreamingTableExec {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {f.debug_struct("LazyMemTableExec").finish_non_exhaustive()}diff --git a/datafusion/physical-plan/src/topk/mod.rs b/datafusion/physical-plan/src/topk/mod.rsindex d3f1a4fd96..9b46ad2ec7 100644--- a/datafusion/physical-plan/src/topk/mod.rs+++ b/datafusion/physical-plan/src/topk/mod.rs@@ -21,6 +21,7 @@ use arrow::{compute::interleave,row::{RowConverter, Rows, SortField},};+use std::mem::size_of;use std::{cmp::Ordering, collections::BinaryHeap, sync::Arc};use arrow_array::{Array, ArrayRef, RecordBatch};@@ -225,7 +226,7 @@ impl TopK {/// return the size of memory used by this operator, in bytesfn size(&self) -> usize {- std::mem::size_of::<Self>()+ size_of::<Self>()+ self.row_converter.size()+ self.scratch_rows.size()+ self.heap.size()@@ -444,8 +445,8 @@ impl TopKHeap {/// return the size of memory used by this heap, in bytesfn size(&self) -> usize {- std::mem::size_of::<Self>()- + (self.inner.capacity() * std::mem::size_of::<TopKRow>())+ size_of::<Self>()+ + (self.inner.capacity() * size_of::<TopKRow>())+ self.store.size()+ self.owned_bytes}@@ -636,9 +637,8 @@ impl RecordBatchStore {/// returns the size of memory used by this store, including all/// referenced `RecordBatch`es, in bytespub fn size(&self) -> usize {- std::mem::size_of::<Self>()- + self.batches.capacity()- * (std::mem::size_of::<u32>() + std::mem::size_of::<RecordBatchEntry>())+ size_of::<Self>()+ + self.batches.capacity() * (size_of::<u32>() + size_of::<RecordBatchEntry>())+ self.batches_size}}diff --git a/datafusion/physical-plan/src/unnest.rs b/datafusion/physical-plan/src/unnest.rsindex 40ec3830ea..3e312b7451 100644--- a/datafusion/physical-plan/src/unnest.rs+++ b/datafusion/physical-plan/src/unnest.rs@@ -984,7 +984,7 @@ mod tests {list_array: &dyn ListArrayType,lengths: Vec<i64>,expected: Vec<Option<&str>>,- ) -> datafusion_common::Result<()> {+ ) -> Result<()> {let length_array = Int64Array::from(lengths);let unnested_array = unnest_list_array(list_array, &length_array, 3 * 6)?;let strs = unnested_array.as_string::<i32>().iter().collect::<Vec<_>>();@@ -993,7 +993,7 @@ mod tests {}#[test]- fn test_build_batch_list_arr_recursive() -> datafusion_common::Result<()> {+ fn test_build_batch_list_arr_recursive() -> Result<()> {// col1 | col2// [[1,2,3],null,[4,5]] | ['a','b']// [[7,8,9,10], null, [11,12,13]] | ['c','d']@@ -1125,7 +1125,7 @@ mod tests {}#[test]- fn test_unnest_list_array() -> datafusion_common::Result<()> {+ fn test_unnest_list_array() -> Result<()> {// [A, B, C], [], NULL, [D], NULL, [NULL, F]let list_array = make_generic_array::<i32>();verify_unnest_list_array(@@ -1173,7 +1173,7 @@ mod tests {list_arrays: &[ArrayRef],preserve_nulls: bool,expected: Vec<i64>,- ) -> datafusion_common::Result<()> {+ ) -> Result<()> {let options = UnnestOptions {preserve_nulls,recursions: vec![],@@ -1191,7 +1191,7 @@ mod tests {}#[test]- fn test_longest_list_length() -> datafusion_common::Result<()> {+ fn test_longest_list_length() -> Result<()> {// Test with single ListArray// [A, B, C], [], NULL, [D], NULL, [NULL, F]let list_array = Arc::new(make_generic_array::<i32>()) as ArrayRef;@@ -1223,7 +1223,7 @@ mod tests {}#[test]- fn test_create_take_indicies() -> datafusion_common::Result<()> {+ fn test_create_take_indicies() -> Result<()> {let length_array = Int64Array::from(vec![2, 3, 1]);let take_indicies = create_take_indicies(&length_array, 6);let expected = Int64Array::from(vec![0, 0, 1, 1, 1, 2]);diff --git a/datafusion/proto/Cargo.toml b/datafusion/proto/Cargo.tomlindex 3ffe5e3e76..9e4b331a01 100644--- a/datafusion/proto/Cargo.toml+++ b/datafusion/proto/Cargo.toml@@ -32,9 +32,6 @@ rust-version = "1.79"# Exclude proto files so crates.io consumers don't need protocexclude = ["*.proto"]-[lints]-workspace = true-[lib]name = "datafusion_proto"path = "src/lib.rs"diff --git a/datafusion/proto/src/logical_plan/file_formats.rs b/datafusion/proto/src/logical_plan/file_formats.rsindex d0f82ecac6..02be3e11c1 100644--- a/datafusion/proto/src/logical_plan/file_formats.rs+++ b/datafusion/proto/src/logical_plan/file_formats.rs@@ -161,7 +161,7 @@ impl LogicalExtensionCodec for CsvLogicalExtensionCodec {&self,_buf: &[u8],_inputs: &[datafusion_expr::LogicalPlan],- _ctx: &datafusion::prelude::SessionContext,+ _ctx: &SessionContext,) -> datafusion_common::Result<datafusion_expr::Extension> {not_impl_err!("Method not implemented")}@@ -179,7 +179,7 @@ impl LogicalExtensionCodec for CsvLogicalExtensionCodec {_buf: &[u8],_table_ref: &TableReference,_schema: arrow::datatypes::SchemaRef,- _ctx: &datafusion::prelude::SessionContext,+ _ctx: &SessionContext,) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {not_impl_err!("Method not implemented")}@@ -271,7 +271,7 @@ impl LogicalExtensionCodec for JsonLogicalExtensionCodec {&self,_buf: &[u8],_inputs: &[datafusion_expr::LogicalPlan],- _ctx: &datafusion::prelude::SessionContext,+ _ctx: &SessionContext,) -> datafusion_common::Result<datafusion_expr::Extension> {not_impl_err!("Method not implemented")}@@ -289,7 +289,7 @@ impl LogicalExtensionCodec for JsonLogicalExtensionCodec {_buf: &[u8],_table_ref: &TableReference,_schema: arrow::datatypes::SchemaRef,- _ctx: &datafusion::prelude::SessionContext,+ _ctx: &SessionContext,) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {not_impl_err!("Method not implemented")}@@ -570,7 +570,7 @@ impl LogicalExtensionCodec for ParquetLogicalExtensionCodec {&self,_buf: &[u8],_inputs: &[datafusion_expr::LogicalPlan],- _ctx: &datafusion::prelude::SessionContext,+ _ctx: &SessionContext,) -> datafusion_common::Result<datafusion_expr::Extension> {not_impl_err!("Method not implemented")}@@ -588,7 +588,7 @@ impl LogicalExtensionCodec for ParquetLogicalExtensionCodec {_buf: &[u8],_table_ref: &TableReference,_schema: arrow::datatypes::SchemaRef,- _ctx: &datafusion::prelude::SessionContext,+ _ctx: &SessionContext,) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {not_impl_err!("Method not implemented")}@@ -658,7 +658,7 @@ impl LogicalExtensionCodec for ArrowLogicalExtensionCodec {&self,_buf: &[u8],_inputs: &[datafusion_expr::LogicalPlan],- _ctx: &datafusion::prelude::SessionContext,+ _ctx: &SessionContext,) -> datafusion_common::Result<datafusion_expr::Extension> {not_impl_err!("Method not implemented")}@@ -676,7 +676,7 @@ impl LogicalExtensionCodec for ArrowLogicalExtensionCodec {_buf: &[u8],_table_ref: &TableReference,_schema: arrow::datatypes::SchemaRef,- _ctx: &datafusion::prelude::SessionContext,+ _ctx: &SessionContext,) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {not_impl_err!("Method not implemented")}@@ -716,7 +716,7 @@ impl LogicalExtensionCodec for AvroLogicalExtensionCodec {&self,_buf: &[u8],_inputs: &[datafusion_expr::LogicalPlan],- _ctx: &datafusion::prelude::SessionContext,+ _ctx: &SessionContext,) -> datafusion_common::Result<datafusion_expr::Extension> {not_impl_err!("Method not implemented")}@@ -734,7 +734,7 @@ impl LogicalExtensionCodec for AvroLogicalExtensionCodec {_buf: &[u8],_table_ref: &TableReference,_schema: arrow::datatypes::SchemaRef,- _cts: &datafusion::prelude::SessionContext,+ _cts: &SessionContext,) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {not_impl_err!("Method not implemented")}diff --git a/datafusion/proto/src/logical_plan/mod.rs b/datafusion/proto/src/logical_plan/mod.rsindex d80c6b7165..b90ae88aa7 100644--- a/datafusion/proto/src/logical_plan/mod.rs+++ b/datafusion/proto/src/logical_plan/mod.rs@@ -450,7 +450,7 @@ impl AsLogicalPlan for LogicalPlanNode {)?.build()}- LogicalPlanType::CustomScan(scan) => {+ CustomScan(scan) => {let schema: Schema = convert_required!(scan.schema)?;let schema = Arc::new(schema);let mut projection = None;@@ -844,13 +844,13 @@ impl AsLogicalPlan for LogicalPlanNode {.prepare(prepare.name.clone(), data_types)?.build()}- LogicalPlanType::DropView(dropview) => Ok(datafusion_expr::LogicalPlan::Ddl(- datafusion_expr::DdlStatement::DropView(DropView {+ LogicalPlanType::DropView(dropview) => {+ Ok(LogicalPlan::Ddl(DdlStatement::DropView(DropView {name: from_table_reference(dropview.name.as_ref(), "DropView")?,if_exists: dropview.if_exists,schema: Arc::new(convert_required!(dropview.schema)?),- }),- )),+ })))+ }LogicalPlanType::CopyTo(copy) => {let input: LogicalPlan =into_logical_plan!(copy.input, ctx, extension_codec)?;@@ -859,20 +859,18 @@ impl AsLogicalPlan for LogicalPlanNode {extension_codec.try_decode_file_format(©.file_type, ctx)?,);- Ok(datafusion_expr::LogicalPlan::Copy(- datafusion_expr::dml::CopyTo {- input: Arc::new(input),- output_url: copy.output_url.clone(),- partition_by: copy.partition_by.clone(),- file_type,- options: Default::default(),- },- ))+ Ok(LogicalPlan::Copy(dml::CopyTo {+ input: Arc::new(input),+ output_url: copy.output_url.clone(),+ partition_by: copy.partition_by.clone(),+ file_type,+ options: Default::default(),+ }))}LogicalPlanType::Unnest(unnest) => {let input: LogicalPlan =into_logical_plan!(unnest.input, ctx, extension_codec)?;- Ok(datafusion_expr::LogicalPlan::Unnest(Unnest {+ Ok(LogicalPlan::Unnest(Unnest {input: Arc::new(input),exec_columns: unnest.exec_columns.iter().map(|c| c.into()).collect(),list_type_columns: unnest@@ -926,7 +924,7 @@ impl AsLogicalPlan for LogicalPlanNode {} as u64;let values_list =serialize_exprs(values.iter().flatten(), extension_codec)?;- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Values(protobuf::ValuesNode {n_cols,@@ -1018,7 +1016,7 @@ impl AsLogicalPlan for LogicalPlanNode {exprs_vec.push(expr_vec);}- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::ListingScan(protobuf::ListingTableScanNode {file_format_type: Some(file_format_type),@@ -1044,12 +1042,12 @@ impl AsLogicalPlan for LogicalPlanNode {)),})} else if let Some(view_table) = source.downcast_ref::<ViewTable>() {- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::ViewScan(Box::new(protobuf::ViewTableScanNode {table_name: Some(table_name.clone().into()),input: Some(Box::new(- protobuf::LogicalPlanNode::try_from_logical_plan(+ LogicalPlanNode::try_from_logical_plan(view_table.logical_plan(),extension_codec,)?,@@ -1082,11 +1080,11 @@ impl AsLogicalPlan for LogicalPlanNode {}}LogicalPlan::Projection(Projection { expr, input, .. }) => {- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Projection(Box::new(protobuf::ProjectionNode {input: Some(Box::new(- protobuf::LogicalPlanNode::try_from_logical_plan(+ LogicalPlanNode::try_from_logical_plan(input.as_ref(),extension_codec,)?,@@ -1098,12 +1096,11 @@ impl AsLogicalPlan for LogicalPlanNode {})}LogicalPlan::Filter(filter) => {- let input: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- filter.input.as_ref(),- extension_codec,- )?;- Ok(protobuf::LogicalPlanNode {+ let input: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ filter.input.as_ref(),+ extension_codec,+ )?;+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Selection(Box::new(protobuf::SelectionNode {input: Some(Box::new(input)),@@ -1116,12 +1113,11 @@ impl AsLogicalPlan for LogicalPlanNode {})}LogicalPlan::Distinct(Distinct::All(input)) => {- let input: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- input.as_ref(),- extension_codec,- )?;- Ok(protobuf::LogicalPlanNode {+ let input: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ input.as_ref(),+ extension_codec,+ )?;+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Distinct(Box::new(protobuf::DistinctNode {input: Some(Box::new(input)),@@ -1136,16 +1132,15 @@ impl AsLogicalPlan for LogicalPlanNode {input,..})) => {- let input: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- input.as_ref(),- extension_codec,- )?;+ let input: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ input.as_ref(),+ extension_codec,+ )?;let sort_expr = match sort_expr {None => vec![],Some(sort_expr) => serialize_sorts(sort_expr, extension_codec)?,};- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::DistinctOn(Box::new(protobuf::DistinctOnNode {on_expr: serialize_exprs(on_expr, extension_codec)?,@@ -1159,12 +1154,11 @@ impl AsLogicalPlan for LogicalPlanNode {LogicalPlan::Window(Window {input, window_expr, ..}) => {- let input: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- input.as_ref(),- extension_codec,- )?;- Ok(protobuf::LogicalPlanNode {+ let input: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ input.as_ref(),+ extension_codec,+ )?;+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Window(Box::new(protobuf::WindowNode {input: Some(Box::new(input)),@@ -1179,12 +1173,11 @@ impl AsLogicalPlan for LogicalPlanNode {input,..}) => {- let input: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- input.as_ref(),- extension_codec,- )?;- Ok(protobuf::LogicalPlanNode {+ let input: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ input.as_ref(),+ extension_codec,+ )?;+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Aggregate(Box::new(protobuf::AggregateNode {input: Some(Box::new(input)),@@ -1204,16 +1197,14 @@ impl AsLogicalPlan for LogicalPlanNode {null_equals_null,..}) => {- let left: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- left.as_ref(),- extension_codec,- )?;- let right: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- right.as_ref(),- extension_codec,- )?;+ let left: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ left.as_ref(),+ extension_codec,+ )?;+ let right: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ right.as_ref(),+ extension_codec,+ )?;let (left_join_key, right_join_key) = on.iter().map(|(l, r)| {@@ -1232,7 +1223,7 @@ impl AsLogicalPlan for LogicalPlanNode {.as_ref().map(|e| serialize_expr(e, extension_codec)).map_or(Ok(None), |v| v.map(Some))?;- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Join(Box::new(protobuf::JoinNode {left: Some(Box::new(left)),@@ -1251,12 +1242,11 @@ impl AsLogicalPlan for LogicalPlanNode {not_impl_err!("LogicalPlan serde is not yet implemented for subqueries")}LogicalPlan::SubqueryAlias(SubqueryAlias { input, alias, .. }) => {- let input: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- input.as_ref(),- extension_codec,- )?;- Ok(protobuf::LogicalPlanNode {+ let input: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ input.as_ref(),+ extension_codec,+ )?;+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::SubqueryAlias(Box::new(protobuf::SubqueryAliasNode {input: Some(Box::new(input)),@@ -1266,11 +1256,10 @@ impl AsLogicalPlan for LogicalPlanNode {})}LogicalPlan::Limit(limit) => {- let input: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- limit.input.as_ref(),- extension_codec,- )?;+ let input: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ limit.input.as_ref(),+ extension_codec,+ )?;let SkipType::Literal(skip) = limit.get_skip_type()? else {return Err(proto_error("LogicalPlan::Limit only supports literal skip values",@@ -1282,7 +1271,7 @@ impl AsLogicalPlan for LogicalPlanNode {));};- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Limit(Box::new(protobuf::LimitNode {input: Some(Box::new(input)),@@ -1293,14 +1282,13 @@ impl AsLogicalPlan for LogicalPlanNode {})}LogicalPlan::Sort(Sort { input, expr, fetch }) => {- let input: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- input.as_ref(),- extension_codec,- )?;+ let input: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ input.as_ref(),+ extension_codec,+ )?;let sort_expr: Vec<protobuf::SortExprNode> =serialize_sorts(expr, extension_codec)?;- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Sort(Box::new(protobuf::SortNode {input: Some(Box::new(input)),@@ -1315,11 +1303,10 @@ impl AsLogicalPlan for LogicalPlanNode {partitioning_scheme,}) => {use datafusion::logical_expr::Partitioning;- let input: protobuf::LogicalPlanNode =- protobuf::LogicalPlanNode::try_from_logical_plan(- input.as_ref(),- extension_codec,- )?;+ let input: LogicalPlanNode = LogicalPlanNode::try_from_logical_plan(+ input.as_ref(),+ extension_codec,+ )?;// Assumed common usize field was batch size// Used u64 to avoid any nastyness involving large values, most data clusters are probably uniformly 64 bits any ways@@ -1340,7 +1327,7 @@ impl AsLogicalPlan for LogicalPlanNode {}};- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Repartition(Box::new(protobuf::RepartitionNode {input: Some(Box::new(input)),@@ -1351,7 +1338,7 @@ impl AsLogicalPlan for LogicalPlanNode {}LogicalPlan::EmptyRelation(EmptyRelation {produce_one_row, ..- }) => Ok(protobuf::LogicalPlanNode {+ }) => Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::EmptyRelation(protobuf::EmptyRelationNode {produce_one_row: *produce_one_row,@@ -1390,7 +1377,7 @@ impl AsLogicalPlan for LogicalPlanNode {.insert(col_name.clone(), serialize_expr(expr, extension_codec)?);}- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::CreateExternalTable(protobuf::CreateExternalTableNode {name: Some(name.clone().into()),@@ -1416,7 +1403,7 @@ impl AsLogicalPlan for LogicalPlanNode {or_replace,definition,temporary,- })) => Ok(protobuf::LogicalPlanNode {+ })) => Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::CreateView(Box::new(protobuf::CreateViewNode {name: Some(name.clone().into()),@@ -1436,7 +1423,7 @@ impl AsLogicalPlan for LogicalPlanNode {if_not_exists,schema: df_schema,},- )) => Ok(protobuf::LogicalPlanNode {+ )) => Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::CreateCatalogSchema(protobuf::CreateCatalogSchemaNode {schema_name: schema_name.clone(),@@ -1449,7 +1436,7 @@ impl AsLogicalPlan for LogicalPlanNode {catalog_name,if_not_exists,schema: df_schema,- })) => Ok(protobuf::LogicalPlanNode {+ })) => Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::CreateCatalog(protobuf::CreateCatalogNode {catalog_name: catalog_name.clone(),@@ -1459,11 +1446,11 @@ impl AsLogicalPlan for LogicalPlanNode {)),}),LogicalPlan::Analyze(a) => {- let input = protobuf::LogicalPlanNode::try_from_logical_plan(+ let input = LogicalPlanNode::try_from_logical_plan(a.input.as_ref(),extension_codec,)?;- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Analyze(Box::new(protobuf::AnalyzeNode {input: Some(Box::new(input)),@@ -1473,11 +1460,11 @@ impl AsLogicalPlan for LogicalPlanNode {})}LogicalPlan::Explain(a) => {- let input = protobuf::LogicalPlanNode::try_from_logical_plan(+ let input = LogicalPlanNode::try_from_logical_plan(a.plan.as_ref(),extension_codec,)?;- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Explain(Box::new(protobuf::ExplainNode {input: Some(Box::new(input)),@@ -1490,14 +1477,9 @@ impl AsLogicalPlan for LogicalPlanNode {let inputs: Vec<LogicalPlanNode> = union.inputs.iter()- .map(|i| {- protobuf::LogicalPlanNode::try_from_logical_plan(- i,- extension_codec,- )- })+ .map(|i| LogicalPlanNode::try_from_logical_plan(i, extension_codec)).collect::<Result<_>>()?;- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Union(protobuf::UnionNode { inputs },)),@@ -1511,15 +1493,10 @@ impl AsLogicalPlan for LogicalPlanNode {.node.inputs().iter()- .map(|i| {- protobuf::LogicalPlanNode::try_from_logical_plan(- i,- extension_codec,- )- })+ .map(|i| LogicalPlanNode::try_from_logical_plan(i, extension_codec)).collect::<Result<_>>()?;- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Extension(LogicalExtensionNode { node: buf, inputs },)),@@ -1530,11 +1507,9 @@ impl AsLogicalPlan for LogicalPlanNode {data_types,input,}) => {- let input = protobuf::LogicalPlanNode::try_from_logical_plan(- input,- extension_codec,- )?;- Ok(protobuf::LogicalPlanNode {+ let input =+ LogicalPlanNode::try_from_logical_plan(input, extension_codec)?;+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Prepare(Box::new(protobuf::PrepareNode {name: name.clone(),@@ -1556,10 +1531,8 @@ impl AsLogicalPlan for LogicalPlanNode {schema,options,}) => {- let input = protobuf::LogicalPlanNode::try_from_logical_plan(- input,- extension_codec,- )?;+ let input =+ LogicalPlanNode::try_from_logical_plan(input, extension_codec)?;let proto_unnest_list_items = list_type_columns.iter().map(|(index, ul)| ColumnUnnestListItem {@@ -1570,7 +1543,7 @@ impl AsLogicalPlan for LogicalPlanNode {}),}).collect();- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::Unnest(Box::new(protobuf::UnnestNode {input: Some(Box::new(input)),@@ -1606,7 +1579,7 @@ impl AsLogicalPlan for LogicalPlanNode {name,if_exists,schema,- })) => Ok(protobuf::LogicalPlanNode {+ })) => Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::DropView(protobuf::DropViewNode {name: Some(name.clone().into()),@@ -1637,15 +1610,13 @@ impl AsLogicalPlan for LogicalPlanNode {partition_by,..}) => {- let input = protobuf::LogicalPlanNode::try_from_logical_plan(- input,- extension_codec,- )?;+ let input =+ LogicalPlanNode::try_from_logical_plan(input, extension_codec)?;let mut buf = Vec::new();extension_codec.try_encode_file_format(&mut buf, file_type_to_format(file_type)?)?;- Ok(protobuf::LogicalPlanNode {+ Ok(LogicalPlanNode {logical_plan_type: Some(LogicalPlanType::CopyTo(Box::new(protobuf::CopyToNode {input: Some(Box::new(input)),diff --git a/datafusion/proto/src/physical_plan/mod.rs b/datafusion/proto/src/physical_plan/mod.rsindex 634ae284c9..326c7acab3 100644--- a/datafusion/proto/src/physical_plan/mod.rs+++ b/datafusion/proto/src/physical_plan/mod.rs@@ -851,7 +851,7 @@ impl AsExecutionPlan for protobuf::PhysicalPlanNode {"physical_plan::from_proto() Unexpected expr {self:?}"))})?;- if let protobuf::physical_expr_node::ExprType::Sort(sort_expr) = expr {+ if let ExprType::Sort(sort_expr) = expr {let expr = sort_expr.expr.as_ref()@@ -898,7 +898,7 @@ impl AsExecutionPlan for protobuf::PhysicalPlanNode {"physical_plan::from_proto() Unexpected expr {self:?}"))})?;- if let protobuf::physical_expr_node::ExprType::Sort(sort_expr) = expr {+ if let ExprType::Sort(sort_expr) = expr {let expr = sort_expr.expr.as_ref()@@ -1713,9 +1713,7 @@ impl AsExecutionPlan for protobuf::PhysicalPlanNode {nulls_first: expr.options.nulls_first,});Ok(protobuf::PhysicalExprNode {- expr_type: Some(protobuf::physical_expr_node::ExprType::Sort(- sort_expr,- )),+ expr_type: Some(ExprType::Sort(sort_expr)),})}).collect::<Result<Vec<_>>>()?;@@ -1782,9 +1780,7 @@ impl AsExecutionPlan for protobuf::PhysicalPlanNode {nulls_first: expr.options.nulls_first,});Ok(protobuf::PhysicalExprNode {- expr_type: Some(protobuf::physical_expr_node::ExprType::Sort(- sort_expr,- )),+ expr_type: Some(ExprType::Sort(sort_expr)),})}).collect::<Result<Vec<_>>>()?;diff --git a/datafusion/proto/tests/cases/roundtrip_logical_plan.rs b/datafusion/proto/tests/cases/roundtrip_logical_plan.rsindex 3fec7d1c6e..14d91913e7 100644--- a/datafusion/proto/tests/cases/roundtrip_logical_plan.rs+++ b/datafusion/proto/tests/cases/roundtrip_logical_plan.rs@@ -2171,7 +2171,7 @@ fn roundtrip_aggregate_udf() {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}@@ -2395,7 +2395,7 @@ fn roundtrip_window() {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}diff --git a/datafusion/sql/src/expr/mod.rs b/datafusion/sql/src/expr/mod.rsindex 34e119c45f..432e8668c5 100644--- a/datafusion/sql/src/expr/mod.rs+++ b/datafusion/sql/src/expr/mod.rs@@ -57,7 +57,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {) -> Result<Expr> {enum StackEntry {SQLExpr(Box<SQLExpr>),- Operator(sqlparser::ast::BinaryOperator),+ Operator(BinaryOperator),}// Virtual stack machine to convert SQLExpr to Exprdiff --git a/datafusion/sql/src/statement.rs b/datafusion/sql/src/statement.rsindex 29852be3bf..abb9912b71 100644--- a/datafusion/sql/src/statement.rs+++ b/datafusion/sql/src/statement.rs@@ -99,7 +99,7 @@ fn calc_inline_constraints_from_columns(columns: &[ColumnDef]) -> Vec<TableConstast::ColumnOption::Unique {is_primary: false,characteristics,- } => constraints.push(ast::TableConstraint::Unique {+ } => constraints.push(TableConstraint::Unique {name: name.clone(),columns: vec![column.name.clone()],characteristics: *characteristics,@@ -111,7 +111,7 @@ fn calc_inline_constraints_from_columns(columns: &[ColumnDef]) -> Vec<TableConstast::ColumnOption::Unique {is_primary: true,characteristics,- } => constraints.push(ast::TableConstraint::PrimaryKey {+ } => constraints.push(TableConstraint::PrimaryKey {name: name.clone(),columns: vec![column.name.clone()],characteristics: *characteristics,@@ -125,7 +125,7 @@ fn calc_inline_constraints_from_columns(columns: &[ColumnDef]) -> Vec<TableConston_delete,on_update,characteristics,- } => constraints.push(ast::TableConstraint::ForeignKey {+ } => constraints.push(TableConstraint::ForeignKey {name: name.clone(),columns: vec![],foreign_table: foreign_table.clone(),@@ -135,7 +135,7 @@ fn calc_inline_constraints_from_columns(columns: &[ColumnDef]) -> Vec<TableConstcharacteristics: *characteristics,}),ast::ColumnOption::Check(expr) => {- constraints.push(ast::TableConstraint::Check {+ constraints.push(TableConstraint::Check {name: name.clone(),expr: Box::new(expr.clone()),})@@ -776,7 +776,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {}let isolation_level: ast::TransactionIsolationLevel = modes.iter()- .filter_map(|m: &ast::TransactionMode| match m {+ .filter_map(|m: &TransactionMode| match m {TransactionMode::AccessMode(_) => None,TransactionMode::IsolationLevel(level) => Some(level),})@@ -785,7 +785,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {.unwrap_or(ast::TransactionIsolationLevel::Serializable);let access_mode: ast::TransactionAccessMode = modes.iter()- .filter_map(|m: &ast::TransactionMode| match m {+ .filter_map(|m: &TransactionMode| match m {TransactionMode::AccessMode(mode) => Some(mode),TransactionMode::IsolationLevel(_) => None,})@@ -1650,7 +1650,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {None => {// If the target table has an alias, use it to qualify the column nameif let Some(alias) = &table_alias {- datafusion_expr::Expr::Column(Column::new(+ Expr::Column(Column::new(Some(self.ident_normalizer.normalize(alias.name.clone())),field.name(),))diff --git a/datafusion/sql/src/unparser/dialect.rs b/datafusion/sql/src/unparser/dialect.rsindex 02934a004d..88159ab6df 100644--- a/datafusion/sql/src/unparser/dialect.rs+++ b/datafusion/sql/src/unparser/dialect.rs@@ -59,8 +59,8 @@ pub trait Dialect: Send + Sync {/// Does the dialect use DOUBLE PRECISION to represent Float64 rather than DOUBLE?/// E.g. Postgres uses DOUBLE PRECISION instead of DOUBLE- fn float64_ast_dtype(&self) -> sqlparser::ast::DataType {- sqlparser::ast::DataType::Double+ fn float64_ast_dtype(&self) -> ast::DataType {+ ast::DataType::Double}/// The SQL type to use for Arrow Utf8 unparsing@@ -110,8 +110,8 @@ pub trait Dialect: Send + Sync {/// The SQL type to use for Arrow Date32 unparsing/// Most dialects use Date, but some, like SQLite require TEXT- fn date32_cast_dtype(&self) -> sqlparser::ast::DataType {- sqlparser::ast::DataType::Date+ fn date32_cast_dtype(&self) -> ast::DataType {+ ast::DataType::Date}/// Does the dialect support specifying column aliases as part of alias table definition?@@ -197,8 +197,8 @@ impl Dialect for PostgreSqlDialect {IntervalStyle::PostgresVerbose}- fn float64_ast_dtype(&self) -> sqlparser::ast::DataType {- sqlparser::ast::DataType::DoublePrecision+ fn float64_ast_dtype(&self) -> ast::DataType {+ ast::DataType::DoublePrecision}fn scalar_function_to_sql_overrides(@@ -245,7 +245,7 @@ impl PostgreSqlDialect {}Ok(ast::Expr::Function(Function {- name: ast::ObjectName(vec![Ident {+ name: ObjectName(vec![Ident {value: func_name.to_string(),quote_style: None,}]),@@ -335,8 +335,8 @@ impl Dialect for SqliteDialect {DateFieldExtractStyle::Strftime}- fn date32_cast_dtype(&self) -> sqlparser::ast::DataType {- sqlparser::ast::DataType::Text+ fn date32_cast_dtype(&self) -> ast::DataType {+ ast::DataType::Text}fn supports_column_alias_in_table_alias(&self) -> bool {@@ -362,7 +362,7 @@ pub struct CustomDialect {supports_nulls_first_in_sort: bool,use_timestamp_for_date64: bool,interval_style: IntervalStyle,- float64_ast_dtype: sqlparser::ast::DataType,+ float64_ast_dtype: ast::DataType,utf8_cast_dtype: ast::DataType,large_utf8_cast_dtype: ast::DataType,date_field_extract_style: DateFieldExtractStyle,@@ -370,7 +370,7 @@ pub struct CustomDialect {int32_cast_dtype: ast::DataType,timestamp_cast_dtype: ast::DataType,timestamp_tz_cast_dtype: ast::DataType,- date32_cast_dtype: sqlparser::ast::DataType,+ date32_cast_dtype: ast::DataType,supports_column_alias_in_table_alias: bool,requires_derived_table_alias: bool,}@@ -382,7 +382,7 @@ impl Default for CustomDialect {supports_nulls_first_in_sort: true,use_timestamp_for_date64: false,interval_style: IntervalStyle::SQLStandard,- float64_ast_dtype: sqlparser::ast::DataType::Double,+ float64_ast_dtype: ast::DataType::Double,utf8_cast_dtype: ast::DataType::Varchar(None),large_utf8_cast_dtype: ast::DataType::Text,date_field_extract_style: DateFieldExtractStyle::DatePart,@@ -393,7 +393,7 @@ impl Default for CustomDialect {None,TimezoneInfo::WithTimeZone,),- date32_cast_dtype: sqlparser::ast::DataType::Date,+ date32_cast_dtype: ast::DataType::Date,supports_column_alias_in_table_alias: true,requires_derived_table_alias: false,}@@ -428,7 +428,7 @@ impl Dialect for CustomDialect {self.interval_style}- fn float64_ast_dtype(&self) -> sqlparser::ast::DataType {+ fn float64_ast_dtype(&self) -> ast::DataType {self.float64_ast_dtype.clone()}@@ -464,7 +464,7 @@ impl Dialect for CustomDialect {}}- fn date32_cast_dtype(&self) -> sqlparser::ast::DataType {+ fn date32_cast_dtype(&self) -> ast::DataType {self.date32_cast_dtype.clone()}@@ -509,7 +509,7 @@ pub struct CustomDialectBuilder {supports_nulls_first_in_sort: bool,use_timestamp_for_date64: bool,interval_style: IntervalStyle,- float64_ast_dtype: sqlparser::ast::DataType,+ float64_ast_dtype: ast::DataType,utf8_cast_dtype: ast::DataType,large_utf8_cast_dtype: ast::DataType,date_field_extract_style: DateFieldExtractStyle,@@ -535,7 +535,7 @@ impl CustomDialectBuilder {supports_nulls_first_in_sort: true,use_timestamp_for_date64: false,interval_style: IntervalStyle::PostgresVerbose,- float64_ast_dtype: sqlparser::ast::DataType::Double,+ float64_ast_dtype: ast::DataType::Double,utf8_cast_dtype: ast::DataType::Varchar(None),large_utf8_cast_dtype: ast::DataType::Text,date_field_extract_style: DateFieldExtractStyle::DatePart,@@ -546,7 +546,7 @@ impl CustomDialectBuilder {None,TimezoneInfo::WithTimeZone,),- date32_cast_dtype: sqlparser::ast::DataType::Date,+ date32_cast_dtype: ast::DataType::Date,supports_column_alias_in_table_alias: true,requires_derived_table_alias: false,}@@ -604,10 +604,7 @@ impl CustomDialectBuilder {}/// Customize the dialect with a specific SQL type for Float64 casting: DOUBLE, DOUBLE PRECISION, etc.- pub fn with_float64_ast_dtype(- mut self,- float64_ast_dtype: sqlparser::ast::DataType,- ) -> Self {+ pub fn with_float64_ast_dtype(mut self, float64_ast_dtype: ast::DataType) -> Self {self.float64_ast_dtype = float64_ast_dtype;self}diff --git a/datafusion/sql/src/unparser/expr.rs b/datafusion/sql/src/unparser/expr.rsindex 1d0327fadb..6da0a32282 100644--- a/datafusion/sql/src/unparser/expr.rs+++ b/datafusion/sql/src/unparser/expr.rs@@ -248,7 +248,7 @@ impl Unparser<'_> {}));Ok(ast::Expr::Function(Function {- name: ast::ObjectName(vec![Ident {+ name: ObjectName(vec![Ident {value: func_name.to_string(),quote_style: None,}]),@@ -292,7 +292,7 @@ impl Unparser<'_> {None => None,};Ok(ast::Expr::Function(Function {- name: ast::ObjectName(vec![Ident {+ name: ObjectName(vec![Ident {value: func_name.to_string(),quote_style: None,}]),@@ -478,7 +478,7 @@ impl Unparser<'_> {) -> Result<ast::Expr> {let args = self.function_args_to_sql(args)?;Ok(ast::Expr::Function(Function {- name: ast::ObjectName(vec![Ident {+ name: ObjectName(vec![Ident {value: func_name.to_string(),quote_style: None,}]),@@ -519,7 +519,7 @@ impl Unparser<'_> {fn ast_type_for_date64_in_cast(&self) -> ast::DataType {if self.dialect.use_timestamp_for_date64() {- ast::DataType::Timestamp(None, ast::TimezoneInfo::None)+ ast::DataType::Timestamp(None, TimezoneInfo::None)} else {ast::DataType::Datetime(None)}@@ -594,16 +594,16 @@ impl Unparser<'_> {}/// This function can create an identifier with or without quotes based on the dialect rules- pub(super) fn new_ident_quoted_if_needs(&self, ident: String) -> ast::Ident {+ pub(super) fn new_ident_quoted_if_needs(&self, ident: String) -> Ident {let quote_style = self.dialect.identifier_quote_style(&ident);- ast::Ident {+ Ident {value: ident,quote_style,}}- pub(super) fn new_ident_without_quote_style(&self, str: String) -> ast::Ident {- ast::Ident {+ pub(super) fn new_ident_without_quote_style(&self, str: String) -> Ident {+ Ident {value: str,quote_style: None,}@@ -613,7 +613,7 @@ impl Unparser<'_> {&self,lhs: ast::Expr,rhs: ast::Expr,- op: ast::BinaryOperator,+ op: BinaryOperator,) -> ast::Expr {ast::Expr::BinaryOp {left: Box::new(lhs),@@ -698,7 +698,7 @@ impl Unparser<'_> {// Closest precedence we currently have to Between is PGLikeMatch// (https://www.postgresql.org/docs/7.2/sql-precedence.html)ast::Expr::Between { .. } => {- self.sql_op_precedence(&ast::BinaryOperator::PGLikeMatch)+ self.sql_op_precedence(&BinaryOperator::PGLikeMatch)}_ => 0,}@@ -728,70 +728,70 @@ impl Unparser<'_> {fn sql_to_op(&self, op: &BinaryOperator) -> Result<Operator> {match op {- ast::BinaryOperator::Eq => Ok(Operator::Eq),- ast::BinaryOperator::NotEq => Ok(Operator::NotEq),- ast::BinaryOperator::Lt => Ok(Operator::Lt),- ast::BinaryOperator::LtEq => Ok(Operator::LtEq),- ast::BinaryOperator::Gt => Ok(Operator::Gt),- ast::BinaryOperator::GtEq => Ok(Operator::GtEq),- ast::BinaryOperator::Plus => Ok(Operator::Plus),- ast::BinaryOperator::Minus => Ok(Operator::Minus),- ast::BinaryOperator::Multiply => Ok(Operator::Multiply),- ast::BinaryOperator::Divide => Ok(Operator::Divide),- ast::BinaryOperator::Modulo => Ok(Operator::Modulo),- ast::BinaryOperator::And => Ok(Operator::And),- ast::BinaryOperator::Or => Ok(Operator::Or),- ast::BinaryOperator::PGRegexMatch => Ok(Operator::RegexMatch),- ast::BinaryOperator::PGRegexIMatch => Ok(Operator::RegexIMatch),- ast::BinaryOperator::PGRegexNotMatch => Ok(Operator::RegexNotMatch),- ast::BinaryOperator::PGRegexNotIMatch => Ok(Operator::RegexNotIMatch),- ast::BinaryOperator::PGILikeMatch => Ok(Operator::ILikeMatch),- ast::BinaryOperator::PGNotLikeMatch => Ok(Operator::NotLikeMatch),- ast::BinaryOperator::PGLikeMatch => Ok(Operator::LikeMatch),- ast::BinaryOperator::PGNotILikeMatch => Ok(Operator::NotILikeMatch),- ast::BinaryOperator::BitwiseAnd => Ok(Operator::BitwiseAnd),- ast::BinaryOperator::BitwiseOr => Ok(Operator::BitwiseOr),- ast::BinaryOperator::BitwiseXor => Ok(Operator::BitwiseXor),- ast::BinaryOperator::PGBitwiseShiftRight => Ok(Operator::BitwiseShiftRight),- ast::BinaryOperator::PGBitwiseShiftLeft => Ok(Operator::BitwiseShiftLeft),- ast::BinaryOperator::StringConcat => Ok(Operator::StringConcat),- ast::BinaryOperator::AtArrow => Ok(Operator::AtArrow),- ast::BinaryOperator::ArrowAt => Ok(Operator::ArrowAt),+ BinaryOperator::Eq => Ok(Operator::Eq),+ BinaryOperator::NotEq => Ok(Operator::NotEq),+ BinaryOperator::Lt => Ok(Operator::Lt),+ BinaryOperator::LtEq => Ok(Operator::LtEq),+ BinaryOperator::Gt => Ok(Operator::Gt),+ BinaryOperator::GtEq => Ok(Operator::GtEq),+ BinaryOperator::Plus => Ok(Operator::Plus),+ BinaryOperator::Minus => Ok(Operator::Minus),+ BinaryOperator::Multiply => Ok(Operator::Multiply),+ BinaryOperator::Divide => Ok(Operator::Divide),+ BinaryOperator::Modulo => Ok(Operator::Modulo),+ BinaryOperator::And => Ok(Operator::And),+ BinaryOperator::Or => Ok(Operator::Or),+ BinaryOperator::PGRegexMatch => Ok(Operator::RegexMatch),+ BinaryOperator::PGRegexIMatch => Ok(Operator::RegexIMatch),+ BinaryOperator::PGRegexNotMatch => Ok(Operator::RegexNotMatch),+ BinaryOperator::PGRegexNotIMatch => Ok(Operator::RegexNotIMatch),+ BinaryOperator::PGILikeMatch => Ok(Operator::ILikeMatch),+ BinaryOperator::PGNotLikeMatch => Ok(Operator::NotLikeMatch),+ BinaryOperator::PGLikeMatch => Ok(Operator::LikeMatch),+ BinaryOperator::PGNotILikeMatch => Ok(Operator::NotILikeMatch),+ BinaryOperator::BitwiseAnd => Ok(Operator::BitwiseAnd),+ BinaryOperator::BitwiseOr => Ok(Operator::BitwiseOr),+ BinaryOperator::BitwiseXor => Ok(Operator::BitwiseXor),+ BinaryOperator::PGBitwiseShiftRight => Ok(Operator::BitwiseShiftRight),+ BinaryOperator::PGBitwiseShiftLeft => Ok(Operator::BitwiseShiftLeft),+ BinaryOperator::StringConcat => Ok(Operator::StringConcat),+ BinaryOperator::AtArrow => Ok(Operator::AtArrow),+ BinaryOperator::ArrowAt => Ok(Operator::ArrowAt),_ => not_impl_err!("unsupported operation: {op:?}"),}}- fn op_to_sql(&self, op: &Operator) -> Result<ast::BinaryOperator> {+ fn op_to_sql(&self, op: &Operator) -> Result<BinaryOperator> {match op {- Operator::Eq => Ok(ast::BinaryOperator::Eq),- Operator::NotEq => Ok(ast::BinaryOperator::NotEq),- Operator::Lt => Ok(ast::BinaryOperator::Lt),- Operator::LtEq => Ok(ast::BinaryOperator::LtEq),- Operator::Gt => Ok(ast::BinaryOperator::Gt),- Operator::GtEq => Ok(ast::BinaryOperator::GtEq),- Operator::Plus => Ok(ast::BinaryOperator::Plus),- Operator::Minus => Ok(ast::BinaryOperator::Minus),- Operator::Multiply => Ok(ast::BinaryOperator::Multiply),- Operator::Divide => Ok(ast::BinaryOperator::Divide),- Operator::Modulo => Ok(ast::BinaryOperator::Modulo),- Operator::And => Ok(ast::BinaryOperator::And),- Operator::Or => Ok(ast::BinaryOperator::Or),+ Operator::Eq => Ok(BinaryOperator::Eq),+ Operator::NotEq => Ok(BinaryOperator::NotEq),+ Operator::Lt => Ok(BinaryOperator::Lt),+ Operator::LtEq => Ok(BinaryOperator::LtEq),+ Operator::Gt => Ok(BinaryOperator::Gt),+ Operator::GtEq => Ok(BinaryOperator::GtEq),+ Operator::Plus => Ok(BinaryOperator::Plus),+ Operator::Minus => Ok(BinaryOperator::Minus),+ Operator::Multiply => Ok(BinaryOperator::Multiply),+ Operator::Divide => Ok(BinaryOperator::Divide),+ Operator::Modulo => Ok(BinaryOperator::Modulo),+ Operator::And => Ok(BinaryOperator::And),+ Operator::Or => Ok(BinaryOperator::Or),Operator::IsDistinctFrom => not_impl_err!("unsupported operation: {op:?}"),Operator::IsNotDistinctFrom => not_impl_err!("unsupported operation: {op:?}"),- Operator::RegexMatch => Ok(ast::BinaryOperator::PGRegexMatch),- Operator::RegexIMatch => Ok(ast::BinaryOperator::PGRegexIMatch),- Operator::RegexNotMatch => Ok(ast::BinaryOperator::PGRegexNotMatch),- Operator::RegexNotIMatch => Ok(ast::BinaryOperator::PGRegexNotIMatch),- Operator::ILikeMatch => Ok(ast::BinaryOperator::PGILikeMatch),- Operator::NotLikeMatch => Ok(ast::BinaryOperator::PGNotLikeMatch),- Operator::LikeMatch => Ok(ast::BinaryOperator::PGLikeMatch),- Operator::NotILikeMatch => Ok(ast::BinaryOperator::PGNotILikeMatch),- Operator::BitwiseAnd => Ok(ast::BinaryOperator::BitwiseAnd),- Operator::BitwiseOr => Ok(ast::BinaryOperator::BitwiseOr),- Operator::BitwiseXor => Ok(ast::BinaryOperator::BitwiseXor),- Operator::BitwiseShiftRight => Ok(ast::BinaryOperator::PGBitwiseShiftRight),- Operator::BitwiseShiftLeft => Ok(ast::BinaryOperator::PGBitwiseShiftLeft),- Operator::StringConcat => Ok(ast::BinaryOperator::StringConcat),+ Operator::RegexMatch => Ok(BinaryOperator::PGRegexMatch),+ Operator::RegexIMatch => Ok(BinaryOperator::PGRegexIMatch),+ Operator::RegexNotMatch => Ok(BinaryOperator::PGRegexNotMatch),+ Operator::RegexNotIMatch => Ok(BinaryOperator::PGRegexNotIMatch),+ Operator::ILikeMatch => Ok(BinaryOperator::PGILikeMatch),+ Operator::NotLikeMatch => Ok(BinaryOperator::PGNotLikeMatch),+ Operator::LikeMatch => Ok(BinaryOperator::PGLikeMatch),+ Operator::NotILikeMatch => Ok(BinaryOperator::PGNotILikeMatch),+ Operator::BitwiseAnd => Ok(BinaryOperator::BitwiseAnd),+ Operator::BitwiseOr => Ok(BinaryOperator::BitwiseOr),+ Operator::BitwiseXor => Ok(BinaryOperator::BitwiseXor),+ Operator::BitwiseShiftRight => Ok(BinaryOperator::PGBitwiseShiftRight),+ Operator::BitwiseShiftLeft => Ok(BinaryOperator::PGBitwiseShiftLeft),+ Operator::StringConcat => Ok(BinaryOperator::StringConcat),Operator::AtArrow => not_impl_err!("unsupported operation: {op:?}"),Operator::ArrowAt => not_impl_err!("unsupported operation: {op:?}"),}@@ -935,17 +935,17 @@ impl Unparser<'_> {Ok(ast::Expr::Value(ast::Value::Number(ui.to_string(), false)))}ScalarValue::UInt64(None) => Ok(ast::Expr::Value(ast::Value::Null)),- ScalarValue::Utf8(Some(str)) => Ok(ast::Expr::Value(- ast::Value::SingleQuotedString(str.to_string()),- )),+ ScalarValue::Utf8(Some(str)) => {+ Ok(ast::Expr::Value(SingleQuotedString(str.to_string())))+ }ScalarValue::Utf8(None) => Ok(ast::Expr::Value(ast::Value::Null)),- ScalarValue::Utf8View(Some(str)) => Ok(ast::Expr::Value(- ast::Value::SingleQuotedString(str.to_string()),- )),+ ScalarValue::Utf8View(Some(str)) => {+ Ok(ast::Expr::Value(SingleQuotedString(str.to_string())))+ }ScalarValue::Utf8View(None) => Ok(ast::Expr::Value(ast::Value::Null)),- ScalarValue::LargeUtf8(Some(str)) => Ok(ast::Expr::Value(- ast::Value::SingleQuotedString(str.to_string()),- )),+ ScalarValue::LargeUtf8(Some(str)) => {+ Ok(ast::Expr::Value(SingleQuotedString(str.to_string())))+ }ScalarValue::LargeUtf8(None) => Ok(ast::Expr::Value(ast::Value::Null)),ScalarValue::Binary(Some(_)) => not_impl_err!("Unsupported scalar: {v:?}"),ScalarValue::Binary(None) => Ok(ast::Expr::Value(ast::Value::Null)),@@ -978,7 +978,7 @@ impl Unparser<'_> {Ok(ast::Expr::Cast {kind: ast::CastKind::Cast,- expr: Box::new(ast::Expr::Value(ast::Value::SingleQuotedString(+ expr: Box::new(ast::Expr::Value(SingleQuotedString(date.to_string(),))),data_type: ast::DataType::Date,@@ -1001,7 +1001,7 @@ impl Unparser<'_> {Ok(ast::Expr::Cast {kind: ast::CastKind::Cast,- expr: Box::new(ast::Expr::Value(ast::Value::SingleQuotedString(+ expr: Box::new(ast::Expr::Value(SingleQuotedString(datetime.to_string(),))),data_type: self.ast_type_for_date64_in_cast(),@@ -1243,9 +1243,9 @@ impl Unparser<'_> {IntervalStyle::SQLStandard => match v {ScalarValue::IntervalYearMonth(Some(v)) => {let interval = Interval {- value: Box::new(ast::Expr::Value(- ast::Value::SingleQuotedString(v.to_string()),- )),+ value: Box::new(ast::Expr::Value(SingleQuotedString(+ v.to_string(),+ ))),leading_field: Some(ast::DateTimeField::Month),leading_precision: None,last_field: None,@@ -1264,11 +1264,9 @@ impl Unparser<'_> {let millis = v.milliseconds % 1_000;let interval = Interval {- value: Box::new(ast::Expr::Value(- ast::Value::SingleQuotedString(format!(- "{days} {hours}:{mins}:{secs}.{millis:3}"- )),- )),+ value: Box::new(ast::Expr::Value(SingleQuotedString(format!(+ "{days} {hours}:{mins}:{secs}.{millis:3}"+ )))),leading_field: Some(ast::DateTimeField::Day),leading_precision: None,last_field: Some(ast::DateTimeField::Second),@@ -1279,9 +1277,9 @@ impl Unparser<'_> {ScalarValue::IntervalMonthDayNano(Some(v)) => {if v.months >= 0 && v.days == 0 && v.nanoseconds == 0 {let interval = Interval {- value: Box::new(ast::Expr::Value(- ast::Value::SingleQuotedString(v.months.to_string()),- )),+ value: Box::new(ast::Expr::Value(SingleQuotedString(+ v.months.to_string(),+ ))),leading_field: Some(ast::DateTimeField::Month),leading_precision: None,last_field: None,@@ -1300,11 +1298,9 @@ impl Unparser<'_> {let millis = (v.nanoseconds % 1_000_000_000) / 1_000_000;let interval = Interval {- value: Box::new(ast::Expr::Value(- ast::Value::SingleQuotedString(format!(- "{days} {hours}:{mins}:{secs}.{millis:03}"- )),- )),+ value: Box::new(ast::Expr::Value(SingleQuotedString(+ format!("{days} {hours}:{mins}:{secs}.{millis:03}"),+ ))),leading_field: Some(ast::DateTimeField::Day),leading_precision: None,last_field: Some(ast::DateTimeField::Second),@@ -1962,11 +1958,8 @@ mod tests {#[test]fn custom_dialect_float64_ast_dtype() -> Result<()> {for (float64_ast_dtype, identifier) in [- (sqlparser::ast::DataType::Double, "DOUBLE"),- (- sqlparser::ast::DataType::DoublePrecision,- "DOUBLE PRECISION",- ),+ (ast::DataType::Double, "DOUBLE"),+ (ast::DataType::DoublePrecision, "DOUBLE PRECISION"),] {let dialect = CustomDialectBuilder::new().with_float64_ast_dtype(float64_ast_dtype)@@ -2383,10 +2376,7 @@ mod tests {expr: Box::new(Expr::Literal(ScalarValue::Utf8(Some("variation".to_string(),)))),- data_type: DataType::Dictionary(- Box::new(DataType::Int8),- Box::new(DataType::Utf8),- ),+ data_type: DataType::Dictionary(Box::new(Int8), Box::new(DataType::Utf8)),}),"'variation'",)];diff --git a/datafusion/sql/tests/common/mod.rs b/datafusion/sql/tests/common/mod.rsindex 47caeec78d..b0fa170318 100644--- a/datafusion/sql/tests/common/mod.rs+++ b/datafusion/sql/tests/common/mod.rs@@ -232,10 +232,7 @@ impl ContextProvider for MockContextProvider {&self.state.config_options}- fn get_file_type(- &self,- _ext: &str,- ) -> Result<Arc<dyn datafusion_common::file_options::file_type::FileType>> {+ fn get_file_type(&self, _ext: &str) -> Result<Arc<dyn FileType>> {Ok(Arc::new(MockCsvType {}))}@@ -275,7 +272,7 @@ impl EmptyTable {}impl TableSource for EmptyTable {- fn as_any(&self) -> &dyn std::any::Any {+ fn as_any(&self) -> &dyn Any {self}diff --git a/datafusion/sqllogictest/bin/sqllogictests.rs b/datafusion/sqllogictest/bin/sqllogictests.rsindex 501fd3517a..2479252a7b 100644--- a/datafusion/sqllogictest/bin/sqllogictests.rs+++ b/datafusion/sqllogictest/bin/sqllogictests.rs@@ -61,7 +61,7 @@ async fn run_tests() -> Result<()> {// Enable logging (e.g. set RUST_LOG=debug to see debug logs)env_logger::init();- let options: Options = clap::Parser::parse();+ let options: Options = Parser::parse();if options.list {// nextest parses stdout, so print messages to stderreprintln!("NOTICE: --list option unsupported, quitting");@@ -264,7 +264,7 @@ fn read_dir_recursive<P: AsRef<Path>>(path: P) -> Result<Vec<PathBuf>> {/// Append all paths recursively to dstfn read_dir_recursive_impl(dst: &mut Vec<PathBuf>, path: &Path) -> Result<()> {- let entries = std::fs::read_dir(path)+ let entries = fs::read_dir(path).map_err(|e| exec_datafusion_err!("Error reading directory {path:?}: {e}"))?;for entry in entries {let path = entrydiff --git a/datafusion/sqllogictest/src/test_context.rs b/datafusion/sqllogictest/src/test_context.rsindex deeacb1b88..477f225443 100644--- a/datafusion/sqllogictest/src/test_context.rs+++ b/datafusion/sqllogictest/src/test_context.rs@@ -139,7 +139,7 @@ impl TestContext {}#[cfg(feature = "avro")]-pub async fn register_avro_tables(ctx: &mut crate::TestContext) {+pub async fn register_avro_tables(ctx: &mut TestContext) {use datafusion::prelude::AvroReadOptions;ctx.enable_testdir();diff --git a/datafusion/substrait/src/logical_plan/consumer.rs b/datafusion/substrait/src/logical_plan/consumer.rsindex 54b93cb7e3..99e7990df6 100644--- a/datafusion/substrait/src/logical_plan/consumer.rs+++ b/datafusion/substrait/src/logical_plan/consumer.rs@@ -77,7 +77,7 @@ use substrait::proto::expression::literal::{IntervalDayToSecond, IntervalYearToMonth, UserDefined,};use substrait::proto::expression::subquery::SubqueryType;-use substrait::proto::expression::{self, FieldReference, Literal, ScalarFunction};+use substrait::proto::expression::{FieldReference, Literal, ScalarFunction};use substrait::proto::read_rel::local_files::file_or_files::PathType::UriFile;use substrait::proto::{aggregate_function::AggregationInvocation,@@ -389,7 +389,7 @@ pub async fn from_substrait_extended_expr(pub fn apply_masking(schema: DFSchema,- mask_expression: &::core::option::Option<expression::MaskExpression>,+ mask_expression: &::core::option::Option<MaskExpression>,) -> Result<DFSchema> {match mask_expression {Some(MaskExpression { select, .. }) => match &select.as_ref() {@@ -2117,11 +2117,7 @@ fn from_substrait_literal(let s = d.scale.try_into().map_err(|e| {substrait_datafusion_err!("Failed to parse decimal scale: {e}")})?;- ScalarValue::Decimal128(- Some(std::primitive::i128::from_le_bytes(value)),- p,- s,- )+ ScalarValue::Decimal128(Some(i128::from_le_bytes(value)), p, s)}Some(LiteralType::List(l)) => {// Each element should start the name index from the same value, then we increase itdiff --git a/datafusion/substrait/src/logical_plan/producer.rs b/datafusion/substrait/src/logical_plan/producer.rsindex da8a4c994f..7b51650672 100644--- a/datafusion/substrait/src/logical_plan/producer.rs+++ b/datafusion/substrait/src/logical_plan/producer.rs@@ -491,7 +491,7 @@ pub fn to_substrait_rel(.map(|ptr| *ptr).collect();Ok(Box::new(Rel {- rel_type: Some(substrait::proto::rel::RelType::Set(SetRel {+ rel_type: Some(RelType::Set(SetRel {common: None,inputs: input_rels,op: set_rel::SetOp::UnionAll as i32, // UNION DISTINCT gets translated to AGGREGATION + UNION ALLdiff --git a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rsindex 9739afa992..1f654f1d3c 100644--- a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs+++ b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs@@ -69,7 +69,7 @@ impl SerializerRegistry for MockSerializerRegistry {&self,name: &str,bytes: &[u8],- ) -> Result<Arc<dyn datafusion::logical_expr::UserDefinedLogicalNode>> {+ ) -> Result<Arc<dyn UserDefinedLogicalNode>> {if name == "MockUserDefinedLogicalPlan" {MockUserDefinedLogicalPlan::deserialize(bytes)} else {@@ -1005,7 +1005,7 @@ async fn roundtrip_aggregate_udf() -> Result<()> {}fn size(&self) -> usize {- std::mem::size_of_val(self)+ size_of_val(self)}}diff --git a/datafusion/substrait/tests/cases/serialize.rs b/datafusion/substrait/tests/cases/serialize.rsindex 72d685817d..54d55d1b6f 100644--- a/datafusion/substrait/tests/cases/serialize.rs+++ b/datafusion/substrait/tests/cases/serialize.rs@@ -20,13 +20,12 @@ mod tests {use datafusion::datasource::provider_as_source;use datafusion::logical_expr::LogicalPlanBuilder;use datafusion_substrait::logical_plan::consumer::from_substrait_plan;- use datafusion_substrait::logical_plan::producer;+ use datafusion_substrait::logical_plan::producer::to_substrait_plan;use datafusion_substrait::serializer;use datafusion::error::Result;use datafusion::prelude::*;- use datafusion_substrait::logical_plan::producer::to_substrait_plan;use std::fs;use substrait::proto::plan_rel::RelType;use substrait::proto::rel_common::{Emit, EmitKind};@@ -61,7 +60,7 @@ mod tests {let ctx = create_context().await?;let table = provider_as_source(ctx.table_provider("data").await?);let table_scan = LogicalPlanBuilder::scan("data", table, None)?.build()?;- let convert_result = producer::to_substrait_plan(&table_scan, &ctx);+ let convert_result = to_substrait_plan(&table_scan, &ctx);assert!(convert_result.is_ok());Ok(())