Apache DataFusion SQL Query Engine
Update Rust toolchain to 1.97.0 (#23430)
Daniël Heres420729155299
diff --git a/benchmarks/src/imdb/convert.rs b/benchmarks/src/imdb/convert.rsindex aaed186da4..bd6b37b2a2 100644--- a/benchmarks/src/imdb/convert.rs+++ b/benchmarks/src/imdb/convert.rs@@ -82,7 +82,7 @@ impl ConvertOpt {println!("Converting '{}' to {} files in directory '{}'",- &input_path, self.file_format, &output_path+ input_path, self.file_format, output_path);match self.file_format.as_str() {"csv" => {diff --git a/datafusion-examples/examples/external_dependency/query_aws_s3.rs b/datafusion-examples/examples/external_dependency/query_aws_s3.rsindex 63507bb3ee..7dc2f76be4 100644--- a/datafusion-examples/examples/external_dependency/query_aws_s3.rs+++ b/datafusion-examples/examples/external_dependency/query_aws_s3.rs@@ -66,7 +66,7 @@ pub async fn query_aws_s3() -> Result<()> {// dynamic query by the file pathlet ctx = ctx.enable_url_table();let df = ctx- .sql(format!(r#"SELECT * FROM '{}' LIMIT 10"#, &path).as_str())+ .sql(format!(r#"SELECT * FROM '{path}' LIMIT 10"#).as_str()).await?;// print the resultsdiff --git a/datafusion/common/src/column.rs b/datafusion/common/src/column.rsindex 0332fa3f59..f8893aa423 100644--- a/datafusion/common/src/column.rs+++ b/datafusion/common/src/column.rs@@ -271,7 +271,7 @@ impl Column {}).map_err(|err| {let mut diagnostic = Diagnostic::new_error(- format!("column '{}' is ambiguous", &self.name),+ format!("column '{}' is ambiguous", self.name),self.spans().first(),);// TODO If [`DFSchema`] had spans, we could show thediff --git a/datafusion/common/src/error.rs b/datafusion/common/src/error.rsindex ce6f8e68ae..02016387c0 100644--- a/datafusion/common/src/error.rs+++ b/datafusion/common/src/error.rs@@ -687,14 +687,11 @@ impl DataFusionError {return Some(diagnostics);}- if let Some(source) = self- .head- .source()- .and_then(|source| source.downcast_ref::<DataFusionError>()){+ let source = self.head.source().and_then(|source| {+ source.downcast_ref::<DataFusionError>()+ })?;self.head = source;- } else {- return None;}}}diff --git a/datafusion/core/src/datasource/file_format/csv.rs b/datafusion/core/src/datasource/file_format/csv.rsindex 9392d6daec..d9254bc8cf 100644--- a/datafusion/core/src/datasource/file_format/csv.rs+++ b/datafusion/core/src/datasource/file_format/csv.rs@@ -702,7 +702,7 @@ mod tests {) -> Result<usize> {let df = ctx.sql(&format!("EXPLAIN {sql}")).await?;let result = df.collect().await?;- let plan = format!("{}", &pretty_format_batches(&result)?);+ let plan = format!("{}", pretty_format_batches(&result)?);let re = Regex::new(r"DataSourceExec: file_groups=\{(\d+) group").unwrap();diff --git a/datafusion/core/src/datasource/file_format/json.rs b/datafusion/core/src/datasource/file_format/json.rsindex 5dd3817829..1de0ec2e77 100644--- a/datafusion/core/src/datasource/file_format/json.rs+++ b/datafusion/core/src/datasource/file_format/json.rs@@ -230,7 +230,7 @@ mod tests {.collect().await?;- let plan = format!("{}", &pretty::pretty_format_batches(&result)?);+ let plan = format!("{}", pretty::pretty_format_batches(&result)?);let re = Regex::new(r"file_groups=\{(\d+) group").unwrap();diff --git a/datafusion/core/src/datasource/listing/table.rs b/datafusion/core/src/datasource/listing/table.rsindex 39c20f9b78..d9cbd5bace 100644--- a/datafusion/core/src/datasource/listing/table.rs+++ b/datafusion/core/src/datasource/listing/table.rs@@ -87,7 +87,7 @@ impl ListingTableConfigExt for ListingTableConfig {let listing_file_extension =if let Some(compression_type) = maybe_compression_type {- format!("{}.{}", &file_extension, &compression_type)+ format!("{file_extension}.{compression_type}")} else {file_extension};diff --git a/datafusion/core/src/execution/context/mod.rs b/datafusion/core/src/execution/context/mod.rsindex 0ff3ab7d0e..08c7463e21 100644--- a/datafusion/core/src/execution/context/mod.rs+++ b/datafusion/core/src/execution/context/mod.rs@@ -2564,7 +2564,7 @@ mod tests {let ctx = SessionContext::new_with_state(session_state).enable_url_table();let result = plan_and_collect(&ctx,- format!("select c_name from '{}' limit 3;", &url).as_str(),+ format!("select c_name from '{url}' limit 3;").as_str(),).await?;diff --git a/datafusion/core/tests/fuzz_cases/join_fuzz.rs b/datafusion/core/tests/fuzz_cases/join_fuzz.rsindex fdb2934817..81c7c9f839 100644--- a/datafusion/core/tests/fuzz_cases/join_fuzz.rs+++ b/datafusion/core/tests/fuzz_cases/join_fuzz.rs@@ -1008,14 +1008,12 @@ impl JoinFuzzTestCase {if join_tests.contains(&HjSmj) {let err_msg_row_cnt = format!(- "HashJoinExec and SortMergeJoinExec produced different row counts, batch_size: {}",- &batch_size+ "HashJoinExec and SortMergeJoinExec produced different row counts, batch_size: {batch_size}");assert_eq!(hj_rows, smj_rows, "{}", err_msg_row_cnt.as_str());let err_msg_contents = format!(- "SortMergeJoinExec and HashJoinExec produced different results, batch_size: {}",- &batch_size+ "SortMergeJoinExec and HashJoinExec produced different results, batch_size: {batch_size}");// row level compare if any of joins returns the result// the reason is different formatting when there is no rows@@ -1070,10 +1068,10 @@ impl JoinFuzzTestCase {let mut file = std::fs::File::create(&file_path).unwrap();println!("{}: Saving batch idx {} rows {} to parquet {}",- &out_name,+ out_name,idx,batch.num_rows(),- &file_path+ file_path);let mut writer = parquet::arrow::ArrowWriter::try_new(&mut file,diff --git a/datafusion/datasource-arrow/src/file_format.rs b/datafusion/datasource-arrow/src/file_format.rsindex 9885d56e85..1daf12540c 100644--- a/datafusion/datasource-arrow/src/file_format.rs+++ b/datafusion/datasource-arrow/src/file_format.rs@@ -356,7 +356,7 @@ impl DisplayAs for ArrowFileSink {}DisplayFormatType::TreeRender => {writeln!(f, "format: arrow")?;- write!(f, "file={}", &self.config.original_url)+ write!(f, "file={}", self.config.original_url)}}}@@ -380,7 +380,7 @@ impl DataSink for ArrowFileSink {// Custom implementation of inferring schema. Should eventually be moved upstream to arrow-rs.// See <https://github.com/apache/arrow-rs/issues/5021>-const ARROW_MAGIC: [u8; 6] = [b'A', b'R', b'R', b'O', b'W', b'1'];+const ARROW_MAGIC: [u8; 6] = *b"ARROW1";const CONTINUATION_MARKER: [u8; 4] = [0xff; 4];async fn infer_stream_schema(diff --git a/datafusion/datasource-csv/src/file_format.rs b/datafusion/datasource-csv/src/file_format.rsindex 9fdd688037..6b131f2bee 100644--- a/datafusion/datasource-csv/src/file_format.rs+++ b/datafusion/datasource-csv/src/file_format.rs@@ -393,7 +393,7 @@ impl FileFormat for CsvFormat {.await.map_err(|err| {DataFusionError::Context(- format!("Error when processing CSV file {}", &object.location),+ format!("Error when processing CSV file {}", object.location),Box::new(err),)})?;@@ -759,7 +759,7 @@ impl DisplayAs for CsvSink {}DisplayFormatType::TreeRender => {writeln!(f, "format: csv")?;- write!(f, "file={}", &self.config.original_url)+ write!(f, "file={}", self.config.original_url)}}}diff --git a/datafusion/datasource-json/src/file_format.rs b/datafusion/datasource-json/src/file_format.rsindex 1854fddfb8..43bde2a039 100644--- a/datafusion/datasource-json/src/file_format.rs+++ b/datafusion/datasource-json/src/file_format.rs@@ -429,7 +429,7 @@ impl DisplayAs for JsonSink {}DisplayFormatType::TreeRender => {writeln!(f, "format: json")?;- write!(f, "file={}", &self.config.original_url)+ write!(f, "file={}", self.config.original_url)}}}diff --git a/datafusion/datasource-parquet/src/page_filter.rs b/datafusion/datasource-parquet/src/page_filter.rsindex 795a63268b..791f658bea 100644--- a/datafusion/datasource-parquet/src/page_filter.rs+++ b/datafusion/datasource-parquet/src/page_filter.rs@@ -303,7 +303,7 @@ impl PagePruningAccessPlanFilter {debug!("Use filter and page index to create RowSelection {:?} from predicate: {:?}",- &selection,+ selection,predicate.predicate_expr(),);diff --git a/datafusion/execution/src/memory_pool/pool.rs b/datafusion/execution/src/memory_pool/pool.rsindex 52b601d5cd..d854cbd627 100644--- a/datafusion/execution/src/memory_pool/pool.rs+++ b/datafusion/execution/src/memory_pool/pool.rs@@ -64,7 +64,7 @@ impl MemoryPool for UnboundedMemoryPool {impl Display for UnboundedMemoryPool {fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {let used = self.used.load(Ordering::Relaxed);- write!(f, "{}(used: {})", &self.name(), human_readable_size(used))+ write!(f, "{}(used: {})", self.name(), human_readable_size(used))}}@@ -135,7 +135,7 @@ impl Display for GreedyMemoryPool {write!(f,"{}(used: {}, pool_size: {})",- &self.name(),+ self.name(),human_readable_size(used),human_readable_size(self.pool_size))@@ -290,7 +290,7 @@ impl Display for FairSpillPool {write!(f,"{}(pool_size: {})",- &self.name(),+ self.name(),human_readable_size(self.pool_size),)}@@ -416,9 +416,9 @@ impl<I: MemoryPool> Display for TrackConsumersPool<I> {write!(f,"{}(inner_pool: {}, num_of_top_consumers: {})",- &self.name(),- &self.inner,- &self.top,+ self.name(),+ self.inner,+ self.top,)}}diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rsindex 7842b25aa8..29bf1df9d3 100644--- a/datafusion/expr-common/src/type_coercion/binary.rs+++ b/datafusion/expr-common/src/type_coercion/binary.rs@@ -654,11 +654,8 @@ pub fn type_union_resolution(data_types: &[DataType]) -> Option<DataType> {// For example,// i64 and decimal(7, 2) are expect to get coerced type decimal(22, 2)// numeric string ('1') and numeric (2) are expect to get coerced type numeric (1, 2)- if let Some(t) = type_union_resolution_coercion(data_type, candidate_t) {- candidate_type = Some(t);- } else {- return None;- }+ let t = type_union_resolution_coercion(data_type, candidate_t)?;+ candidate_type = Some(t);} else {candidate_type = Some(data_type.clone());}@@ -743,14 +740,11 @@ fn type_union_resolution_coercion() -> Option<DataType> {for rhs_field in rhs.iter() {if lhs_field.name() == rhs_field.name() {- if let Some(t) = type_union_resolution_coercion(+ let t = type_union_resolution_coercion(lhs_field.data_type(),rhs_field.data_type(),- ) {- return Some(t);- } else {- return None;- }+ )?;+ return Some(t);}}diff --git a/datafusion/expr/src/logical_plan/display.rs b/datafusion/expr/src/logical_plan/display.rsindex 27b86a6d8c..09f41c94f6 100644--- a/datafusion/expr/src/logical_plan/display.rs+++ b/datafusion/expr/src/logical_plan/display.rs@@ -634,11 +634,7 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> {let list_type_columns = list_col_indices.iter().map(|(i, unnest_info)| {- format!(- "{}|depth={:?}",- &input_columns[*i].to_string(),- unnest_info.depth- )+ format!("{}|depth={:?}", input_columns[*i], unnest_info.depth)}).collect::<Vec<String>>();let struct_type_columns = struct_col_indicesdiff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rsindex c154bc7c92..b6e6cc7683 100644--- a/datafusion/expr/src/logical_plan/plan.rs+++ b/datafusion/expr/src/logical_plan/plan.rs@@ -2222,8 +2222,7 @@ impl LogicalPlan {.map(|(i, unnest_info)| {format!("{}|depth={}",- &input_columns[*i].to_string(),- unnest_info.depth+ input_columns[*i], unnest_info.depth)}).collect::<Vec<String>>();diff --git a/datafusion/expr/src/sql.rs b/datafusion/expr/src/sql.rsindex d582a0f6b9..23e8d2f63d 100644--- a/datafusion/expr/src/sql.rs+++ b/datafusion/expr/src/sql.rs@@ -38,7 +38,7 @@ pub struct IlikeSelectItem {impl Display for IlikeSelectItem {fn fmt(&self, f: &mut Formatter) -> fmt::Result {- write!(f, "ILIKE '{}'", &self.pattern)?;+ write!(f, "ILIKE '{}'", self.pattern)?;Ok(())}}diff --git a/datafusion/expr/src/type_coercion/functions.rs b/datafusion/expr/src/type_coercion/functions.rsindex c2dc56ae10..65a45c0780 100644--- a/datafusion/expr/src/type_coercion/functions.rs+++ b/datafusion/expr/src/type_coercion/functions.rs@@ -1063,12 +1063,8 @@ fn maybe_data_types(// attempt to coerce.// TODO: Replace with `can_cast_types` after failing cases are resolved// (they need new signature that returns exactly valid types instead of list of possible valid types).- if let Some(coerced_type) = coerced_from(valid_type, current_type) {- new_type.push(coerced_type)- } else {- // not possible- return None;- }+ let coerced_type = coerced_from(valid_type, current_type)?;+ new_type.push(coerced_type)}}Some(new_type)diff --git a/datafusion/functions/src/string/split_part.rs b/datafusion/functions/src/string/split_part.rsindex 7e382868c4..9b73a1af88 100644--- a/datafusion/functions/src/string/split_part.rs+++ b/datafusion/functions/src/string/split_part.rs@@ -407,10 +407,8 @@ fn split_nth_finder<'a>(let bytes = string.as_bytes();let mut start = 0;for _ in 0..n {- match finder.find(&bytes[start..]) {- Some(pos) => start += pos + delim_len,- None => return None,- }+ let pos = finder.find(&bytes[start..])?;+ start += pos + delim_len}match finder.find(&bytes[start..]) {Some(pos) => Some(&string[start..start + pos]),@@ -430,10 +428,8 @@ fn rsplit_nth_finder<'a>(let bytes = string.as_bytes();let mut end = bytes.len();for _ in 0..n {- match finder.rfind(&bytes[..end]) {- Some(pos) => end = pos,- None => return None,- }+ let pos = finder.rfind(&bytes[..end])?;+ end = pos}match finder.rfind(&bytes[..end]) {Some(pos) => Some(&string[pos + delim_len..end]),diff --git a/datafusion/functions/src/utils.rs b/datafusion/functions/src/utils.rsindex 39683e9a6a..f42ecc789b 100644--- a/datafusion/functions/src/utils.rs+++ b/datafusion/functions/src/utils.rs@@ -217,8 +217,7 @@ where} else {let right = R::Native::try_from(scalar.clone()).map_err(|_| {DataFusionError::NotImplemented(format!(- "Cannot convert scalar value {} to {}",- &scalar, cast_target+ "Cannot convert scalar value {scalar} to {cast_target}"))})?;left.try_unary::<_, O, _>(|lvalue| fun(lvalue, right))?diff --git a/datafusion/optimizer/src/simplify_expressions/regex.rs b/datafusion/optimizer/src/simplify_expressions/regex.rsindex df4c344b2e..f04d9476c4 100644--- a/datafusion/optimizer/src/simplify_expressions/regex.rs+++ b/datafusion/optimizer/src/simplify_expressions/regex.rs@@ -398,20 +398,17 @@ fn lower_alt(let mut accu: Option<Expr> = None;for part in alts {- if let Some(expr) = lower_simple(mode, left, part, string_scalar) {- accu = match accu {- Some(accu) => {- if mode.not {- Some(accu.and(expr))- } else {- Some(accu.or(expr))- }+ let expr = lower_simple(mode, left, part, string_scalar)?;+ accu = match accu {+ Some(accu) => {+ if mode.not {+ Some(accu.and(expr))+ } else {+ Some(accu.or(expr))}- None => Some(expr),- };- } else {- return None;- }+ }+ None => Some(expr),+ };}Some(accu.expect("at least two alts"))diff --git a/datafusion/optimizer/src/simplify_expressions/simplify_literal.rs b/datafusion/optimizer/src/simplify_expressions/simplify_literal.rsindex 72e9dbc99d..2236a7e55b 100644--- a/datafusion/optimizer/src/simplify_expressions/simplify_literal.rs+++ b/datafusion/optimizer/src/simplify_expressions/simplify_literal.rs@@ -62,7 +62,7 @@ where.simplify(expr.clone()).map_err(|err| plan_datafusion_err!("Cannot simplify {expr:?}: {err}"))?;let coerced_expr: Expr = simplifier.coerce(simplified_expr, schema.as_ref())?;- log::debug!("Coerced expression: {:?}", &coerced_expr);+ log::debug!("Coerced expression: {coerced_expr:?}");match coerced_expr {Expr::Literal(scalar_value, _) => {diff --git a/datafusion/physical-expr/src/equivalence/properties/joins.rs b/datafusion/physical-expr/src/equivalence/properties/joins.rsindex 536badba43..d41293615f 100644--- a/datafusion/physical-expr/src/equivalence/properties/joins.rs+++ b/datafusion/physical-expr/src/equivalence/properties/joins.rs@@ -210,7 +210,7 @@ mod tests {&[],)?;let err_msg =- format!("expected: {:?}, actual:{:?}", expected, &join_eq.oeq_class);+ format!("expected: {:?}, actual:{:?}", expected, join_eq.oeq_class);assert_eq!(join_eq.oeq_class.len(), expected.len(), "{err_msg}");for ordering in join_eq.oeq_class {assert!(diff --git a/datafusion/physical-expr/src/partitioning.rs b/datafusion/physical-expr/src/partitioning.rsindex b662207e38..b9ec312e94 100644--- a/datafusion/physical-expr/src/partitioning.rs+++ b/datafusion/physical-expr/src/partitioning.rs@@ -19,7 +19,7 @@use crate::{EquivalenceProperties, PhysicalExpr, equivalence::ProjectionMapping,- expressions::UnKnownColumn, physical_exprs_equal,+ expressions::UnKnownColumn, physical_exprs_contains, physical_exprs_equal,};pub use datafusion_common::SplitPoint;use datafusion_common::{Result, validate_range_split_points};@@ -454,11 +454,9 @@ impl Partitioning {return false;}- subset_exprs.iter().all(|subset_expr| {- superset_exprs- .iter()- .any(|superset_expr| subset_expr.eq(superset_expr))- })+ subset_exprs+ .iter()+ .all(|subset_expr| physical_exprs_contains(superset_exprs, subset_expr))}#[deprecated(since = "52.0.0", note = "Use satisfaction instead")]@@ -1095,6 +1093,13 @@ mod tests {PartitioningSatisfaction::NotSatisfied,PartitioningSatisfaction::NotSatisfied,),+ (+ "KeyPartitioned([unknown, a]) satisfied by Hash([unknown])",+ Partitioning::Hash(vec![Arc::clone(&unknown)], 4),+ Distribution::KeyPartitioned(vec![Arc::clone(&unknown), fixture.col(0)]),+ PartitioningSatisfaction::NotSatisfied,+ PartitioningSatisfaction::NotSatisfied,+ ),];for (desc, partition, required, expected_with_subset, expected_without_subset) indiff --git a/datafusion/physical-expr/src/physical_expr.rs b/datafusion/physical-expr/src/physical_expr.rsindex 6ff5be4e38..cfc9866fc8 100644--- a/datafusion/physical-expr/src/physical_expr.rs+++ b/datafusion/physical-expr/src/physical_expr.rs@@ -60,7 +60,7 @@ pub fn physical_exprs_contains() -> bool {physical_exprs.iter()- .any(|physical_expr| physical_expr.eq(expr))+ .any(|physical_expr| physical_expr.as_ref().eq(expr.as_ref()))}/// Checks whether the given physical expression slices are equal.@@ -68,7 +68,8 @@ pub fn physical_exprs_equal(lhs: &[Arc<dyn PhysicalExpr>],rhs: &[Arc<dyn PhysicalExpr>],) -> bool {- lhs.len() == rhs.len() && izip!(lhs, rhs).all(|(lhs, rhs)| lhs.eq(rhs))+ lhs.len() == rhs.len()+ && izip!(lhs, rhs).all(|(lhs, rhs)| lhs.as_ref().eq(rhs.as_ref()))}/// Checks whether the given physical expression slices are equal in the sense@@ -328,7 +329,7 @@ pub fn add_offset_to_physical_sort_exprs(mod tests {use super::*;- use crate::expressions::{BinaryExpr, Literal};+ use crate::expressions::{BinaryExpr, Literal, UnKnownColumn};use crate::physical_expr::{physical_exprs_bag_equal, physical_exprs_contains, physical_exprs_equal,};@@ -374,6 +375,12 @@ mod tests {// below expressions are not inside physical_exprsassert!(!physical_exprs_contains(&physical_exprs, &col_c_expr));assert!(!physical_exprs_contains(&physical_exprs, &lit1));++ let unknown = Arc::new(UnKnownColumn::new("unknown")) as Arc<dyn PhysicalExpr>;+ assert!(!physical_exprs_contains(+ std::slice::from_ref(&unknown),+ &unknown+ ));}#[test]@@ -404,6 +411,12 @@ mod tests {assert!(!physical_exprs_equal(&vec1, &vec3));assert!(!physical_exprs_bag_equal(&vec1, &vec2));assert!(!physical_exprs_bag_equal(&vec1, &vec3));++ let unknown = Arc::new(UnKnownColumn::new("unknown")) as Arc<dyn PhysicalExpr>;+ assert!(!physical_exprs_equal(+ std::slice::from_ref(&unknown),+ std::slice::from_ref(&unknown)+ ));}#[test]diff --git a/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs b/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rsindex 7f3a63ed91..0d52dc5614 100644--- a/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs+++ b/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs@@ -630,12 +630,9 @@ fn expected_expr_positions(let mut current = current.to_vec();for expr in expected.iter() {// Find the position of the expected expr in the current expressions- if let Some(expected_position) = current.iter().position(|e| e.eq(expr)) {- current[expected_position] = Arc::new(NoOp::new());- indexes.push(expected_position);- } else {- return None;- }+ let expected_position = current.iter().position(|e| e.eq(expr))?;+ current[expected_position] = Arc::new(NoOp::new());+ indexes.push(expected_position);}Some(indexes)}diff --git a/datafusion/physical-optimizer/src/limited_distinct_aggregation.rs b/datafusion/physical-optimizer/src/limited_distinct_aggregation.rsindex 852dc2a2a9..192a139f36 100644--- a/datafusion/physical-optimizer/src/limited_distinct_aggregation.rs+++ b/datafusion/physical-optimizer/src/limited_distinct_aggregation.rs@@ -72,7 +72,8 @@ impl LimitedDistinctAggregation {if let Some(local_limit) = plan.downcast_ref::<LocalLimitExec>() {limit = local_limit.fetch();children = local_limit.children().into_iter().cloned().collect();- } else if let Some(global_limit) = plan.downcast_ref::<GlobalLimitExec>() {+ } else {+ let global_limit = plan.downcast_ref::<GlobalLimitExec>()?;global_fetch = global_limit.fetch();global_fetch?;global_skip = global_limit.skip();@@ -80,8 +81,6 @@ impl LimitedDistinctAggregation {limit = global_fetch.unwrap() + global_skip;children = global_limit.children().into_iter().cloned().collect();is_global_limit = true- } else {- return None;}let child = children.iter().exactly_one().ok()?;// ensure there is no output ordering; can this rule be relaxed?diff --git a/datafusion/physical-plan/src/aggregates/topk/heap.rs b/datafusion/physical-plan/src/aggregates/topk/heap.rsindex 889fe04bf8..ca321cdf99 100644--- a/datafusion/physical-plan/src/aggregates/topk/heap.rs+++ b/datafusion/physical-plan/src/aggregates/topk/heap.rs@@ -334,10 +334,7 @@ impl<VAL: ValueType> TopKHeap<VAL> {pub fn worst_val(&self) -> Option<&VAL> {let root = self.heap.first()?;- let hi = match root {- None => return None,- Some(hi) => hi,- };+ let hi = root.as_ref()?;Some(&hi.val)}diff --git a/datafusion/physical-plan/src/display.rs b/datafusion/physical-plan/src/display.rsindex 56b209d921..2c1d30eaab 100644--- a/datafusion/physical-plan/src/display.rs+++ b/datafusion/physical-plan/src/display.rs@@ -1011,7 +1011,7 @@ impl TreeRenderVisitor<'_, '_> {continue;}// there are nodes next to this, fill the space- write!(self.f, "{}", &" ".repeat(Self::NODE_RENDER_WIDTH))?;+ write!(self.f, "{}", " ".repeat(Self::NODE_RENDER_WIDTH))?;}}writeln!(self.f)?;@@ -1201,13 +1201,13 @@ impl TreeRenderVisitor<'_, '_> {)?;write!(self.f, "{}", Self::RDCORNER)?;} else if root.has_node(x, y + 1) {- write!(self.f, "{}", &" ".repeat(Self::NODE_RENDER_WIDTH / 2))?;+ write!(self.f, "{}", " ".repeat(Self::NODE_RENDER_WIDTH / 2))?;write!(self.f, "{}", Self::VERTICAL)?;if has_adjacent_nodes || Self::should_render_whitespace(root, x, y) {- write!(self.f, "{}", &" ".repeat(Self::NODE_RENDER_WIDTH / 2))?;+ write!(self.f, "{}", " ".repeat(Self::NODE_RENDER_WIDTH / 2))?;}} else if has_adjacent_nodes || Self::should_render_whitespace(root, x, y) {- write!(self.f, "{}", &" ".repeat(Self::NODE_RENDER_WIDTH))?;+ write!(self.f, "{}", " ".repeat(Self::NODE_RENDER_WIDTH))?;}}writeln!(self.f)?;diff --git a/datafusion/proto-common/gen/src/main.rs b/datafusion/proto-common/gen/src/main.rsindex 02e1ecf00b..d672832d43 100644--- a/datafusion/proto-common/gen/src/main.rs+++ b/datafusion/proto-common/gen/src/main.rs@@ -33,14 +33,12 @@ fn main() -> Result<(), String> {.map_err(|e| format!("protobuf compilation failed: {e}"))?;let descriptor_set = std::fs::read(&descriptor_path)- .unwrap_or_else(|e| panic!("Cannot read {:?}: {}", &descriptor_path, e));+ .unwrap_or_else(|e| panic!("Cannot read {descriptor_path:?}: {e}"));pbjson_build::Builder::new().out_dir("src").register_descriptors(&descriptor_set)- .unwrap_or_else(|e| {- panic!("Cannot register descriptors {:?}: {}", &descriptor_set, e)- })+ .unwrap_or_else(|e| panic!("Cannot register descriptors {descriptor_set:?}: {e}")).build(&[".datafusion_common"]).map_err(|e| format!("pbjson compilation failed: {e}"))?;diff --git a/datafusion/proto-models/gen/src/main.rs b/datafusion/proto-models/gen/src/main.rsindex 4da674c43c..b9cbf81bb1 100644--- a/datafusion/proto-models/gen/src/main.rs+++ b/datafusion/proto-models/gen/src/main.rs@@ -35,14 +35,12 @@ fn main() -> Result<(), String> {.map_err(|e| format!("protobuf compilation failed: {e}"))?;let descriptor_set = std::fs::read(&descriptor_path)- .unwrap_or_else(|e| panic!("Cannot read {:?}: {}", &descriptor_path, e));+ .unwrap_or_else(|e| panic!("Cannot read {descriptor_path:?}: {e}"));pbjson_build::Builder::new().out_dir(out_dir).register_descriptors(&descriptor_set)- .unwrap_or_else(|e| {- panic!("Cannot register descriptors {:?}: {}", &descriptor_set, e)- })+ .unwrap_or_else(|e| panic!("Cannot register descriptors {descriptor_set:?}: {e}")).build(&[".datafusion"]).map_err(|e| format!("pbjson compilation failed: {e}"))?;diff --git a/datafusion/proto/tests/cases/roundtrip_logical_plan.rs b/datafusion/proto/tests/cases/roundtrip_logical_plan.rsindex 82ad94d8f7..431b49dc8b 100644--- a/datafusion/proto/tests/cases/roundtrip_logical_plan.rs+++ b/datafusion/proto/tests/cases/roundtrip_logical_plan.rs@@ -147,7 +147,7 @@ fn roundtrip_expr_test_with_codec(let round_trip: Expr =from_proto::parse_expr(&proto, ctx.task_ctx().as_ref(), codec).unwrap();- assert_eq!(format!("{:?}", &initial_struct), format!("{round_trip:?}"));+ assert_eq!(format!("{:?}", initial_struct), format!("{round_trip:?}"));roundtrip_json_test(&proto);}@@ -2354,7 +2354,7 @@ fn roundtrip_null_scalar_values() {for test_case in test_types.into_iter() {let proto_scalar: protobuf::ScalarValue = (&test_case).try_into().unwrap();let returned_scalar: ScalarValue = (&proto_scalar).try_into().unwrap();- assert_eq!(format!("{:?}", &test_case), format!("{returned_scalar:?}"));+ assert_eq!(format!("{:?}", test_case), format!("{returned_scalar:?}"));}}@@ -2849,7 +2849,7 @@ fn roundtrip_scalar_udf_extension_codec() {from_proto::parse_expr(&proto, ctx.task_ctx().as_ref(), &UDFExtensionCodec).expect("parse expr");- assert_eq!(format!("{:?}", &test_expr), format!("{round_trip:?}"));+ assert_eq!(format!("{:?}", test_expr), format!("{round_trip:?}"));roundtrip_json_test(&proto);}@@ -2863,7 +2863,7 @@ fn roundtrip_aggregate_udf_extension_codec() {from_proto::parse_expr(&proto, ctx.task_ctx().as_ref(), &UDFExtensionCodec).expect("parse expr");- assert_eq!(format!("{:?}", &test_expr), format!("{round_trip:?}"));+ assert_eq!(format!("{:?}", test_expr), format!("{round_trip:?}"));roundtrip_json_test(&proto);}diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rsindex a17cb224d1..3a696811be 100644--- a/datafusion/sql/src/planner.rs+++ b/datafusion/sql/src/planner.rs@@ -641,13 +641,13 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {Diagnostic::new_error(format!("column '{}' not found in '{}'",- &col.name, relation+ col.name, relation),col.spans().first(),)} else {Diagnostic::new_error(- format!("column '{}' not found", &col.name),+ format!("column '{}' not found", col.name),col.spans().first(),)};diff --git a/datafusion/sql/src/statement.rs b/datafusion/sql/src/statement.rsindex 401313f9d3..838228a3e0 100644--- a/datafusion/sql/src/statement.rs+++ b/datafusion/sql/src/statement.rs@@ -278,7 +278,6 @@ impl<S: ContextProvider> SqlToRel<'_, S> {statement,analyze,format,- describe_alias: _,..} => {let format = formatdiff --git a/datafusion/sql/src/unparser/expr.rs b/datafusion/sql/src/unparser/expr.rsindex 33457a1515..c659d8694e 100644--- a/datafusion/sql/src/unparser/expr.rs+++ b/datafusion/sql/src/unparser/expr.rs@@ -264,7 +264,7 @@ impl Unparser<'_> {}Expr::Cast(Cast { expr, field }) => Ok(self.cast_to_sql(expr, field)?),Expr::Literal(value, _) => Ok(self.scalar_to_sql(value)?),- Expr::Alias(Alias { expr, name: _, .. }) => self.expr_to_sql_inner(expr),+ Expr::Alias(Alias { expr, .. }) => self.expr_to_sql_inner(expr),Expr::WindowFunction(window_fun) => {let WindowFunction {fun,diff --git a/datafusion/sqllogictest/bin/sqllogictests.rs b/datafusion/sqllogictest/bin/sqllogictests.rsindex e43f03fcf4..cd51dc47ef 100644--- a/datafusion/sqllogictest/bin/sqllogictests.rs+++ b/datafusion/sqllogictest/bin/sqllogictests.rs@@ -453,7 +453,7 @@ async fn run_test_file_substrait_round_trip(let pb = mp.add(ProgressBar::new(count));pb.set_style(mp_style);- pb.set_message(format!("{:?}", &relative_path));+ pb.set_message(format!("{relative_path:?}"));let mut runner = sqllogictest::Runner::new(|| async {Ok(DataFusionSubstraitRoundTrip::new(@@ -508,7 +508,7 @@ async fn run_test_file(let pb = mp.add(ProgressBar::new(count));pb.set_style(mp_style);- pb.set_message(format!("{:?}", &relative_path));+ pb.set_message(format!("{relative_path:?}"));// If DataFusion configuration has changed during test file runs, errors will be// pushed to this vec.@@ -627,7 +627,7 @@ async fn run_test_file_with_postgres(let pb = mp.add(ProgressBar::new(count));pb.set_style(mp_style);- pb.set_message(format!("{:?}", &relative_path));+ pb.set_message(format!("{relative_path:?}"));let mut runner = sqllogictest::Runner::new(|| {Postgres::connect_with_tracked_sql(@@ -682,7 +682,7 @@ async fn run_complete_file(let pb = mp.add(ProgressBar::new(count));pb.set_style(mp_style);- pb.set_message(format!("{:?}", &relative_path));+ pb.set_message(format!("{relative_path:?}"));let config_change_errors = Arc::new(Mutex::new(Vec::new()));let mut runner = sqllogictest::Runner::new(|| async {@@ -738,7 +738,7 @@ async fn run_complete_file_with_postgres(let pb = mp.add(ProgressBar::new(count));pb.set_style(mp_style);- pb.set_message(format!("{:?}", &relative_path));+ pb.set_message(format!("{relative_path:?}"));let mut runner = sqllogictest::Runner::new(|| {Postgres::connect_with_tracked_sql(diff --git a/datafusion/substrait/src/physical_plan/producer.rs b/datafusion/substrait/src/physical_plan/producer.rsindex 17ca99ceff..21282b9e8b 100644--- a/datafusion/substrait/src/physical_plan/producer.rs+++ b/datafusion/substrait/src/physical_plan/producer.rs@@ -74,13 +74,9 @@ pub fn to_substrait_rel(let mut types = vec![];for field in file_config.file_schema().fields.iter() {- match to_substrait_type(field.data_type(), field.is_nullable()) {- Ok(t) => {- names.push(field.name().clone());- types.push(t);- }- Err(e) => return Err(e),- }+ let t = to_substrait_type(field.data_type(), field.is_nullable())?;+ names.push(field.name().clone());+ types.push(t);}let type_info = Struct {diff --git a/docs/source/contributor-guide/development_environment.md b/docs/source/contributor-guide/development_environment.mdindex 8570dbdbb9..2e4e007265 100644--- a/docs/source/contributor-guide/development_environment.md+++ b/docs/source/contributor-guide/development_environment.md@@ -108,7 +108,7 @@ DataFusion is written in Rust and it uses a standard rust toolkit:- `rustup update stable` DataFusion generally uses the latest stable release of Rust, though it may lag when new Rust toolchains release- See which toolchain is currently pinned in the [`rust-toolchain.toml`](https://github.com/apache/datafusion/blob/main/rust-toolchain.toml) file- - This can cause issues such as not having the rust-analyzer component installed for the specified toolchain, in which case just install it manually, e.g. `rustup component add --toolchain 1.96.1 rust-analyzer`+ - This can cause issues such as not having the rust-analyzer component installed for the specified toolchain, in which case just install it manually, e.g. `rustup component add --toolchain 1.97.0 rust-analyzer`- `cargo build`- `cargo fmt` to format the code- etc.diff --git a/rust-toolchain.toml b/rust-toolchain.tomlindex 041925c753..5639a821f5 100644--- a/rust-toolchain.toml+++ b/rust-toolchain.toml@@ -19,5 +19,5 @@# to compile this workspace and run CI jobs.[toolchain]-channel = "1.96.1"+channel = "1.97.0"components = ["rustfmt", "clippy"]