From caf9dd1a1f7f7b38f5889af6daf8851f8ff65a17 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 21 Aug 2026 16:42:01 +0200 Subject: [PATCH 1/9] Enable clippy lint `no_effect_underscore_binding` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove a dead `let _expected = …` binding left over from a removed assertion. Co-Authored-By: Claude Fable 5 --- Cargo.toml | 1 - datafusion/core/src/physical_planner.rs | 3 --- 2 files changed, 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f9b2cac5c5538..39f5caa30dd13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -309,7 +309,6 @@ must_use_candidate = "allow" # 2726 hits needless_bitwise_bool = "allow" # 1 hit needless_continue = "allow" # 37 hits needless_raw_string_hashes = "allow" # 540 hits -no_effect_underscore_binding = "allow" # 1 hit ptr_as_ptr = "allow" # 83 hits redundant_closure_for_method_calls = "allow" # 686 hits redundant_else = "allow" # 48 hits diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs index 2792c9c7a6faa..6648658bdee50 100644 --- a/datafusion/core/src/physical_planner.rs +++ b/datafusion/core/src/physical_planner.rs @@ -4269,9 +4269,6 @@ mod tests { let plan = plan(&logical_plan).await?; - // c12 is f64, c7 is u8 -> cast c7 to f64 - // the cast here is implicit so has CastOptions with safe=true - let _expected = "predicate: BinaryExpr { left: TryCastExpr { expr: Column { name: \"c7\", index: 6 }, cast_type: Float64 }, op: Lt, right: Column { name: \"c12\", index: 11 } }"; let plan_debug_str = format!("{plan:?}"); assert!(plan_debug_str.contains("GlobalLimitExec")); assert!(plan_debug_str.contains("skip: 3")); From 5a1e6393734880c096cbe74cb74ce582b2b7157c Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 21 Aug 2026 16:48:23 +0200 Subject: [PATCH 2/9] Enable clippy lint `case_sensitive_file_extension_comparisons` Compare the file extension with `Path::extension()` instead of `str::ends_with(".csv")`. Co-Authored-By: Claude Fable 5 --- Cargo.toml | 125 +++++++++--------- .../core/src/datasource/file_format/csv.rs | 16 +-- 2 files changed, 66 insertions(+), 75 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 39f5caa30dd13..1029d48692760 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -269,69 +269,68 @@ wildcard_dependencies = "warn" # Pedantic lints we opt out of, with the number of hits at the time we enabled `pedantic`. # Some of these we should consider enabling. -borrow_as_ptr = "allow" # 6 hits -case_sensitive_file_extension_comparisons = "allow" # 1 hit -cast_lossless = "allow" # 361 hits -cast_possible_truncation = "allow" # 911 hits -cast_possible_wrap = "allow" # 493 hits -cast_precision_loss = "allow" # 266 hits -cast_ptr_alignment = "allow" # 5 hits -cast_sign_loss = "allow" # 440 hits -cloned_instead_of_copied = "allow" # 38 hits -default_trait_access = "allow" # 221 hits -doc_comment_double_space_linebreaks = "allow" # 6 hits -doc_link_with_quotes = "allow" # 25 hits -doc_markdown = "allow" # 4933 hits; needs a long `doc-valid-idents` list in `clippy.toml` -enum_glob_use = "allow" # 98 hits -explicit_into_iter_loop = "allow" # 55 hits -explicit_iter_loop = "allow" # 189 hits -float_cmp = "allow" # 8 hits; exact float comparisons are often intentional here -format_collect = "allow" # 4 hits -format_push_string = "allow" # 34 hits -from_iter_instead_of_collect = "allow" # 51 hits -if_not_else = "allow" # 133 hits -ignored_unit_patterns = "allow" # 52 hits -implicit_clone = "allow" # 198 hits -implicit_hasher = "allow" # 17 hits -inline_always = "allow" # 45 hits -items_after_statements = "allow" # 171 hits -large_digit_groups = "allow" # 3 hits -manual_string_new = "allow" # 84 hits -many_single_char_names = "allow" # 12 hits; short names are idiomatic in the numeric kernels -map_unwrap_or = "allow" # 198 hits -match_bool = "allow" # 46 hits -match_same_arms = "allow" # 261 hits -match_wildcard_for_single_variants = "allow" # 132 hits -missing_errors_doc = "allow" # 1807 hits -missing_fields_in_debug = "allow" # 29 hits -missing_panics_doc = "allow" # 244 hits -must_use_candidate = "allow" # 2726 hits -needless_bitwise_bool = "allow" # 1 hit -needless_continue = "allow" # 37 hits -needless_raw_string_hashes = "allow" # 540 hits -ptr_as_ptr = "allow" # 83 hits -redundant_closure_for_method_calls = "allow" # 686 hits -redundant_else = "allow" # 48 hits -ref_option = "allow" # 36 hits -return_self_not_must_use = "allow" # 644 hits -semicolon_if_nothing_returned = "allow" # 1353 hits -similar_names = "allow" # 228 hits; too many false positives, e.g. `expr`/`exprs` -single_char_pattern = "allow" # 23 hits -single_match_else = "allow" # 155 hits -struct_excessive_bools = "allow" # 24 hits -struct_field_names = "allow" # 14 hits -too_many_lines = "allow" # 484 hits -trivially_copy_pass_by_ref = "allow" # 74 hits -unicode_not_nfc = "allow" # 2 hits -unnecessary_literal_bound = "allow" # 471 hits -unnecessary_semicolon = "allow" # 185 hits -unnecessary_trailing_comma = "allow" # 49 hits -unnecessary_wraps = "allow" # 427 hits -unnested_or_patterns = "allow" # 68 hits -unreadable_literal = "allow" # 502 hits -unused_self = "allow" # 69 hits -used_underscore_items = "allow" # 28 hits -wildcard_imports = "allow" # 48 hits; `use crate::prelude::*` is idiomatic +borrow_as_ptr = "allow" # 6 hits +cast_lossless = "allow" # 361 hits +cast_possible_truncation = "allow" # 911 hits +cast_possible_wrap = "allow" # 493 hits +cast_precision_loss = "allow" # 266 hits +cast_ptr_alignment = "allow" # 5 hits +cast_sign_loss = "allow" # 440 hits +cloned_instead_of_copied = "allow" # 38 hits +default_trait_access = "allow" # 221 hits +doc_comment_double_space_linebreaks = "allow" # 6 hits +doc_link_with_quotes = "allow" # 25 hits +doc_markdown = "allow" # 4933 hits; needs a long `doc-valid-idents` list in `clippy.toml` +enum_glob_use = "allow" # 98 hits +explicit_into_iter_loop = "allow" # 55 hits +explicit_iter_loop = "allow" # 189 hits +float_cmp = "allow" # 8 hits; exact float comparisons are often intentional here +format_collect = "allow" # 4 hits +format_push_string = "allow" # 34 hits +from_iter_instead_of_collect = "allow" # 51 hits +if_not_else = "allow" # 133 hits +ignored_unit_patterns = "allow" # 52 hits +implicit_clone = "allow" # 198 hits +implicit_hasher = "allow" # 17 hits +inline_always = "allow" # 45 hits +items_after_statements = "allow" # 171 hits +large_digit_groups = "allow" # 3 hits +manual_string_new = "allow" # 84 hits +many_single_char_names = "allow" # 12 hits; short names are idiomatic in the numeric kernels +map_unwrap_or = "allow" # 198 hits +match_bool = "allow" # 46 hits +match_same_arms = "allow" # 261 hits +match_wildcard_for_single_variants = "allow" # 132 hits +missing_errors_doc = "allow" # 1807 hits +missing_fields_in_debug = "allow" # 29 hits +missing_panics_doc = "allow" # 244 hits +must_use_candidate = "allow" # 2726 hits +needless_bitwise_bool = "allow" # 1 hit +needless_continue = "allow" # 37 hits +needless_raw_string_hashes = "allow" # 540 hits +ptr_as_ptr = "allow" # 83 hits +redundant_closure_for_method_calls = "allow" # 686 hits +redundant_else = "allow" # 48 hits +ref_option = "allow" # 36 hits +return_self_not_must_use = "allow" # 644 hits +semicolon_if_nothing_returned = "allow" # 1353 hits +similar_names = "allow" # 228 hits; too many false positives, e.g. `expr`/`exprs` +single_char_pattern = "allow" # 23 hits +single_match_else = "allow" # 155 hits +struct_excessive_bools = "allow" # 24 hits +struct_field_names = "allow" # 14 hits +too_many_lines = "allow" # 484 hits +trivially_copy_pass_by_ref = "allow" # 74 hits +unicode_not_nfc = "allow" # 2 hits +unnecessary_literal_bound = "allow" # 471 hits +unnecessary_semicolon = "allow" # 185 hits +unnecessary_trailing_comma = "allow" # 49 hits +unnecessary_wraps = "allow" # 427 hits +unnested_or_patterns = "allow" # 68 hits +unreadable_literal = "allow" # 502 hits +unused_self = "allow" # 69 hits +used_underscore_items = "allow" # 28 hits +wildcard_imports = "allow" # 48 hits; `use crate::prelude::*` is idiomatic [workspace.lints.rust] unexpected_cfgs = { level = "warn", check-cfg = [ diff --git a/datafusion/core/src/datasource/file_format/csv.rs b/datafusion/core/src/datasource/file_format/csv.rs index 447d5244f9e94..2fb64fd6486e6 100644 --- a/datafusion/core/src/datasource/file_format/csv.rs +++ b/datafusion/core/src/datasource/file_format/csv.rs @@ -987,18 +987,10 @@ mod tests { let files: Vec<_> = std::fs::read_dir(&path).unwrap().collect(); assert_eq!(files.len(), 1); - assert!( - files - .last() - .unwrap() - .as_ref() - .unwrap() - .path() - .file_name() - .unwrap() - .to_str() - .unwrap() - .ends_with(".csv") + let file_path = files.last().unwrap().as_ref().unwrap().path(); + assert_eq!( + file_path.extension().and_then(|ext| ext.to_str()), + Some("csv") ); Ok(()) From 132e4c9175dc0b476a266d7464fbb6b922f2d7cd Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 21 Aug 2026 16:56:34 +0200 Subject: [PATCH 3/9] Enable clippy lint `cast_ptr_alignment` All five hits are FFI local-bypass tests that downcast a trait object to its concrete type with a pointer cast. The casts are aligned, so mark them with targeted `#[expect]` attributes. Co-Authored-By: Claude Fable 5 --- Cargo.toml | 1 - datafusion/ffi/src/udaf/accumulator.rs | 2 ++ datafusion/ffi/src/udaf/groups_accumulator.rs | 2 ++ datafusion/ffi/src/udwf/partition_evaluator.rs | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1029d48692760..56e0886ffdf40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -274,7 +274,6 @@ cast_lossless = "allow" # 361 hits cast_possible_truncation = "allow" # 911 hits cast_possible_wrap = "allow" # 493 hits cast_precision_loss = "allow" # 266 hits -cast_ptr_alignment = "allow" # 5 hits cast_sign_loss = "allow" # 440 hits cloned_instead_of_copied = "allow" # 38 hits default_trait_access = "allow" # 221 hits diff --git a/datafusion/ffi/src/udaf/accumulator.rs b/datafusion/ffi/src/udaf/accumulator.rs index 4d696cadb70e3..8e6e5983bba2f 100644 --- a/datafusion/ffi/src/udaf/accumulator.rs +++ b/datafusion/ffi/src/udaf/accumulator.rs @@ -406,6 +406,8 @@ mod tests { } #[test] + // The pointer casts are aligned because the pointees are the concrete types. + #[expect(clippy::cast_ptr_alignment)] fn test_ffi_accumulator_local_bypass() -> Result<()> { let original_accum = AvgAccumulator::default(); let boxed_accum: Box = Box::new(original_accum); diff --git a/datafusion/ffi/src/udaf/groups_accumulator.rs b/datafusion/ffi/src/udaf/groups_accumulator.rs index ad2714da0cc60..fb76d443a0c6b 100644 --- a/datafusion/ffi/src/udaf/groups_accumulator.rs +++ b/datafusion/ffi/src/udaf/groups_accumulator.rs @@ -529,6 +529,8 @@ mod tests { } #[test] + // The pointer casts are aligned because the pointees are the concrete types. + #[expect(clippy::cast_ptr_alignment)] fn test_ffi_groups_accumulator_local_bypass_inner() -> Result<()> { let original_accum = StddevGroupsAccumulator::new(StatsType::Population); let boxed_accum: Box = Box::new(original_accum); diff --git a/datafusion/ffi/src/udwf/partition_evaluator.rs b/datafusion/ffi/src/udwf/partition_evaluator.rs index 2e6243ddd1650..1074c1a019a73 100644 --- a/datafusion/ffi/src/udwf/partition_evaluator.rs +++ b/datafusion/ffi/src/udwf/partition_evaluator.rs @@ -384,6 +384,8 @@ mod tests { } #[test] + // The pointer casts are aligned because the pointees are the concrete types. + #[expect(clippy::cast_ptr_alignment)] fn test_ffi_partition_evaluator_local_bypass_inner() -> datafusion_common::Result<()> { let original_accum = TestPartitionEvaluator {}; From 42ef731729dca3b69c2724ea31f1b92be233106e Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 21 Aug 2026 17:04:49 +0200 Subject: [PATCH 4/9] Enable clippy lint `doc_link_with_quotes` Turn quoted doc links into real intra-doc links where a target exists, and wrap array examples and SQL snippets in backticks or text code fences. Co-Authored-By: Claude Fable 5 --- Cargo.toml | 1 - datafusion/common/src/scalar/mod.rs | 4 ++++ datafusion/core/src/datasource/file_format/options.rs | 2 +- datafusion/expr/src/expr_rewriter/mod.rs | 2 +- datafusion/ffi/src/expr/distribution.rs | 2 +- datafusion/functions-aggregate/src/count.rs | 2 +- datafusion/optimizer/src/extract_leaf_expressions.rs | 4 ++-- datafusion/physical-expr/src/expressions/in_list.rs | 2 +- .../src/ensure_requirements/enforce_distribution.rs | 2 +- datafusion/physical-plan/src/joins/nested_loop_join.rs | 6 +++--- datafusion/physical-plan/src/visitor.rs | 2 +- datafusion/pruning/src/pruning_predicate.rs | 2 ++ 12 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 56e0886ffdf40..540f8459e571d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -278,7 +278,6 @@ cast_sign_loss = "allow" # 440 hits cloned_instead_of_copied = "allow" # 38 hits default_trait_access = "allow" # 221 hits doc_comment_double_space_linebreaks = "allow" # 6 hits -doc_link_with_quotes = "allow" # 25 hits doc_markdown = "allow" # 4933 hits; needs a long `doc-valid-idents` list in `clippy.toml` enum_glob_use = "allow" # 98 hits explicit_into_iter_loop = "allow" # 55 hits diff --git a/datafusion/common/src/scalar/mod.rs b/datafusion/common/src/scalar/mod.rs index fb08ef284280e..fde5c605d5694 100644 --- a/datafusion/common/src/scalar/mod.rs +++ b/datafusion/common/src/scalar/mod.rs @@ -1115,14 +1115,18 @@ fn dict_from_scalar( /// Useful for wrapping arrays in dictionary form. /// /// # Input +/// ```text /// ["alice", "bob", "alice", null, "carol"] +/// ``` /// /// # Output /// `DictionaryArray` +/// ```text /// { /// keys: [0, 1, 2, 3, 4], /// values: ["alice", "bob", "alice", null, "carol"] /// } +/// ``` pub fn dict_from_values( values_array: ArrayRef, ) -> Result { diff --git a/datafusion/core/src/datasource/file_format/options.rs b/datafusion/core/src/datasource/file_format/options.rs index f2903405c8204..d672641389562 100644 --- a/datafusion/core/src/datasource/file_format/options.rs +++ b/datafusion/core/src/datasource/file_format/options.rs @@ -581,7 +581,7 @@ impl<'a> JsonReadOptions<'a> { } #[async_trait] -/// ['ReadOptions'] is implemented by Options like ['CsvReadOptions'] that control the reading of respective files/sources. +/// [`ReadOptions`] is implemented by Options like [`CsvReadOptions`] that control the reading of respective files/sources. pub trait ReadOptions<'a> { /// Helper to convert these user facing options to `ListingTable` options fn to_listing_options( diff --git a/datafusion/expr/src/expr_rewriter/mod.rs b/datafusion/expr/src/expr_rewriter/mod.rs index 7a6ac3fc8b062..4e9839e2f7479 100644 --- a/datafusion/expr/src/expr_rewriter/mod.rs +++ b/datafusion/expr/src/expr_rewriter/mod.rs @@ -203,7 +203,7 @@ pub fn unnormalize_cols(exprs: impl IntoIterator) -> Vec { exprs.into_iter().map(unnormalize_col).collect() } -/// Recursively remove all the ['OuterReferenceColumn'] and return the inside Column +/// Recursively remove all the [`Expr::OuterReferenceColumn`] and return the inside Column /// in the expression tree. pub fn strip_outer_reference(expr: Expr) -> Expr { expr.transform(|expr| { diff --git a/datafusion/ffi/src/expr/distribution.rs b/datafusion/ffi/src/expr/distribution.rs index 91b6c4ce754b4..feacbdc6b02b3 100644 --- a/datafusion/ffi/src/expr/distribution.rs +++ b/datafusion/ffi/src/expr/distribution.rs @@ -32,7 +32,7 @@ use crate::arrow_wrappers::WrappedArray; use crate::expr::interval::FFI_Interval; /// A stable struct for sharing [`Distribution`] across FFI boundaries. -/// See ['Distribution'] for the meaning of each variant. +/// See [`Distribution`] for the meaning of each variant. #[repr(C)] #[derive(Debug)] #[expect(clippy::large_enum_variant)] diff --git a/datafusion/functions-aggregate/src/count.rs b/datafusion/functions-aggregate/src/count.rs index 87d3adeca27ab..a3ebe0699e174 100644 --- a/datafusion/functions-aggregate/src/count.rs +++ b/datafusion/functions-aggregate/src/count.rs @@ -922,7 +922,7 @@ mod tests { /// Helper function to create a dictionary array with non-null keys but some null values /// Returns a dictionary array where: /// - keys are [0, 1, 2, 0, 1] (all non-null) - /// - values are ["a", null, "c"] + /// - values are `["a", null, "c"]` /// - so the keys reference: "a", null, "c", "a", null fn create_dictionary_with_null_values() -> Result> { let values = StringArray::from(vec![Some("a"), None, Some("c")]); diff --git a/datafusion/optimizer/src/extract_leaf_expressions.rs b/datafusion/optimizer/src/extract_leaf_expressions.rs index 2590b4769aab4..8048b2aeb2c9d 100644 --- a/datafusion/optimizer/src/extract_leaf_expressions.rs +++ b/datafusion/optimizer/src/extract_leaf_expressions.rs @@ -1679,8 +1679,8 @@ mod tests { } /// Test: Projection with different field than Filter - /// SELECT id, s['label'] FROM t WHERE s['value'] > 150 - /// Both s['label'] and s['value'] should be in a single extraction projection. + /// `SELECT id, s['label'] FROM t WHERE s['value'] > 150` + /// Both `s['label']` and `s['value']` should be in a single extraction projection. #[test] fn test_projection_different_field_from_filter() -> Result<()> { let table_scan = test_table_scan_with_struct()?; diff --git a/datafusion/physical-expr/src/expressions/in_list.rs b/datafusion/physical-expr/src/expressions/in_list.rs index 0fb978cd0bafe..59943086f8a36 100644 --- a/datafusion/physical-expr/src/expressions/in_list.rs +++ b/datafusion/physical-expr/src/expressions/in_list.rs @@ -881,7 +881,7 @@ mod tests { /// Test IN LIST for all string types (Utf8, LargeUtf8, Utf8View). /// - /// Test data: "a" (in list), "d" (not in list), ["b", "c"] (other list values) + /// Test data: "a" (in list), "d" (not in list), `["b", "c"]` (other list values) #[test] fn in_list_string_types() -> Result<()> { let string_data = PrimitiveTestCaseData { diff --git a/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs b/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs index 07bc98b2db798..19e308283ec81 100644 --- a/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs +++ b/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs @@ -619,7 +619,7 @@ fn try_reorder( } /// Return the expected expressions positions. -/// For example, the current expressions are ['c', 'a', 'a', b'], the expected expressions are ['b', 'c', 'a', 'a'], +/// For example, the current expressions are `['c', 'a', 'a', 'b']`, the expected expressions are `['b', 'c', 'a', 'a']`, /// /// This method will return a Vec [3, 0, 1, 2] fn expected_expr_positions( diff --git a/datafusion/physical-plan/src/joins/nested_loop_join.rs b/datafusion/physical-plan/src/joins/nested_loop_join.rs index 548a0cf1db9b1..d915dc74ea7bc 100644 --- a/datafusion/physical-plan/src/joins/nested_loop_join.rs +++ b/datafusion/physical-plan/src/joins/nested_loop_join.rs @@ -1260,9 +1260,9 @@ pub(crate) struct NestedLoopJoinStream { pub(crate) left_data: OnceFut, /// Projection to construct the output schema from the left and right tables. /// Example: - /// - output_schema: ['a', 'c'] - /// - left_schema: ['a', 'b'] - /// - right_schema: ['c'] + /// - output_schema: `['a', 'c']` + /// - left_schema: `['a', 'b']` + /// - right_schema: `['c']` /// /// The column indices would be [(left, 0), (right, 0)] -- taking the left /// 0th column and right 0th column can construct the output schema. diff --git a/datafusion/physical-plan/src/visitor.rs b/datafusion/physical-plan/src/visitor.rs index 892e603a016d3..31d1bb9831ba9 100644 --- a/datafusion/physical-plan/src/visitor.rs +++ b/datafusion/physical-plan/src/visitor.rs @@ -40,7 +40,7 @@ pub fn accept( /// after all children have been visited. /// /// To use, define a struct that implements this trait and then invoke -/// ['accept']. +/// [`accept`]. /// /// For example, for an execution plan that looks like: /// diff --git a/datafusion/pruning/src/pruning_predicate.rs b/datafusion/pruning/src/pruning_predicate.rs index dff18173ae32a..f0eccec61525c 100644 --- a/datafusion/pruning/src/pruning_predicate.rs +++ b/datafusion/pruning/src/pruning_predicate.rs @@ -4696,6 +4696,7 @@ mod tests { /// Creates a setup for chunk pruning, modeling a utf8 column "s1" /// with 5 different containers (e.g. RowGroups). They have [min, /// max]: + /// ```text /// s1 ["A", "Z"] /// s1 ["A", "L"] /// s1 ["N", "Z"] @@ -4705,6 +4706,7 @@ mod tests { /// s1 ["", ""] /// s1 ["AB", "A\u{10ffff}"] /// s1 ["A\u{10ffff}\u{10ffff}\u{10ffff}", "A\u{10ffff}\u{10ffff}"] + /// ``` fn utf8_setup() -> (SchemaRef, TestStatistics) { let schema = Arc::new(Schema::new(vec![Field::new("s1", DataType::Utf8, true)])); From 2af6967a227944981fefc0d4ff140bef573704b7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 21 Aug 2026 17:15:48 +0200 Subject: [PATCH 5/9] Enable clippy lint `ref_option` Change internal fn parameters and return types from `&Option` to `Option<&T>`, updating callers to pass `.as_ref()`. Also changes the public `apply_masking` in datafusion-substrait, which forwards from a flagged internal fn. Co-Authored-By: Claude Fable 5 --- Cargo.toml | 1 - datafusion/catalog-listing/src/helpers.rs | 6 +- .../common/src/file_options/parquet_writer.rs | 10 +- datafusion/common/src/format.rs | 22 +-- .../benches/preserve_file_partitioning.rs | 12 +- .../src/nested_schema_pruning.rs | 6 +- .../execution/src/cache/cache_manager.rs | 4 +- .../ffi/src/proto/logical_extension_codec.rs | 8 +- .../ffi/src/proto/physical_extension_codec.rs | 8 +- datafusion/ffi/src/session/mod.rs | 10 +- datafusion/ffi/src/table_provider.rs | 16 +- datafusion/ffi/src/table_provider_factory.rs | 8 +- .../functions-aggregate-common/src/min_max.rs | 170 ++++++++++++------ datafusion/functions/src/datetime/common.rs | 8 +- datafusion/functions/src/datetime/date_bin.rs | 28 ++- .../functions/src/datetime/date_trunc.rs | 91 ++++++---- .../functions/src/datetime/to_timestamp.rs | 57 +++--- .../src/output_requirements.rs | 4 +- .../physical-plan/src/aggregates/mod.rs | 7 +- .../physical-plan/src/joins/hash_join/exec.rs | 4 +- .../src/joins/sort_merge_join/filter.rs | 4 +- .../sort_merge_join/materializing_stream.rs | 6 +- datafusion/proto/src/logical_plan/mod.rs | 5 +- .../src/function/string/format_string.rs | 64 ++++--- datafusion/sql/src/parser.rs | 24 ++- datafusion/sql/src/unparser/expr.rs | 10 +- datafusion/sql/src/unparser/plan.rs | 8 +- .../consumer/expr/window_function.rs | 6 +- .../src/logical_plan/consumer/rel/read_rel.rs | 14 +- 29 files changed, 380 insertions(+), 241 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 540f8459e571d..2b326355ff73e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -309,7 +309,6 @@ needless_raw_string_hashes = "allow" # 540 hits ptr_as_ptr = "allow" # 83 hits redundant_closure_for_method_calls = "allow" # 686 hits redundant_else = "allow" # 48 hits -ref_option = "allow" # 36 hits return_self_not_must_use = "allow" # 644 hits semicolon_if_nothing_returned = "allow" # 1353 hits similar_names = "allow" # 228 hits; too many false positives, e.g. `expr`/`exprs` diff --git a/datafusion/catalog-listing/src/helpers.rs b/datafusion/catalog-listing/src/helpers.rs index 098f3d51ef911..dc090378a8513 100644 --- a/datafusion/catalog-listing/src/helpers.rs +++ b/datafusion/catalog-listing/src/helpers.rs @@ -413,7 +413,7 @@ pub async fn pruned_partition_list<'a>( .try_filter_map(|object_meta| { futures::future::ready(object_meta_to_partitioned_file( object_meta, - table_path.get_table_ref(), + table_path.get_table_ref().as_ref(), )) }) .boxed()) @@ -443,7 +443,7 @@ pub async fn pruned_partition_list<'a>( fn object_meta_to_partitioned_file( object_meta: ObjectMeta, - table_ref: &Option, + table_ref: Option<&TableReference>, ) -> Result> { Ok(Some(PartitionedFile { object_meta, @@ -454,7 +454,7 @@ fn object_meta_to_partitioned_file( ordering: None, extensions: FileExtensions::new(), metadata_size_hint: None, - table_reference: table_ref.clone(), + table_reference: table_ref.cloned(), })) } diff --git a/datafusion/common/src/file_options/parquet_writer.rs b/datafusion/common/src/file_options/parquet_writer.rs index c539245764d45..2121be904217e 100644 --- a/datafusion/common/src/file_options/parquet_writer.rs +++ b/datafusion/common/src/file_options/parquet_writer.rs @@ -344,7 +344,7 @@ fn split_compression_string(str_setting: &str) -> Result<(String, Option)> /// Helper to ensure compression codecs which don't support levels /// don't have one set. E.g. snappy(2) is invalid. -fn check_level_is_none(codec: &str, level: &Option) -> Result<()> { +fn check_level_is_none(codec: &str, level: Option<&u32>) -> Result<()> { if level.is_some() { return Err(DataFusionError::Configuration(format!( "Compression {codec} does not support specifying a level" @@ -370,11 +370,11 @@ pub fn parse_compression_string( let codec = codec.as_str(); match codec { "uncompressed" => { - check_level_is_none(codec, &level)?; + check_level_is_none(codec, level.as_ref())?; Ok(parquet::basic::Compression::UNCOMPRESSED) } "snappy" => { - check_level_is_none(codec, &level)?; + check_level_is_none(codec, level.as_ref())?; Ok(parquet::basic::Compression::SNAPPY) } "gzip" => { @@ -390,7 +390,7 @@ pub fn parse_compression_string( )?)) } "lz4" => { - check_level_is_none(codec, &level)?; + check_level_is_none(codec, level.as_ref())?; Ok(parquet::basic::Compression::LZ4) } "zstd" => { @@ -400,7 +400,7 @@ pub fn parse_compression_string( )?)) } "lz4_raw" => { - check_level_is_none(codec, &level)?; + check_level_is_none(codec, level.as_ref())?; Ok(parquet::basic::Compression::LZ4_RAW) } _ => Err(DataFusionError::Configuration(format!( diff --git a/datafusion/common/src/format.rs b/datafusion/common/src/format.rs index ea88eca4a65bc..0c71013cb09a3 100644 --- a/datafusion/common/src/format.rs +++ b/datafusion/common/src/format.rs @@ -496,27 +496,27 @@ impl ExplainStatementOptions { let name = opt.name.value.to_ascii_lowercase(); match name.as_str() { "analyze" => { - out.analyze = parse_bool_arg(&opt.arg, &name)?; + out.analyze = parse_bool_arg(opt.arg.as_ref(), &name)?; } "verbose" => { - out.verbose = parse_bool_arg(&opt.arg, &name)?; + out.verbose = parse_bool_arg(opt.arg.as_ref(), &name)?; } "format" => { - let s = parse_ident_or_string_arg(&opt.arg, &name)?; + let s = parse_ident_or_string_arg(opt.arg.as_ref(), &name)?; out.format = Some(ExplainFormat::from_str(&s)?); } "metrics" => { - let s = parse_ident_or_string_arg(&opt.arg, &name)?; + let s = parse_ident_or_string_arg(opt.arg.as_ref(), &name)?; out.analyze_categories = Some(ExplainAnalyzeCategories::from_str(&s)?); metrics_explicit = true; } "level" => { - let s = parse_ident_or_string_arg(&opt.arg, &name)?; + let s = parse_ident_or_string_arg(opt.arg.as_ref(), &name)?; out.analyze_level = Some(MetricType::from_str(&s)?); } "timing" => { - let enable = parse_bool_arg(&opt.arg, &name)?; + let enable = parse_bool_arg(opt.arg.as_ref(), &name)?; out.analyze_categories = Some(adjust_timing( out.analyze_categories.take(), enable, @@ -524,7 +524,7 @@ impl ExplainStatementOptions { )); } "summary" => { - let summary = parse_bool_arg(&opt.arg, &name)?; + let summary = parse_bool_arg(opt.arg.as_ref(), &name)?; out.analyze_level = Some(if summary { MetricType::Summary } else { @@ -532,7 +532,7 @@ impl ExplainStatementOptions { }); } "costs" => { - out.show_statistics = Some(parse_bool_arg(&opt.arg, &name)?); + out.show_statistics = Some(parse_bool_arg(opt.arg.as_ref(), &name)?); } // Postgres options DataFusion does not model. Give a helpful // pointer rather than silently accepting them. @@ -562,7 +562,7 @@ impl ExplainStatementOptions { /// identifiers `TRUE`/`FALSE`/`ON`/`OFF` (case-insensitive) and the numeric /// literals `0` / `1`. #[cfg(feature = "sql")] -fn parse_bool_arg(arg: &Option, name: &str) -> Result { +fn parse_bool_arg(arg: Option<&Expr>, name: &str) -> Result { let Some(expr) = arg else { return Ok(true); }; @@ -605,8 +605,8 @@ fn parse_bool_arg(arg: &Option, name: &str) -> Result { /// Parse an identifier-or-string argument (used for `FORMAT`, `METRICS`, /// `LEVEL`). #[cfg(feature = "sql")] -fn parse_ident_or_string_arg(arg: &Option, name: &str) -> Result { - let expr = arg.as_ref().ok_or_else(|| { +fn parse_ident_or_string_arg(arg: Option<&Expr>, name: &str) -> Result { + let expr = arg.ok_or_else(|| { DataFusionError::Plan(format!( "EXPLAIN option {} requires an argument", name.to_ascii_uppercase() diff --git a/datafusion/core/benches/preserve_file_partitioning.rs b/datafusion/core/benches/preserve_file_partitioning.rs index 9b1f59adc6823..c459853d5e05c 100644 --- a/datafusion/core/benches/preserve_file_partitioning.rs +++ b/datafusion/core/benches/preserve_file_partitioning.rs @@ -331,7 +331,7 @@ fn run_benchmark( dim_path: Option<&str>, target_partitions: usize, query: &str, - file_sort_order: &Option>>, + file_sort_order: Option<&Vec>>, ) { if std::env::var("SAVE_PLANS").is_ok() { let output_path = format!("{name}_plans.txt"); @@ -341,7 +341,7 @@ fn run_benchmark( dim_path, target_partitions, query, - file_sort_order.clone(), + file_sort_order.cloned(), )); println!("Plans saved to {output_path}"); } @@ -351,7 +351,7 @@ fn run_benchmark( for variant in &BENCH_VARIANTS { let fact_path_owned = fact_path.to_string(); let dim_path_owned = dim_path.map(|s| s.to_string()); - let sort_order = file_sort_order.clone(); + let sort_order = file_sort_order.cloned(); let query_owned = query.to_string(); let preserve_file_partitions = variant.preserve_file_partitions; let prefer_existing_sort = variant.prefer_existing_sort; @@ -520,7 +520,7 @@ fn preserve_order_bench( None, target_partitions, query, - &Some(file_sort_order), + Some(&file_sort_order), ); } @@ -653,7 +653,7 @@ fn preserve_order_join_bench( Some(dim_path), target_partitions, query, - &Some(file_sort_order), + Some(&file_sort_order), ); } @@ -757,7 +757,7 @@ fn preserve_order_window_bench( None, target_partitions, query, - &Some(file_sort_order), + Some(&file_sort_order), ); } diff --git a/datafusion/datasource-parquet/src/nested_schema_pruning.rs b/datafusion/datasource-parquet/src/nested_schema_pruning.rs index 2f7ceba3c64b6..f84ae788842e5 100644 --- a/datafusion/datasource-parquet/src/nested_schema_pruning.rs +++ b/datafusion/datasource-parquet/src/nested_schema_pruning.rs @@ -192,7 +192,7 @@ const LINEAR_FIELD_SCAN_MAX: usize = 8; /// Duplicate names resolve to the first occurrence either way. fn lookup_field<'a>( fields: &'a Fields, - by_name: &Option>, + by_name: Option<&HashMap<&'a str, &'a FieldRef>>, name: &str, ) -> Option<&'a FieldRef> { match by_name { @@ -227,7 +227,9 @@ fn clip_type( let kept_children: Fields = p_children .iter() .filter_map(|pc| { - let Some(tc) = lookup_field(t_children, &t_by_name, pc.name()) else { + let Some(tc) = + lookup_field(t_children, t_by_name.as_ref(), pc.name()) + else { skip_leaves(pc.data_type(), next_leaf); return None; }; diff --git a/datafusion/execution/src/cache/cache_manager.rs b/datafusion/execution/src/cache/cache_manager.rs index 5b8c098e3a814..bbbcaa4c77559 100644 --- a/datafusion/execution/src/cache/cache_manager.rs +++ b/datafusion/execution/src/cache/cache_manager.rs @@ -175,7 +175,7 @@ impl CachedFileList { } /// Filter the files by prefix. - fn filter_by_prefix(&self, prefix: &Option) -> Vec { + fn filter_by_prefix(&self, prefix: Option<&Path>) -> Vec { match prefix { Some(prefix) => self .files @@ -194,7 +194,7 @@ impl CachedFileList { pub fn files_matching_prefix(&self, prefix: &Option) -> Arc> { match prefix { None => Arc::clone(&self.files), - Some(p) => Arc::new(self.filter_by_prefix(&Some(p.clone()))), + Some(p) => Arc::new(self.filter_by_prefix(Some(p))), } } } diff --git a/datafusion/ffi/src/proto/logical_extension_codec.rs b/datafusion/ffi/src/proto/logical_extension_codec.rs index ed2c594f1bc02..08fe285fc4434 100644 --- a/datafusion/ffi/src/proto/logical_extension_codec.rs +++ b/datafusion/ffi/src/proto/logical_extension_codec.rs @@ -134,9 +134,9 @@ impl FFI_LogicalExtensionCodec { unsafe { &(*private_data).codec } } - fn runtime(&self) -> &Option { + fn runtime(&self) -> Option<&Handle> { let private_data = self.private_data as *const LogicalExtensionCodecPrivateData; - unsafe { &(*private_data).runtime } + unsafe { (*private_data).runtime.as_ref() } } fn task_ctx(&self) -> Result> { @@ -151,7 +151,7 @@ unsafe extern "C" fn try_decode_table_provider_fn_wrapper( schema: WrappedSchema, ) -> FFI_Result { let ctx = sresult_return!(codec.task_ctx()); - let runtime = codec.runtime().clone(); + let runtime = codec.runtime().cloned(); let codec_inner = codec.inner(); let table_ref = TableReference::from(table_ref.as_str()); let schema: SchemaRef = schema.into(); @@ -281,7 +281,7 @@ unsafe extern "C" fn clone_fn_wrapper( codec: &FFI_LogicalExtensionCodec, ) -> FFI_LogicalExtensionCodec { let old_codec = Arc::clone(codec.inner()); - let runtime = codec.runtime().clone(); + let runtime = codec.runtime().cloned(); FFI_LogicalExtensionCodec::new(old_codec, runtime, codec.task_ctx_provider.clone()) } diff --git a/datafusion/ffi/src/proto/physical_extension_codec.rs b/datafusion/ffi/src/proto/physical_extension_codec.rs index 95d2ed68a6ea3..97e49ca89e84e 100644 --- a/datafusion/ffi/src/proto/physical_extension_codec.rs +++ b/datafusion/ffi/src/proto/physical_extension_codec.rs @@ -127,9 +127,9 @@ impl FFI_PhysicalExtensionCodec { unsafe { &(*private_data).codec } } - fn runtime(&self) -> &Option { + fn runtime(&self) -> Option<&Handle> { let private_data = self.private_data as *const PhysicalExtensionCodecPrivateData; - unsafe { &(*private_data).runtime } + unsafe { (*private_data).runtime.as_ref() } } } @@ -138,7 +138,7 @@ unsafe extern "C" fn try_decode_fn_wrapper( buf: SSlice, inputs: SVec, ) -> FFI_Result { - let runtime = codec.runtime().clone(); + let runtime = codec.runtime().cloned(); let task_ctx: Arc = sresult_return!((&codec.task_ctx_provider).try_into()); let codec = codec.inner(); @@ -267,7 +267,7 @@ unsafe extern "C" fn clone_fn_wrapper( codec: &FFI_PhysicalExtensionCodec, ) -> FFI_PhysicalExtensionCodec { let old_codec = Arc::clone(codec.inner()); - let runtime = codec.runtime().clone(); + let runtime = codec.runtime().cloned(); FFI_PhysicalExtensionCodec::new(old_codec, runtime, codec.task_ctx_provider.clone()) } diff --git a/datafusion/ffi/src/session/mod.rs b/datafusion/ffi/src/session/mod.rs index 83f842508ab2c..3fdc9902e0322 100644 --- a/datafusion/ffi/src/session/mod.rs +++ b/datafusion/ffi/src/session/mod.rs @@ -180,10 +180,10 @@ impl FFI_SessionRef { unsafe { (*private_data).session } } - unsafe fn runtime(&self) -> &Option { + unsafe fn runtime(&self) -> Option<&Handle> { unsafe { let private_data = self.private_data as *const SessionPrivateData; - &(*private_data).runtime + (*private_data).runtime.as_ref() } } } @@ -203,7 +203,7 @@ unsafe extern "C" fn catalog_list_fn_wrapper( ) -> FFI_CatalogProviderList { FFI_CatalogProviderList::new_with_ffi_codec( session.inner().catalog_list(), - unsafe { session.runtime() }.clone(), + unsafe { session.runtime() }.cloned(), session.logical_codec.clone(), ) } @@ -243,7 +243,7 @@ unsafe extern "C" fn create_physical_plan_fn_wrapper( logical_plan_serialized: SVec, ) -> FfiFuture> { unsafe { - let runtime = session.runtime().clone(); + let runtime = session.runtime().cloned(); let session = session.clone(); async move { let session = session.inner(); @@ -371,7 +371,7 @@ unsafe extern "C" fn task_ctx_fn_wrapper(session: &FFI_SessionRef) -> FFI_TaskCo unsafe extern "C" fn physical_optimizers_fn_wrapper( session: &FFI_SessionRef, ) -> SVec { - let runtime = unsafe { session.runtime().clone() }; + let runtime = unsafe { session.runtime().cloned() }; session .inner() .physical_optimizers() diff --git a/datafusion/ffi/src/table_provider.rs b/datafusion/ffi/src/table_provider.rs index dbb39940460fe..5f5e8dfc2043e 100644 --- a/datafusion/ffi/src/table_provider.rs +++ b/datafusion/ffi/src/table_provider.rs @@ -202,9 +202,9 @@ impl FFI_TableProvider { unsafe { &(*private_data).provider } } - fn runtime(&self) -> &Option { + fn runtime(&self) -> Option<&Handle> { let private_data = self.private_data as *const ProviderPrivateData; - unsafe { &(*private_data).runtime } + unsafe { (*private_data).runtime.as_ref() } } } @@ -292,7 +292,7 @@ unsafe extern "C" fn scan_fn_wrapper( ) -> FfiFuture> { let task_ctx: Result, DataFusionError> = (&provider.logical_codec.task_ctx_provider).try_into(); - let runtime = provider.runtime().clone(); + let runtime = provider.runtime().cloned(); let logical_codec: Arc = (&provider.logical_codec).into(); let internal_provider = Arc::clone(provider.inner()); @@ -335,7 +335,7 @@ unsafe extern "C" fn insert_into_fn_wrapper( input: &FFI_ExecutionPlan, insert_op: FFI_InsertOp, ) -> FfiFuture> { - let runtime = provider.runtime().clone(); + let runtime = provider.runtime().cloned(); let internal_provider = Arc::clone(provider.inner()); let input = input.clone(); @@ -373,7 +373,7 @@ unsafe extern "C" fn delete_from_fn_wrapper( ) -> FfiFuture> { let task_ctx: Result, DataFusionError> = (&provider.logical_codec.task_ctx_provider).try_into(); - let runtime = provider.runtime().clone(); + let runtime = provider.runtime().cloned(); let logical_codec: Arc = (&provider.logical_codec).into(); let internal_provider = Arc::clone(provider.inner()); @@ -411,7 +411,7 @@ unsafe extern "C" fn update_fn_wrapper( ) -> FfiFuture> { let task_ctx: Result, DataFusionError> = (&provider.logical_codec.task_ctx_provider).try_into(); - let runtime = provider.runtime().clone(); + let runtime = provider.runtime().cloned(); let logical_codec: Arc = (&provider.logical_codec).into(); let internal_provider = Arc::clone(provider.inner()); @@ -473,7 +473,7 @@ unsafe extern "C" fn truncate_fn_wrapper( provider: &FFI_TableProvider, session: FFI_SessionRef, ) -> FfiFuture> { - let runtime = provider.runtime().clone(); + let runtime = provider.runtime().cloned(); let internal_provider = Arc::clone(provider.inner()); async move { @@ -506,7 +506,7 @@ unsafe extern "C" fn release_fn_wrapper(provider: &mut FFI_TableProvider) { } unsafe extern "C" fn clone_fn_wrapper(provider: &FFI_TableProvider) -> FFI_TableProvider { - let runtime = provider.runtime().clone(); + let runtime = provider.runtime().cloned(); let old_provider = Arc::clone(provider.inner()); let private_data = Box::into_raw(Box::new(ProviderPrivateData { diff --git a/datafusion/ffi/src/table_provider_factory.rs b/datafusion/ffi/src/table_provider_factory.rs index 63ebb51bb1db8..5972be38d3ff5 100644 --- a/datafusion/ffi/src/table_provider_factory.rs +++ b/datafusion/ffi/src/table_provider_factory.rs @@ -136,9 +136,9 @@ impl FFI_TableProviderFactory { unsafe { &(*private_data).factory } } - fn runtime(&self) -> &Option { + fn runtime(&self) -> Option<&Handle> { let private_data = self.private_data as *const FactoryPrivateData; - unsafe { &(*private_data).runtime } + unsafe { (*private_data).runtime.as_ref() } } fn deserialize_cmd( @@ -203,7 +203,7 @@ async fn create_fn_wrapper_impl( session: FFI_SessionRef, cmd_serialized: SVec, ) -> Result { - let runtime = factory.runtime().clone(); + let runtime = factory.runtime().cloned(); let ffi_logical_codec = factory.logical_codec.clone(); let internal_factory = Arc::clone(factory.inner()); let cmd = factory.deserialize_cmd(&cmd_serialized)?; @@ -229,7 +229,7 @@ async fn create_fn_wrapper_impl( unsafe extern "C" fn clone_fn_wrapper( factory: &FFI_TableProviderFactory, ) -> FFI_TableProviderFactory { - let runtime = factory.runtime().clone(); + let runtime = factory.runtime().cloned(); let old_factory = Arc::clone(factory.inner()); let private_data = Box::into_raw(Box::new(FactoryPrivateData { diff --git a/datafusion/functions-aggregate-common/src/min_max.rs b/datafusion/functions-aggregate-common/src/min_max.rs index 2c381facccedf..f0a4a52a4a060 100644 --- a/datafusion/functions-aggregate-common/src/min_max.rs +++ b/datafusion/functions-aggregate-common/src/min_max.rs @@ -51,8 +51,8 @@ macro_rules! min_max { } fn min_max_option( - lhs: &Option, - rhs: &Option, + lhs: Option<&T>, + rhs: Option<&T>, ordering: Ordering, ) -> Option { match (lhs, rhs) { @@ -65,8 +65,8 @@ fn min_max_option( } fn min_max_float_option( - lhs: &Option, - rhs: &Option, + lhs: Option<&T>, + rhs: Option<&T>, ordering: Ordering, cmp: impl Fn(&T, &T) -> Ordering, ) -> Option { @@ -204,88 +204,107 @@ fn min_max_scalar_same_variant( ScalarValue::Decimal32(rhsv, rhsp, rhss), ) => { ensure_decimal_compatibility(lhs, rhs, (*lhsp, *lhss), (*rhsp, *rhss))?; - ScalarValue::Decimal32(min_max_option(lhsv, rhsv, ordering), *lhsp, *lhss) + ScalarValue::Decimal32( + min_max_option(lhsv.as_ref(), rhsv.as_ref(), ordering), + *lhsp, + *lhss, + ) } ( ScalarValue::Decimal64(lhsv, lhsp, lhss), ScalarValue::Decimal64(rhsv, rhsp, rhss), ) => { ensure_decimal_compatibility(lhs, rhs, (*lhsp, *lhss), (*rhsp, *rhss))?; - ScalarValue::Decimal64(min_max_option(lhsv, rhsv, ordering), *lhsp, *lhss) + ScalarValue::Decimal64( + min_max_option(lhsv.as_ref(), rhsv.as_ref(), ordering), + *lhsp, + *lhss, + ) } ( ScalarValue::Decimal128(lhsv, lhsp, lhss), ScalarValue::Decimal128(rhsv, rhsp, rhss), ) => { ensure_decimal_compatibility(lhs, rhs, (*lhsp, *lhss), (*rhsp, *rhss))?; - ScalarValue::Decimal128(min_max_option(lhsv, rhsv, ordering), *lhsp, *lhss) + ScalarValue::Decimal128( + min_max_option(lhsv.as_ref(), rhsv.as_ref(), ordering), + *lhsp, + *lhss, + ) } ( ScalarValue::Decimal256(lhsv, lhsp, lhss), ScalarValue::Decimal256(rhsv, rhsp, rhss), ) => { ensure_decimal_compatibility(lhs, rhs, (*lhsp, *lhss), (*rhsp, *rhss))?; - ScalarValue::Decimal256(min_max_option(lhsv, rhsv, ordering), *lhsp, *lhss) + ScalarValue::Decimal256( + min_max_option(lhsv.as_ref(), rhsv.as_ref(), ordering), + *lhsp, + *lhss, + ) } (ScalarValue::Boolean(lhs), ScalarValue::Boolean(rhs)) => { - ScalarValue::Boolean(min_max_option(lhs, rhs, ordering)) - } - (ScalarValue::Float64(lhs), ScalarValue::Float64(rhs)) => { - ScalarValue::Float64(min_max_float_option(lhs, rhs, ordering, f64::total_cmp)) - } - (ScalarValue::Float32(lhs), ScalarValue::Float32(rhs)) => { - ScalarValue::Float32(min_max_float_option(lhs, rhs, ordering, f32::total_cmp)) + ScalarValue::Boolean(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } - (ScalarValue::Float16(lhs), ScalarValue::Float16(rhs)) => { - ScalarValue::Float16(min_max_float_option(lhs, rhs, ordering, |a, b| { + (ScalarValue::Float64(lhs), ScalarValue::Float64(rhs)) => ScalarValue::Float64( + min_max_float_option(lhs.as_ref(), rhs.as_ref(), ordering, f64::total_cmp), + ), + (ScalarValue::Float32(lhs), ScalarValue::Float32(rhs)) => ScalarValue::Float32( + min_max_float_option(lhs.as_ref(), rhs.as_ref(), ordering, f32::total_cmp), + ), + (ScalarValue::Float16(lhs), ScalarValue::Float16(rhs)) => ScalarValue::Float16( + min_max_float_option(lhs.as_ref(), rhs.as_ref(), ordering, |a, b| { a.total_cmp(b) - })) - } + }), + ), (ScalarValue::UInt64(lhs), ScalarValue::UInt64(rhs)) => { - ScalarValue::UInt64(min_max_option(lhs, rhs, ordering)) + ScalarValue::UInt64(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::UInt32(lhs), ScalarValue::UInt32(rhs)) => { - ScalarValue::UInt32(min_max_option(lhs, rhs, ordering)) + ScalarValue::UInt32(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::UInt16(lhs), ScalarValue::UInt16(rhs)) => { - ScalarValue::UInt16(min_max_option(lhs, rhs, ordering)) + ScalarValue::UInt16(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::UInt8(lhs), ScalarValue::UInt8(rhs)) => { - ScalarValue::UInt8(min_max_option(lhs, rhs, ordering)) + ScalarValue::UInt8(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::Int64(lhs), ScalarValue::Int64(rhs)) => { - ScalarValue::Int64(min_max_option(lhs, rhs, ordering)) + ScalarValue::Int64(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::Int32(lhs), ScalarValue::Int32(rhs)) => { - ScalarValue::Int32(min_max_option(lhs, rhs, ordering)) + ScalarValue::Int32(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::Int16(lhs), ScalarValue::Int16(rhs)) => { - ScalarValue::Int16(min_max_option(lhs, rhs, ordering)) + ScalarValue::Int16(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::Int8(lhs), ScalarValue::Int8(rhs)) => { - ScalarValue::Int8(min_max_option(lhs, rhs, ordering)) + ScalarValue::Int8(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::Utf8(lhs), ScalarValue::Utf8(rhs)) => { - ScalarValue::Utf8(min_max_option(lhs, rhs, ordering)) + ScalarValue::Utf8(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::LargeUtf8(lhs), ScalarValue::LargeUtf8(rhs)) => { - ScalarValue::LargeUtf8(min_max_option(lhs, rhs, ordering)) + ScalarValue::LargeUtf8(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::Utf8View(lhs), ScalarValue::Utf8View(rhs)) => { - ScalarValue::Utf8View(min_max_option(lhs, rhs, ordering)) + ScalarValue::Utf8View(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::Binary(lhs), ScalarValue::Binary(rhs)) => { - ScalarValue::Binary(min_max_option(lhs, rhs, ordering)) + ScalarValue::Binary(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::LargeBinary(lhs), ScalarValue::LargeBinary(rhs)) => { - ScalarValue::LargeBinary(min_max_option(lhs, rhs, ordering)) + ScalarValue::LargeBinary(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } ( ScalarValue::FixedSizeBinary(lsize, lhs), ScalarValue::FixedSizeBinary(rsize, rhs), ) => { if lsize == rsize { - ScalarValue::FixedSizeBinary(*lsize, min_max_option(lhs, rhs, ordering)) + ScalarValue::FixedSizeBinary( + *lsize, + min_max_option(lhs.as_ref(), rhs.as_ref(), ordering), + ) } else { return internal_err!( "MIN/MAX is not expected to receive FixedSizeBinary of incompatible sizes {:?}", @@ -294,62 +313,91 @@ fn min_max_scalar_same_variant( } } (ScalarValue::BinaryView(lhs), ScalarValue::BinaryView(rhs)) => { - ScalarValue::BinaryView(min_max_option(lhs, rhs, ordering)) + ScalarValue::BinaryView(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } ( ScalarValue::TimestampSecond(lhs, l_tz), ScalarValue::TimestampSecond(rhs, _), - ) => { - ScalarValue::TimestampSecond(min_max_option(lhs, rhs, ordering), l_tz.clone()) - } + ) => ScalarValue::TimestampSecond( + min_max_option(lhs.as_ref(), rhs.as_ref(), ordering), + l_tz.clone(), + ), ( ScalarValue::TimestampMillisecond(lhs, l_tz), ScalarValue::TimestampMillisecond(rhs, _), ) => ScalarValue::TimestampMillisecond( - min_max_option(lhs, rhs, ordering), + min_max_option(lhs.as_ref(), rhs.as_ref(), ordering), l_tz.clone(), ), ( ScalarValue::TimestampMicrosecond(lhs, l_tz), ScalarValue::TimestampMicrosecond(rhs, _), ) => ScalarValue::TimestampMicrosecond( - min_max_option(lhs, rhs, ordering), + min_max_option(lhs.as_ref(), rhs.as_ref(), ordering), l_tz.clone(), ), ( ScalarValue::TimestampNanosecond(lhs, l_tz), ScalarValue::TimestampNanosecond(rhs, _), ) => ScalarValue::TimestampNanosecond( - min_max_option(lhs, rhs, ordering), + min_max_option(lhs.as_ref(), rhs.as_ref(), ordering), l_tz.clone(), ), (ScalarValue::Date32(lhs), ScalarValue::Date32(rhs)) => { - ScalarValue::Date32(min_max_option(lhs, rhs, ordering)) + ScalarValue::Date32(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::Date64(lhs), ScalarValue::Date64(rhs)) => { - ScalarValue::Date64(min_max_option(lhs, rhs, ordering)) + ScalarValue::Date64(min_max_option(lhs.as_ref(), rhs.as_ref(), ordering)) } (ScalarValue::Time32Second(lhs), ScalarValue::Time32Second(rhs)) => { - ScalarValue::Time32Second(min_max_option(lhs, rhs, ordering)) + ScalarValue::Time32Second(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )) } (ScalarValue::Time32Millisecond(lhs), ScalarValue::Time32Millisecond(rhs)) => { - ScalarValue::Time32Millisecond(min_max_option(lhs, rhs, ordering)) + ScalarValue::Time32Millisecond(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )) } (ScalarValue::Time64Microsecond(lhs), ScalarValue::Time64Microsecond(rhs)) => { - ScalarValue::Time64Microsecond(min_max_option(lhs, rhs, ordering)) + ScalarValue::Time64Microsecond(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )) } (ScalarValue::Time64Nanosecond(lhs), ScalarValue::Time64Nanosecond(rhs)) => { - ScalarValue::Time64Nanosecond(min_max_option(lhs, rhs, ordering)) + ScalarValue::Time64Nanosecond(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )) } (ScalarValue::IntervalYearMonth(lhs), ScalarValue::IntervalYearMonth(rhs)) => { - ScalarValue::IntervalYearMonth(min_max_option(lhs, rhs, ordering)) + ScalarValue::IntervalYearMonth(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )) } ( ScalarValue::IntervalMonthDayNano(lhs), ScalarValue::IntervalMonthDayNano(rhs), - ) => ScalarValue::IntervalMonthDayNano(min_max_option(lhs, rhs, ordering)), + ) => ScalarValue::IntervalMonthDayNano(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )), (ScalarValue::IntervalDayTime(lhs), ScalarValue::IntervalDayTime(rhs)) => { - ScalarValue::IntervalDayTime(min_max_option(lhs, rhs, ordering)) + ScalarValue::IntervalDayTime(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )) } (ScalarValue::IntervalYearMonth(_), ScalarValue::IntervalMonthDayNano(_)) | (ScalarValue::IntervalYearMonth(_), ScalarValue::IntervalDayTime(_)) @@ -360,18 +408,34 @@ fn min_max_scalar_same_variant( return min_max_interval_scalar(lhs, rhs, ordering); } (ScalarValue::DurationSecond(lhs), ScalarValue::DurationSecond(rhs)) => { - ScalarValue::DurationSecond(min_max_option(lhs, rhs, ordering)) + ScalarValue::DurationSecond(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )) } ( ScalarValue::DurationMillisecond(lhs), ScalarValue::DurationMillisecond(rhs), - ) => ScalarValue::DurationMillisecond(min_max_option(lhs, rhs, ordering)), + ) => ScalarValue::DurationMillisecond(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )), ( ScalarValue::DurationMicrosecond(lhs), ScalarValue::DurationMicrosecond(rhs), - ) => ScalarValue::DurationMicrosecond(min_max_option(lhs, rhs, ordering)), + ) => ScalarValue::DurationMicrosecond(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )), (ScalarValue::DurationNanosecond(lhs), ScalarValue::DurationNanosecond(rhs)) => { - ScalarValue::DurationNanosecond(min_max_option(lhs, rhs, ordering)) + ScalarValue::DurationNanosecond(min_max_option( + lhs.as_ref(), + rhs.as_ref(), + ordering, + )) } (ScalarValue::Struct(_), ScalarValue::Struct(_)) | (ScalarValue::List(_), ScalarValue::List(_)) diff --git a/datafusion/functions/src/datetime/common.rs b/datafusion/functions/src/datetime/common.rs index 9a7f94bd5973f..513c8d1422bcb 100644 --- a/datafusion/functions/src/datetime/common.rs +++ b/datafusion/functions/src/datetime/common.rs @@ -56,10 +56,10 @@ static UTC: LazyLock = LazyLock::new(|| "UTC".parse().expect("UTC is always /// value is out of range (between 1677-09-21T00:12:44.0 and 2262-04-11T23:47:16.854775804) /// or the parsed value does not correspond to an unambiguous time. pub(crate) fn string_to_timestamp_nanos_with_timezone( - timezone: &Option, + timezone: Option<&Tz>, s: &str, ) -> Result { - let tz = timezone.as_ref().unwrap_or(&UTC); + let tz = timezone.unwrap_or(&UTC); let dt = string_to_datetime(tz, s)?; let parsed = dt .timestamp_nanos_opt() @@ -211,11 +211,11 @@ pub(crate) fn string_to_datetime_formatted( /// [`chrono::format::strftime`]: https://docs.rs/chrono/latest/chrono/format/strftime/index.html #[inline] pub(crate) fn string_to_timestamp_nanos_formatted_with_timezone( - timezone: &Option, + timezone: Option<&Tz>, s: &str, format: &str, ) -> Result { - let dt = string_to_datetime_formatted(timezone.as_ref().unwrap_or(&UTC), s, format)?; + let dt = string_to_datetime_formatted(timezone.unwrap_or(&UTC), s, format)?; let parsed = dt .timestamp_nanos_opt() .ok_or_else(|| exec_datafusion_err!("{ERR_NANOSECONDS_NOT_SUPPORTED}"))?; diff --git a/datafusion/functions/src/datetime/date_bin.rs b/datafusion/functions/src/datetime/date_bin.rs index c97301584348d..15cdecc3c2842 100644 --- a/datafusion/functions/src/datetime/date_bin.rs +++ b/datafusion/functions/src/datetime/date_bin.rs @@ -685,7 +685,7 @@ fn date_bin_impl( stride: i64, stride_fn: BinFunction, array: &ArrayRef, - tz_opt: &Option>, + tz_opt: Option<&Arc>, ) -> Result where T: ArrowTimestampType, @@ -697,29 +697,45 @@ fn date_bin_impl( date_bin_timestamp_value::(val, origin, stride, stride_fn) }); - let array = result.with_timezone_opt(tz_opt.clone()); + let array = result.with_timezone_opt(tz_opt.cloned()); Ok(ColumnarValue::Array(Arc::new(array))) } match array.data_type() { Timestamp(Nanosecond, tz_opt) => { transform_array_with_stride::( - origin, stride, stride_fn, array, tz_opt, + origin, + stride, + stride_fn, + array, + tz_opt.as_ref(), )? } Timestamp(Microsecond, tz_opt) => { transform_array_with_stride::( - origin, stride, stride_fn, array, tz_opt, + origin, + stride, + stride_fn, + array, + tz_opt.as_ref(), )? } Timestamp(Millisecond, tz_opt) => { transform_array_with_stride::( - origin, stride, stride_fn, array, tz_opt, + origin, + stride, + stride_fn, + array, + tz_opt.as_ref(), )? } Timestamp(Second, tz_opt) => { transform_array_with_stride::( - origin, stride, stride_fn, array, tz_opt, + origin, + stride, + stride_fn, + array, + tz_opt.as_ref(), )? } Time32(Millisecond) => { diff --git a/datafusion/functions/src/datetime/date_trunc.rs b/datafusion/functions/src/datetime/date_trunc.rs index b05f0f46e1571..690c38e5cbf43 100644 --- a/datafusion/functions/src/datetime/date_trunc.rs +++ b/datafusion/functions/src/datetime/date_trunc.rs @@ -300,7 +300,7 @@ impl ScalarUDFImpl for DateTruncFunc { fn process_array( array: &dyn Array, granularity: DateTruncGranularity, - tz_opt: &Option>, + tz_opt: Option<&Arc>, ) -> Result { let parsed_tz = parse_tz(tz_opt)?; let array = as_primitive_array::(array)?; @@ -317,21 +317,21 @@ impl ScalarUDFImpl for DateTruncFunc { T::UNIT, array, granularity, - tz_opt.clone(), + tz_opt.cloned(), )?; return Ok(ColumnarValue::Array(result)); } let array: PrimitiveArray = array .try_unary(|x| general_date_trunc(T::UNIT, x, parsed_tz, granularity))? - .with_timezone_opt(tz_opt.clone()); + .with_timezone_opt(tz_opt.cloned()); Ok(ColumnarValue::Array(Arc::new(array))) } fn process_scalar( - v: &Option, + v: Option<&i64>, granularity: DateTruncGranularity, - tz_opt: &Option>, + tz_opt: Option<&Arc>, ) -> Result { let parsed_tz = parse_tz(tz_opt)?; let value = if let Some(v) = v { @@ -339,7 +339,7 @@ impl ScalarUDFImpl for DateTruncFunc { } else { None }; - let value = ScalarValue::new_timestamp::(value, tz_opt.clone()); + let value = ScalarValue::new_timestamp::(value, tz_opt.cloned()); Ok(ColumnarValue::Scalar(value)) } @@ -349,16 +349,32 @@ impl ScalarUDFImpl for DateTruncFunc { ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(None, None)) } ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(v, tz_opt)) => { - process_scalar::(v, granularity, tz_opt)? + process_scalar::( + v.as_ref(), + granularity, + tz_opt.as_ref(), + )? } ColumnarValue::Scalar(ScalarValue::TimestampMicrosecond(v, tz_opt)) => { - process_scalar::(v, granularity, tz_opt)? + process_scalar::( + v.as_ref(), + granularity, + tz_opt.as_ref(), + )? } ColumnarValue::Scalar(ScalarValue::TimestampMillisecond(v, tz_opt)) => { - process_scalar::(v, granularity, tz_opt)? + process_scalar::( + v.as_ref(), + granularity, + tz_opt.as_ref(), + )? } ColumnarValue::Scalar(ScalarValue::TimestampSecond(v, tz_opt)) => { - process_scalar::(v, granularity, tz_opt)? + process_scalar::( + v.as_ref(), + granularity, + tz_opt.as_ref(), + )? } ColumnarValue::Scalar(ScalarValue::Time64Nanosecond(v)) => { let truncated = v.map(|val| truncate_time_nanos(val, granularity)); @@ -379,24 +395,32 @@ impl ScalarUDFImpl for DateTruncFunc { ColumnarValue::Array(array) => { let array_type = array.data_type(); match array_type { - Timestamp(Second, tz_opt) => { - process_array::(array, granularity, tz_opt)? - } - Timestamp(Millisecond, tz_opt) => process_array::< - TimestampMillisecondType, - >( - array, granularity, tz_opt - )?, - Timestamp(Microsecond, tz_opt) => process_array::< - TimestampMicrosecondType, - >( - array, granularity, tz_opt - )?, - Timestamp(Nanosecond, tz_opt) => process_array::< - TimestampNanosecondType, - >( - array, granularity, tz_opt + Timestamp(Second, tz_opt) => process_array::( + array, + granularity, + tz_opt.as_ref(), )?, + Timestamp(Millisecond, tz_opt) => { + process_array::( + array, + granularity, + tz_opt.as_ref(), + )? + } + Timestamp(Microsecond, tz_opt) => { + process_array::( + array, + granularity, + tz_opt.as_ref(), + )? + } + Timestamp(Nanosecond, tz_opt) => { + process_array::( + array, + granularity, + tz_opt.as_ref(), + )? + } Time64(Nanosecond) => { let arr = as_primitive_array::(array)?; let result: PrimitiveArray = @@ -866,13 +890,12 @@ fn general_date_trunc( Ok(result) } -fn parse_tz(tz: &Option>) -> Result> { - tz.as_ref() - .map(|tz| { - Tz::from_str(tz) - .map_err(|op| exec_datafusion_err!("failed on timezone {tz}: {op:?}")) - }) - .transpose() +fn parse_tz(tz: Option<&Arc>) -> Result> { + tz.map(|tz| { + Tz::from_str(tz) + .map_err(|op| exec_datafusion_err!("failed on timezone {tz}: {op:?}")) + }) + .transpose() } #[cfg(test)] diff --git a/datafusion/functions/src/datetime/to_timestamp.rs b/datafusion/functions/src/datetime/to_timestamp.rs index a858d8dad4e64..0007412500afa 100644 --- a/datafusion/functions/src/datetime/to_timestamp.rs +++ b/datafusion/functions/src/datetime/to_timestamp.rs @@ -501,9 +501,11 @@ impl ScalarUDFImpl for ToTimestampFunc { decimal128_to_timestamp_nanos(&arg, tz) } Decimal128(_, _) => decimal128_to_timestamp_nanos(&args[0], tz), - Utf8View | LargeUtf8 | Utf8 => { - to_timestamp_impl::(&args, "to_timestamp", &tz) - } + Utf8View | LargeUtf8 | Utf8 => to_timestamp_impl::( + &args, + "to_timestamp", + tz.as_ref(), + ), other => { exec_err!("Unsupported data type {other} for function to_timestamp") } @@ -568,7 +570,7 @@ impl ScalarUDFImpl for ToTimestampSecondsFunc { Utf8View | LargeUtf8 | Utf8 => to_timestamp_impl::( &args, "to_timestamp_seconds", - &self.timezone, + self.timezone.as_ref(), ), other => { exec_err!( @@ -637,7 +639,7 @@ impl ScalarUDFImpl for ToTimestampMillisFunc { Utf8View | LargeUtf8 | Utf8 => to_timestamp_impl::( &args, "to_timestamp_millis", - &self.timezone, + self.timezone.as_ref(), ), other => { exec_err!( @@ -706,7 +708,7 @@ impl ScalarUDFImpl for ToTimestampMicrosFunc { Utf8View | LargeUtf8 | Utf8 => to_timestamp_impl::( &args, "to_timestamp_micros", - &self.timezone, + self.timezone.as_ref(), ), other => { exec_err!( @@ -775,7 +777,7 @@ impl ScalarUDFImpl for ToTimestampNanosFunc { Utf8View | LargeUtf8 | Utf8 => to_timestamp_impl::( &args, "to_timestamp_nanos", - &self.timezone, + self.timezone.as_ref(), ), other => { exec_err!( @@ -794,7 +796,7 @@ impl ScalarUDFImpl for ToTimestampNanosFunc { fn to_timestamp_impl>( args: &[ColumnarValue], name: &str, - timezone: &Option>, + timezone: Option<&Arc>, ) -> Result { let factor = match T::UNIT { Second => 1_000_000_000, @@ -803,7 +805,7 @@ fn to_timestamp_impl>( Nanosecond => 1, }; - let tz = match timezone.clone() { + let tz = match timezone { Some(tz) => Some(tz.parse::()?), None => None, }; @@ -811,18 +813,21 @@ fn to_timestamp_impl>( match args.len() { 1 => handle::( args, - move |s| string_to_timestamp_nanos_with_timezone(&tz, s).map(|n| n / factor), + move |s| { + string_to_timestamp_nanos_with_timezone(tz.as_ref(), s) + .map(|n| n / factor) + }, name, - &Timestamp(T::UNIT, timezone.clone()), + &Timestamp(T::UNIT, timezone.cloned()), ), n if n >= 2 => handle_multiple::( args, move |s, format| { - string_to_timestamp_nanos_formatted_with_timezone(&tz, s, format) + string_to_timestamp_nanos_formatted_with_timezone(tz.as_ref(), s, format) }, |n| n / factor, name, - &Timestamp(T::UNIT, timezone.clone()), + &Timestamp(T::UNIT, timezone.cloned()), ), _ => exec_err!("Unsupported 0 argument count for function {name}"), } @@ -846,7 +851,11 @@ mod tests { fn to_timestamp(args: &[ColumnarValue]) -> Result { let timezone: Option> = Some("UTC".into()); - to_timestamp_impl::(args, "to_timestamp", &timezone) + to_timestamp_impl::( + args, + "to_timestamp", + timezone.as_ref(), + ) } /// to_timestamp_millis SQL function @@ -855,7 +864,7 @@ mod tests { to_timestamp_impl::( args, "to_timestamp_millis", - &timezone, + timezone.as_ref(), ) } @@ -865,7 +874,7 @@ mod tests { to_timestamp_impl::( args, "to_timestamp_micros", - &timezone, + timezone.as_ref(), ) } @@ -875,14 +884,18 @@ mod tests { to_timestamp_impl::( args, "to_timestamp_nanos", - &timezone, + timezone.as_ref(), ) } /// to_timestamp_seconds SQL function fn to_timestamp_seconds(args: &[ColumnarValue]) -> Result { let timezone: Option> = Some("UTC".into()); - to_timestamp_impl::(args, "to_timestamp_seconds", &timezone) + to_timestamp_impl::( + args, + "to_timestamp_seconds", + timezone.as_ref(), + ) } fn udfs_and_timeunit() -> Vec<(Box, TimeUnit)> { @@ -1573,11 +1586,9 @@ mod tests { } fn parse_timestamp_formatted(s: &str, format: &str) -> Result { - let result = string_to_timestamp_nanos_formatted_with_timezone( - &Some("UTC".parse()?), - s, - format, - ); + let tz: Tz = "UTC".parse()?; + let result = + string_to_timestamp_nanos_formatted_with_timezone(Some(&tz), s, format); if let Err(e) = &result { eprintln!("Error parsing timestamp '{s}' using format '{format}': {e:?}"); } diff --git a/datafusion/physical-optimizer/src/output_requirements.rs b/datafusion/physical-optimizer/src/output_requirements.rs index 541981270169e..83cef91ec4355 100644 --- a/datafusion/physical-optimizer/src/output_requirements.rs +++ b/datafusion/physical-optimizer/src/output_requirements.rs @@ -117,7 +117,7 @@ impl OutputRequirementExec { dist_requirement: Distribution, fetch: Option, ) -> Self { - let cache = Self::compute_properties(&input, &fetch); + let cache = Self::compute_properties(&input, fetch); Self { input, order_requirement: requirements, @@ -134,7 +134,7 @@ impl OutputRequirementExec { /// This function creates the cache object that stores the plan properties such as schema, equivalence properties, ordering, partitioning, etc. fn compute_properties( input: &Arc, - fetch: &Option, + fetch: Option, ) -> PlanProperties { let boundedness = if fetch.is_some() { Boundedness::Bounded diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs index e85ef5ce583b0..3c1df7076c47f 100644 --- a/datafusion/physical-plan/src/aggregates/mod.rs +++ b/datafusion/physical-plan/src/aggregates/mod.rs @@ -2809,7 +2809,7 @@ pub fn concat_slices(lhs: &[T], rhs: &[T]) -> Vec { // Returns `None` if they are incomparable, `Some(true)` if there is no current // ordering or candidate ordering is finer, and `Some(false)` otherwise. fn determine_finer( - current: &Option, + current: Option<&LexOrdering>, candidate: &LexOrdering, ) -> Option { if let Some(ordering) = current { @@ -2867,7 +2867,7 @@ pub fn get_finer_aggregate_exprs_requirement( // we can skip this expression. If the latter is finer than the former, // adopt it if it is satisfied by the equivalence properties. Otherwise, // defer the analysis to the reverse expression. - let forward_finer = determine_finer(&requirement, &aggr_req); + let forward_finer = determine_finer(requirement.as_ref(), &aggr_req); if let Some(finer) = forward_finer { if !finer { continue; @@ -2894,7 +2894,8 @@ pub fn get_finer_aggregate_exprs_requirement( // expression. If the latter is finer than the former, adopt it if // it is satisfied by the equivalence properties. Otherwise, adopt // the forward expression. - if let Some(finer) = determine_finer(&requirement, &rev_aggr_req) { + if let Some(finer) = determine_finer(requirement.as_ref(), &rev_aggr_req) + { if !finer { *aggr_expr = Arc::new(reverse_aggr_expr); } else if eq_properties.ordering_satisfy(rev_aggr_req.clone())? { diff --git a/datafusion/physical-plan/src/joins/hash_join/exec.rs b/datafusion/physical-plan/src/joins/hash_join/exec.rs index aa06015be7137..828e557ccd9d9 100644 --- a/datafusion/physical-plan/src/joins/hash_join/exec.rs +++ b/datafusion/physical-plan/src/joins/hash_join/exec.rs @@ -109,7 +109,7 @@ const ARRAY_MAP_CREATED_COUNT_METRIC_NAME: &str = "array_map_created_count"; #[expect(clippy::too_many_arguments)] fn try_create_array_map( - bounds: &Option, + bounds: Option<&PartitionBounds>, schema: &SchemaRef, batches: &[RecordBatch], on_left: &[PhysicalExprRef], @@ -2642,7 +2642,7 @@ async fn collect_left_input( let (join_hash_map, batch, left_values) = if let Some((array_map, batch, left_value)) = try_create_array_map( - &bounds, + bounds.as_ref(), &schema, &batches, &on_left, diff --git a/datafusion/physical-plan/src/joins/sort_merge_join/filter.rs b/datafusion/physical-plan/src/joins/sort_merge_join/filter.rs index 4fc6cccaa8838..306a154666fae 100644 --- a/datafusion/physical-plan/src/joins/sort_merge_join/filter.rs +++ b/datafusion/physical-plan/src/joins/sort_merge_join/filter.rs @@ -138,7 +138,7 @@ impl Default for FilterMetadata { /// - A filter exists AND /// - The join type requires ensuring each input row produces at least one output pub fn needs_deferred_filtering( - filter: &Option, + filter: Option<&JoinFilter>, join_type: JoinType, ) -> bool { filter.is_some() @@ -149,7 +149,7 @@ pub fn needs_deferred_filtering( /// /// Extracts the columns needed for filter evaluation from left and right batch columns pub fn get_filter_columns( - join_filter: &Option, + join_filter: Option<&JoinFilter>, left_columns: &[ArrayRef], right_columns: &[ArrayRef], ) -> Vec { diff --git a/datafusion/physical-plan/src/joins/sort_merge_join/materializing_stream.rs b/datafusion/physical-plan/src/joins/sort_merge_join/materializing_stream.rs index 3baa0c4a3e792..30abff1ad4711 100644 --- a/datafusion/physical-plan/src/joins/sort_merge_join/materializing_stream.rs +++ b/datafusion/physical-plan/src/joins/sort_merge_join/materializing_stream.rs @@ -568,7 +568,7 @@ impl MaterializingSortMergeJoinStream { buffered_exhausted: false, on_streamed, on_buffered, - deferred_filtering: needs_deferred_filtering(&filter, join_type), + deferred_filtering: needs_deferred_filtering(filter.as_ref(), join_type), filter, joined_record_batches: JoinedRecordBatches { joined_batches: BatchCoalescer::new(Arc::clone(&schema), batch_size) @@ -1546,9 +1546,9 @@ impl MaterializingSortMergeJoinStream { self.materialize_right_columns(matched_chunks, total_matched_rows)?; let filter_columns = if self.join_type == JoinType::Right { - get_filter_columns(&self.filter, &right_columns, &left_columns) + get_filter_columns(self.filter.as_ref(), &right_columns, &left_columns) } else { - get_filter_columns(&self.filter, &left_columns, &right_columns) + get_filter_columns(self.filter.as_ref(), &left_columns, &right_columns) }; let columns = if self.join_type != JoinType::Right { diff --git a/datafusion/proto/src/logical_plan/mod.rs b/datafusion/proto/src/logical_plan/mod.rs index 08c1a59e46c6c..71516ec3a91ea 100644 --- a/datafusion/proto/src/logical_plan/mod.rs +++ b/datafusion/proto/src/logical_plan/mod.rs @@ -376,7 +376,7 @@ fn from_table_reference( /// method to be used to deserialize nodes /// serialized by [from_table_source] fn to_table_source( - node: &Option>, + node: Option<&LogicalPlanNode>, ctx: &TaskContext, extension_codec: &dyn LogicalExtensionCodec, ) -> Result> { @@ -1293,7 +1293,8 @@ impl AsLogicalPlan for LogicalPlanNode { LogicalPlanType::Dml(dml_node) => { let table_name = from_table_reference(dml_node.table_name.as_ref(), "DML ")?; - let target = to_table_source(&dml_node.target, ctx, extension_codec)?; + let target = + to_table_source(dml_node.target.as_deref(), ctx, extension_codec)?; let write_op = from_proto::parse_write_op(dml_node, ctx, extension_codec)?; Ok(LogicalPlan::Dml(DmlStatement::new( diff --git a/datafusion/spark/src/function/string/format_string.rs b/datafusion/spark/src/function/string/format_string.rs index 64346dd823d80..f2ab85265c82a 100644 --- a/datafusion/spark/src/function/string/format_string.rs +++ b/datafusion/spark/src/function/string/format_string.rs @@ -1000,16 +1000,32 @@ impl ConversionSpecifier { self.format_string(string, &value.unwrap_or(false).to_string()) } - _ => self.format_boolean(string, value), + _ => self.format_boolean(string, value.as_ref()), }, - ScalarValue::Int8(value) => self.format_integer(string, value, "Int8"), - ScalarValue::Int16(value) => self.format_integer(string, value, "Int16"), - ScalarValue::Int32(value) => self.format_integer(string, value, "Int32"), - ScalarValue::Int64(value) => self.format_integer(string, value, "Int64"), - ScalarValue::UInt8(value) => self.format_integer(string, value, "UInt8"), - ScalarValue::UInt16(value) => self.format_integer(string, value, "UInt16"), - ScalarValue::UInt32(value) => self.format_integer(string, value, "UInt32"), - ScalarValue::UInt64(value) => self.format_integer(string, value, "UInt64"), + ScalarValue::Int8(value) => { + self.format_integer(string, value.as_ref(), "Int8") + } + ScalarValue::Int16(value) => { + self.format_integer(string, value.as_ref(), "Int16") + } + ScalarValue::Int32(value) => { + self.format_integer(string, value.as_ref(), "Int32") + } + ScalarValue::Int64(value) => { + self.format_integer(string, value.as_ref(), "Int64") + } + ScalarValue::UInt8(value) => { + self.format_integer(string, value.as_ref(), "UInt8") + } + ScalarValue::UInt16(value) => { + self.format_integer(string, value.as_ref(), "UInt16") + } + ScalarValue::UInt32(value) => { + self.format_integer(string, value.as_ref(), "UInt32") + } + ScalarValue::UInt64(value) => { + self.format_integer(string, value.as_ref(), "UInt64") + } ScalarValue::Float16(value) => match (self.conversion_type, value) { ( ConversionType::DecFloatLower @@ -1183,7 +1199,7 @@ impl ConversionSpecifier { ( ConversionType::TimeLower(_) | ConversionType::TimeUpper(_), Some(value), - ) => self.format_time(string, *value as i64 * 1000000000, &None), + ) => self.format_time(string, *value as i64 * 1000000000, None), ( ConversionType::StringLower | ConversionType::StringUpper, Some(value), @@ -1201,7 +1217,7 @@ impl ConversionSpecifier { ( ConversionType::TimeLower(_) | ConversionType::TimeUpper(_), Some(value), - ) => self.format_time(string, *value as i64 * 1000000, &None), + ) => self.format_time(string, *value as i64 * 1000000, None), ( ConversionType::StringLower | ConversionType::StringUpper, Some(value), @@ -1220,7 +1236,7 @@ impl ConversionSpecifier { ( ConversionType::TimeLower(_) | ConversionType::TimeUpper(_), Some(value), - ) => self.format_time(string, *value * 1000, &None), + ) => self.format_time(string, *value * 1000, None), ( ConversionType::StringLower | ConversionType::StringUpper, Some(value), @@ -1238,7 +1254,7 @@ impl ConversionSpecifier { ( ConversionType::TimeLower(_) | ConversionType::TimeUpper(_), Some(value), - ) => self.format_time(string, *value, &None), + ) => self.format_time(string, *value, None), ( ConversionType::StringLower | ConversionType::StringUpper, Some(value), @@ -1256,7 +1272,7 @@ impl ConversionSpecifier { ( ConversionType::TimeLower(_) | ConversionType::TimeUpper(_), Some(value), - ) => self.format_time(string, value * 1000000000, zone), + ) => self.format_time(string, value * 1000000000, zone.as_ref()), ( ConversionType::StringLower | ConversionType::StringUpper, Some(value), @@ -1275,7 +1291,7 @@ impl ConversionSpecifier { ( ConversionType::TimeLower(_) | ConversionType::TimeUpper(_), Some(value), - ) => self.format_time(string, *value * 1000000, zone), + ) => self.format_time(string, *value * 1000000, zone.as_ref()), ( ConversionType::StringLower | ConversionType::StringUpper, Some(value), @@ -1295,7 +1311,7 @@ impl ConversionSpecifier { ( ConversionType::TimeLower(_) | ConversionType::TimeUpper(_), Some(value), - ) => self.format_time(string, value * 1000, zone), + ) => self.format_time(string, value * 1000, zone.as_ref()), ( ConversionType::StringLower | ConversionType::StringUpper, Some(value), @@ -1315,7 +1331,7 @@ impl ConversionSpecifier { ( ConversionType::TimeLower(_) | ConversionType::TimeUpper(_), Some(value), - ) => self.format_time(string, *value, zone), + ) => self.format_time(string, *value, zone.as_ref()), ( ConversionType::StringLower | ConversionType::StringUpper, Some(value), @@ -1374,13 +1390,13 @@ impl ConversionSpecifier { fn format_integer( &self, writer: &mut String, - value: &Option, + value: Option<&T>, type_name: &str, ) -> Result<()> where T: Copy + IntegerFormatValue, { - let Some(value) = *value else { + let Some(value) = value.copied() else { return if self.conversion_type.supports_integer() { self.format_string(writer, "null") } else { @@ -1644,8 +1660,8 @@ impl ConversionSpecifier { } } - fn format_boolean(&self, writer: &mut String, value: &Option) -> Result<()> { - let value = value.unwrap_or(false); + fn format_boolean(&self, writer: &mut String, value: Option<&bool>) -> Result<()> { + let value = value.copied().unwrap_or(false); let formatted = match self.conversion_type { ConversionType::BooleanUpper => { @@ -2094,7 +2110,7 @@ impl ConversionSpecifier { &self, writer: &mut String, timestamp_nanos: i64, - timezone: &Option>, + timezone: Option<&Arc>, ) -> Result<()> { let upper = self.conversion_type.is_upper(); match &self.conversion_type { @@ -2121,14 +2137,14 @@ impl ConversionSpecifier { fn format_date(&self, writer: &mut String, date_days: i64) -> Result<()> { // Convert days since epoch to timestamp in nanoseconds let timestamp_nanos = date_days * 24 * 60 * 60 * 1_000_000_000; - self.format_time(writer, timestamp_nanos, &None) + self.format_time(writer, timestamp_nanos, None) } fn format_time_component( &self, timestamp_nanos: i64, time_format: TimeFormat, - _timezone: &Option>, + _timezone: Option<&Arc>, ) -> Result { // Convert nanoseconds to seconds and nanoseconds remainder let secs = timestamp_nanos / 1_000_000_000; diff --git a/datafusion/sql/src/parser.rs b/datafusion/sql/src/parser.rs index 71493fb9c9d25..f554a57838881 100644 --- a/datafusion/sql/src/parser.rs +++ b/datafusion/sql/src/parser.rs @@ -357,7 +357,7 @@ impl fmt::Display for Statement { } } -fn ensure_not_set(field: &Option, name: &str) -> Result<(), DataFusionError> { +fn ensure_not_set(field: Option<&T>, name: &str) -> Result<(), DataFusionError> { if field.is_some() { parser_err!(format!("{name} specified more than once",))? } @@ -722,11 +722,11 @@ impl<'a> DFParser<'a> { match keyword { Keyword::STORED => { self.parser.expect_keyword(Keyword::AS)?; - ensure_not_set(&builder.stored_as, "STORED AS")?; + ensure_not_set(builder.stored_as.as_ref(), "STORED AS")?; builder.stored_as = Some(self.parse_file_format()?); } Keyword::TO => { - ensure_not_set(&builder.target, "TO")?; + ensure_not_set(builder.target.as_ref(), "TO")?; builder.target = Some(self.parser.parse_literal_string()?); } Keyword::WITH => { @@ -738,11 +738,14 @@ impl<'a> DFParser<'a> { } Keyword::PARTITIONED => { self.parser.expect_keyword(Keyword::BY)?; - ensure_not_set(&builder.partitioned_by, "PARTITIONED BY")?; + ensure_not_set( + builder.partitioned_by.as_ref(), + "PARTITIONED BY", + )?; builder.partitioned_by = Some(self.parse_partitions()?); } Keyword::OPTIONS => { - ensure_not_set(&builder.options, "OPTIONS")?; + ensure_not_set(builder.options.as_ref(), "OPTIONS")?; builder.options = Some(self.parse_value_options()?); } _ => { @@ -1133,11 +1136,11 @@ impl<'a> DFParser<'a> { match keyword { Keyword::STORED => { self.parser.expect_keyword(Keyword::AS)?; - ensure_not_set(&builder.file_type, "STORED AS")?; + ensure_not_set(builder.file_type.as_ref(), "STORED AS")?; builder.file_type = Some(self.parse_file_format()?); } Keyword::LOCATION => { - ensure_not_set(&builder.locations, "LOCATION")?; + ensure_not_set(builder.locations.as_ref(), "LOCATION")?; builder.locations = Some(self.parse_locations()?); } Keyword::WITH => { @@ -1164,7 +1167,10 @@ impl<'a> DFParser<'a> { } Keyword::PARTITIONED => { self.parser.expect_keyword(Keyword::BY)?; - ensure_not_set(&builder.table_partition_cols, "PARTITIONED BY")?; + ensure_not_set( + builder.table_partition_cols.as_ref(), + "PARTITIONED BY", + )?; // Expects either list of column names (col_name [, col_name]*) // or list of column definitions (col_name datatype [, col_name datatype]* ) // use the token after the name to decide which parsing rule to use @@ -1191,7 +1197,7 @@ impl<'a> DFParser<'a> { } } Keyword::OPTIONS => { - ensure_not_set(&builder.options, "OPTIONS")?; + ensure_not_set(builder.options.as_ref(), "OPTIONS")?; builder.options = Some(self.parse_value_options()?); } _ => { diff --git a/datafusion/sql/src/unparser/expr.rs b/datafusion/sql/src/unparser/expr.rs index 898330018c708..cd3ac1f3a455b 100644 --- a/datafusion/sql/src/unparser/expr.rs +++ b/datafusion/sql/src/unparser/expr.rs @@ -1202,7 +1202,7 @@ impl Unparser<'_> { fn handle_timestamp( &self, v: &ScalarValue, - tz: &Option>, + tz: Option<&Arc>, ) -> Result where i64: From, @@ -1498,25 +1498,25 @@ impl Unparser<'_> { } ScalarValue::Time64Nanosecond(None) => Ok(ast::Expr::value(ast::Value::Null)), ScalarValue::TimestampSecond(Some(_ts), tz) => { - self.handle_timestamp::(v, tz) + self.handle_timestamp::(v, tz.as_ref()) } ScalarValue::TimestampSecond(None, _) => { Ok(ast::Expr::value(ast::Value::Null)) } ScalarValue::TimestampMillisecond(Some(_ts), tz) => { - self.handle_timestamp::(v, tz) + self.handle_timestamp::(v, tz.as_ref()) } ScalarValue::TimestampMillisecond(None, _) => { Ok(ast::Expr::value(ast::Value::Null)) } ScalarValue::TimestampMicrosecond(Some(_ts), tz) => { - self.handle_timestamp::(v, tz) + self.handle_timestamp::(v, tz.as_ref()) } ScalarValue::TimestampMicrosecond(None, _) => { Ok(ast::Expr::value(ast::Value::Null)) } ScalarValue::TimestampNanosecond(Some(_ts), tz) => { - self.handle_timestamp::(v, tz) + self.handle_timestamp::(v, tz.as_ref()) } ScalarValue::TimestampNanosecond(None, _) => { Ok(ast::Expr::value(ast::Value::Null)) diff --git a/datafusion/sql/src/unparser/plan.rs b/datafusion/sql/src/unparser/plan.rs index 9922509a0e609..e5a367f9ef76a 100644 --- a/datafusion/sql/src/unparser/plan.rs +++ b/datafusion/sql/src/unparser/plan.rs @@ -1357,7 +1357,7 @@ impl Unparser<'_> { let (join_filters, where_filters) = Self::split_join_on_and_where_filters( join.join_type, - &join.filter, + join.filter.as_ref(), table_scan_filters, ); for filter in where_filters { @@ -2571,17 +2571,17 @@ impl Unparser<'_> { /// Returns `(on_filter, where_filters)`. fn split_join_on_and_where_filters( join_type: JoinType, - join_filter: &Option, + join_filter: Option<&Expr>, table_scan_filters: Vec, ) -> (Option, Vec) { if table_scan_filters.is_empty() { - return (join_filter.clone(), vec![]); + return (join_filter.cloned(), vec![]); } if join_type == JoinType::Inner { // ON and WHERE are equivalent for inner joins; prefer WHERE // because some dialects reject subqueries inside JOIN ON. - return (join_filter.clone(), table_scan_filters); + return (join_filter.cloned(), table_scan_filters); } // Outer joins: fold table-scan filters into ON to preserve semantics. diff --git a/datafusion/substrait/src/logical_plan/consumer/expr/window_function.rs b/datafusion/substrait/src/logical_plan/consumer/expr/window_function.rs index 1f6f602a2ab73..820ff6768bdaf 100644 --- a/datafusion/substrait/src/logical_plan/consumer/expr/window_function.rs +++ b/datafusion/substrait/src/logical_plan/consumer/expr/window_function.rs @@ -84,8 +84,8 @@ pub async fn from_window_function( }; let window_frame = datafusion::logical_expr::WindowFrame::new_bounds( bound_units, - from_substrait_bound(&window.lower_bound, true)?, - from_substrait_bound(&window.upper_bound, false)?, + from_substrait_bound(window.lower_bound.as_ref(), true)?, + from_substrait_bound(window.upper_bound.as_ref(), false)?, ); window_frame.regularize_order_bys(&mut order_by)?; @@ -119,7 +119,7 @@ pub async fn from_window_function( } fn from_substrait_bound( - bound: &Option, + bound: Option<&Bound>, is_lower: bool, ) -> datafusion::common::Result { match bound { diff --git a/datafusion/substrait/src/logical_plan/consumer/rel/read_rel.rs b/datafusion/substrait/src/logical_plan/consumer/rel/read_rel.rs index 78951a3aff549..2cad1440807a5 100644 --- a/datafusion/substrait/src/logical_plan/consumer/rel/read_rel.rs +++ b/datafusion/substrait/src/logical_plan/consumer/rel/read_rel.rs @@ -44,8 +44,8 @@ pub async fn from_read_rel( consumer: &impl SubstraitConsumer, table_ref: TableReference, schema: DFSchema, - projection: &Option, - filter: &Option>, + projection: Option<&MaskExpression>, + filter: Option<&Expression>, ) -> datafusion::common::Result { let schema = schema.replace_qualifier(table_ref.clone()); @@ -108,8 +108,8 @@ pub async fn from_read_rel( consumer, table_reference, substrait_schema, - &read.projection, - &read.filter, + read.projection.as_ref(), + read.filter.as_deref(), ) .await } @@ -240,8 +240,8 @@ pub async fn from_read_rel( consumer, table_reference, substrait_schema, - &read.projection, - &read.filter, + read.projection.as_ref(), + read.filter.as_deref(), ) .await } @@ -293,7 +293,7 @@ fn convert_literal_rows( pub fn apply_masking( schema: DFSchema, - mask_expression: &::core::option::Option, + mask_expression: Option<&MaskExpression>, ) -> datafusion::common::Result { match mask_expression { Some(MaskExpression { select, .. }) => match &select.as_ref() { From dbd2c0ac84518a27b86d11be81698e99cfb5c2a7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 21 Aug 2026 18:34:48 +0200 Subject: [PATCH 6/9] Enable clippy lint `needless_continue` Drop `continue` expressions that end a loop iteration anyway, flattening the surrounding `match`/`if` where that reads better. Co-Authored-By: Claude Fable 5 --- Cargo.toml | 1 - datafusion-cli/src/exec.rs | 8 +--- datafusion/common/src/column.rs | 2 +- datafusion/datasource/src/boundary_stream.rs | 38 +++++++++---------- datafusion/datasource/src/file_stream/mod.rs | 2 +- .../src/aggregates/hash_stream.rs | 2 - .../src/aggregates/ordered_final_stream.rs | 1 - .../src/aggregates/ordered_single_stream.rs | 1 - .../src/aggregates/partial_reduce_stream.rs | 1 - .../src/aggregates/single_stream.rs | 1 - .../physical-plan/src/execution_plan.rs | 2 +- .../src/joins/nested_loop_join.rs | 14 +++---- .../src/operator_statistics/mod.rs | 3 +- .../physical-plan/src/repartition/mod.rs | 4 +- datafusion/physical-plan/src/sorts/stream.rs | 3 +- datafusion/physical-plan/src/stream.rs | 17 +++------ datafusion/physical-plan/src/topk/mod.rs | 4 +- .../src/function/datetime/make_dt_interval.rs | 5 +-- .../src/function/datetime/make_interval.rs | 5 +-- .../tests/cases/roundtrip_logical_plan.rs | 33 +++------------- 20 files changed, 50 insertions(+), 97 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2b326355ff73e..b2fbc3ea1100e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -304,7 +304,6 @@ missing_fields_in_debug = "allow" # 29 hits missing_panics_doc = "allow" # 244 hits must_use_candidate = "allow" # 2726 hits needless_bitwise_bool = "allow" # 1 hit -needless_continue = "allow" # 37 hits needless_raw_string_hashes = "allow" # 540 hits ptr_as_ptr = "allow" # 83 hits redundant_closure_for_method_calls = "allow" # 686 hits diff --git a/datafusion-cli/src/exec.rs b/datafusion-cli/src/exec.rs index fc230d5362346..288ce4b7351b6 100644 --- a/datafusion-cli/src/exec.rs +++ b/datafusion-cli/src/exec.rs @@ -73,12 +73,7 @@ pub async fn exec_from_lines( for line in reader.lines() { match line { - Ok(line) if line.starts_with("#!") => { - continue; - } - Ok(line) if line.starts_with("--") => { - continue; - } + Ok(line) if line.starts_with("#!") || line.starts_with("--") => {} Ok(line) => { let line = line.trim_end(); query.push_str(line); @@ -197,7 +192,6 @@ pub async fn exec_from_repl( Err(ReadlineError::Interrupted) => { println!("^C"); rl.helper().unwrap().reset_hint(); - continue; } Err(ReadlineError::Eof) => { println!("\\q"); diff --git a/datafusion/common/src/column.rs b/datafusion/common/src/column.rs index f8893aa423fa1..8204ffdf92f18 100644 --- a/datafusion/common/src/column.rs +++ b/datafusion/common/src/column.rs @@ -236,7 +236,7 @@ impl Column { .flat_map(|s| s.qualified_fields_with_unqualified_name(&self.name)) .collect::>(); match qualified_fields.len() { - 0 => continue, + 0 => {} 1 => return Ok(Column::from(qualified_fields[0])), _ => { // More than 1 fields in this schema have their names set to self.name. diff --git a/datafusion/datasource/src/boundary_stream.rs b/datafusion/datasource/src/boundary_stream.rs index 496a74085378d..a1d10651b5e46 100644 --- a/datafusion/datasource/src/boundary_stream.rs +++ b/datafusion/datasource/src/boundary_stream.rs @@ -239,27 +239,25 @@ impl Stream for AlignedBoundaryStream { } Poll::Ready(Some(Ok(chunk))) => { this.bytes_consumed += chunk.len() as u64; - match chunk.iter().position(|&b| b == this.terminator) { - Some(pos) => { - let remainder = chunk.slice((pos + 1)..); - // The aligned start position is where - // data begins after the newline. - let aligned_start = - this.abs_pos() - remainder.len() as u64; - if aligned_start >= this.end { - // Start alignment landed at or past - // the end boundary — no complete - // lines in this partition's range. - this.phase = Phase::Done; - return Poll::Ready(None); - } - if !remainder.is_empty() { - this.pending = Some(remainder); - } - this.phase = Phase::FetchingChunks; - continue; + if let Some(pos) = + chunk.iter().position(|&b| b == this.terminator) + { + let remainder = chunk.slice((pos + 1)..); + // The aligned start position is where + // data begins after the newline. + let aligned_start = + this.abs_pos() - remainder.len() as u64; + if aligned_start >= this.end { + // Start alignment landed at or past + // the end boundary — no complete + // lines in this partition's range. + this.phase = Phase::Done; + return Poll::Ready(None); + } + if !remainder.is_empty() { + this.pending = Some(remainder); } - None => continue, + this.phase = Phase::FetchingChunks; } } } diff --git a/datafusion/datasource/src/file_stream/mod.rs b/datafusion/datasource/src/file_stream/mod.rs index 6daed7c338022..93595cb355a47 100644 --- a/datafusion/datasource/src/file_stream/mod.rs +++ b/datafusion/datasource/src/file_stream/mod.rs @@ -95,7 +95,7 @@ impl FileStream { FileStreamState::Scan { scan_state: queue } => { let action = queue.poll_scan(cx); match action { - ScanAndReturn::Continue => continue, + ScanAndReturn::Continue => {} ScanAndReturn::Done(result) => { self.state = FileStreamState::Done; return Poll::Ready(result); diff --git a/datafusion/physical-plan/src/aggregates/hash_stream.rs b/datafusion/physical-plan/src/aggregates/hash_stream.rs index 2df5960188a2b..340bf5cfc12d6 100644 --- a/datafusion/physical-plan/src/aggregates/hash_stream.rs +++ b/datafusion/physical-plan/src/aggregates/hash_stream.rs @@ -980,7 +980,6 @@ impl Stream for PartialHashAggregateStream { match next_state { ControlFlow::Continue(next_state) => { self.state = Some(next_state); - continue; } ControlFlow::Break((Poll::Ready(Some(Err(e))), next_state)) => { debug_assert!(matches!(next_state, PartialHashAggregateState::Error)); @@ -1539,7 +1538,6 @@ impl Stream for FinalHashAggregateStream { match next_state { ControlFlow::Continue(next_state) => { self.state = Some(next_state); - continue; } ControlFlow::Break((Poll::Ready(Some(Err(e))), next_state)) => { debug_assert!(matches!(next_state, FinalHashAggregateState::Error)); diff --git a/datafusion/physical-plan/src/aggregates/ordered_final_stream.rs b/datafusion/physical-plan/src/aggregates/ordered_final_stream.rs index 2c26b74da7748..8823dcb32f47c 100644 --- a/datafusion/physical-plan/src/aggregates/ordered_final_stream.rs +++ b/datafusion/physical-plan/src/aggregates/ordered_final_stream.rs @@ -876,7 +876,6 @@ impl Stream for OrderedFinalAggregateStream { match next_state { ControlFlow::Continue(next_state) => { self.state = Some(next_state); - continue; } ControlFlow::Break((Poll::Ready(Some(Err(e))), next_state)) => { // Errors are terminal: discard all operator state and release diff --git a/datafusion/physical-plan/src/aggregates/ordered_single_stream.rs b/datafusion/physical-plan/src/aggregates/ordered_single_stream.rs index da00b42e5c3ed..701dee4e8146d 100644 --- a/datafusion/physical-plan/src/aggregates/ordered_single_stream.rs +++ b/datafusion/physical-plan/src/aggregates/ordered_single_stream.rs @@ -856,7 +856,6 @@ impl Stream for OrderedSingleAggregateStream { match next_state { ControlFlow::Continue(next_state) => { self.state = Some(next_state); - continue; } ControlFlow::Break((Poll::Ready(Some(Err(e))), next_state)) => { debug_assert!(matches!( diff --git a/datafusion/physical-plan/src/aggregates/partial_reduce_stream.rs b/datafusion/physical-plan/src/aggregates/partial_reduce_stream.rs index 2f4535e66f4ef..9eedf868477a0 100644 --- a/datafusion/physical-plan/src/aggregates/partial_reduce_stream.rs +++ b/datafusion/physical-plan/src/aggregates/partial_reduce_stream.rs @@ -367,7 +367,6 @@ impl Stream for PartialReduceHashAggregateStream { match next_state { ControlFlow::Continue(next_state) => { self.state = Some(next_state); - continue; } ControlFlow::Break((poll, next_state)) => { self.state = Some(next_state); diff --git a/datafusion/physical-plan/src/aggregates/single_stream.rs b/datafusion/physical-plan/src/aggregates/single_stream.rs index 3e306d72a7e82..7b8b08c15ba30 100644 --- a/datafusion/physical-plan/src/aggregates/single_stream.rs +++ b/datafusion/physical-plan/src/aggregates/single_stream.rs @@ -806,7 +806,6 @@ impl Stream for SingleHashAggregateStream { match next_state { ControlFlow::Continue(next_state) => { self.state = Some(next_state); - continue; } ControlFlow::Break((Poll::Ready(Some(Err(e))), next_state)) => { debug_assert!(matches!(next_state, SingleHashAggregateState::Error)); diff --git a/datafusion/physical-plan/src/execution_plan.rs b/datafusion/physical-plan/src/execution_plan.rs index a4d081b3d9e75..db1a629f93f91 100644 --- a/datafusion/physical-plan/src/execution_plan.rs +++ b/datafusion/physical-plan/src/execution_plan.rs @@ -1467,7 +1467,7 @@ pub(crate) fn emission_type_from_children<'a>( match child.pipeline_behavior() { EmissionType::Final => return EmissionType::Final, EmissionType::Both => inc_and_final = true, - EmissionType::Incremental => continue, + EmissionType::Incremental => {} } } diff --git a/datafusion/physical-plan/src/joins/nested_loop_join.rs b/datafusion/physical-plan/src/joins/nested_loop_join.rs index d915dc74ea7bc..5cd1cf740ed28 100644 --- a/datafusion/physical-plan/src/joins/nested_loop_join.rs +++ b/datafusion/physical-plan/src/joins/nested_loop_join.rs @@ -1408,7 +1408,7 @@ impl Stream for NestedLoopJoinStream { let _build_timer = build_metric.timer(); match self.handle_buffering_left(cx) { - ControlFlow::Continue(()) => continue, + ControlFlow::Continue(()) => {} ControlFlow::Break(poll) => return poll, } } @@ -1443,7 +1443,7 @@ impl Stream for NestedLoopJoinStream { let _join_timer = join_metric.timer(); match self.handle_fetching_right(cx) { - ControlFlow::Continue(()) => continue, + ControlFlow::Continue(()) => {} ControlFlow::Break(poll) => return poll, } } @@ -1470,7 +1470,7 @@ impl Stream for NestedLoopJoinStream { let _join_timer = join_metric.timer(); match self.handle_probe_right() { - ControlFlow::Continue(()) => continue, + ControlFlow::Continue(()) => {} ControlFlow::Break(poll) => { return self.metrics.join_metrics.baseline.record_poll(poll); } @@ -1491,7 +1491,7 @@ impl Stream for NestedLoopJoinStream { let _join_timer = join_metric.timer(); match self.handle_emit_right_unmatched() { - ControlFlow::Continue(()) => continue, + ControlFlow::Continue(()) => {} ControlFlow::Break(poll) => { return self.metrics.join_metrics.baseline.record_poll(poll); } @@ -1513,7 +1513,7 @@ impl Stream for NestedLoopJoinStream { let _join_timer = join_metric.timer(); match self.handle_probe_end() { - ControlFlow::Continue(()) => continue, + ControlFlow::Continue(()) => {} ControlFlow::Break(poll) => { return self.metrics.join_metrics.baseline.record_poll(poll); } @@ -1543,7 +1543,7 @@ impl Stream for NestedLoopJoinStream { let _join_timer = join_metric.timer(); match self.handle_emit_left_unmatched() { - ControlFlow::Continue(()) => continue, + ControlFlow::Continue(()) => {} ControlFlow::Break(poll) => { return self.metrics.join_metrics.baseline.record_poll(poll); } @@ -1562,7 +1562,7 @@ impl Stream for NestedLoopJoinStream { let _join_timer = join_metric.timer(); match self.handle_emit_global_right_unmatched(cx) { - ControlFlow::Continue(()) => continue, + ControlFlow::Continue(()) => {} ControlFlow::Break(poll) => { return self.metrics.join_metrics.baseline.record_poll(poll); } diff --git a/datafusion/physical-plan/src/operator_statistics/mod.rs b/datafusion/physical-plan/src/operator_statistics/mod.rs index 16b89e9eca926..0e1066456b309 100644 --- a/datafusion/physical-plan/src/operator_statistics/mod.rs +++ b/datafusion/physical-plan/src/operator_statistics/mod.rs @@ -379,7 +379,8 @@ impl StatisticsRegistry { for provider in &self.providers { match provider.compute_statistics(plan, &child_stats)? { StatisticsResult::Computed(stats) => return Ok(stats), - StatisticsResult::Delegate => continue, + // Try the next provider + StatisticsResult::Delegate => {} } } // Fallback: use plan's built-in stats diff --git a/datafusion/physical-plan/src/repartition/mod.rs b/datafusion/physical-plan/src/repartition/mod.rs index 8f4b8558a592b..806f69495a4ef 100644 --- a/datafusion/physical-plan/src/repartition/mod.rs +++ b/datafusion/physical-plan/src/repartition/mod.rs @@ -2409,7 +2409,6 @@ impl PerPartitionStream { // We must block on spill stream until we get the batch // to preserve ordering self.state = StreamState::ReadingSpilled; - continue; } Err(e) => { return Poll::Ready(Some(Err(e))); @@ -2422,8 +2421,7 @@ impl PerPartitionStream { // All input partitions finished return Poll::Ready(None); } - // Continue to poll for more data from other partitions - continue; + // Otherwise poll for more data from the other partitions } None => { // Channel closed unexpectedly diff --git a/datafusion/physical-plan/src/sorts/stream.rs b/datafusion/physical-plan/src/sorts/stream.rs index 652276c26dfa4..bb9c00949369e 100644 --- a/datafusion/physical-plan/src/sorts/stream.rs +++ b/datafusion/physical-plan/src/sorts/stream.rs @@ -76,7 +76,8 @@ impl FusedStreams { let poll_result = self.0[stream_idx].poll_next_unpin(cx); match &poll_result { Poll::Pending => return Poll::Pending, - Poll::Ready(Some(Ok(b))) if b.num_rows() == 0 => continue, + // Skip empty batches + Poll::Ready(Some(Ok(b))) if b.num_rows() == 0 => {} Poll::Ready(Some(Ok(_))) => return poll_result, Poll::Ready(None) | Poll::Ready(Some(Err(_))) => { let stream_schema = self.0[stream_idx].get_ref().schema(); diff --git a/datafusion/physical-plan/src/stream.rs b/datafusion/physical-plan/src/stream.rs index 9d0b964886afd..a1c89daa31b39 100644 --- a/datafusion/physical-plan/src/stream.rs +++ b/datafusion/physical-plan/src/stream.rs @@ -133,14 +133,10 @@ impl ReceiverStreamBuilder { let check = async move { while let Some(result) = join_set.join_next().await { match result { - Ok(task_result) => { - match task_result { - // Nothing to report - Ok(_) => continue, - // This means a blocking task error - Err(error) => return Some(Err(error)), - } - } + // Nothing to report + Ok(Ok(())) => {} + // This means a blocking task error + Ok(Err(error)) => return Some(Err(error)), // This means a tokio task error, likely a panic Err(e) => { if e.is_panic() { @@ -1030,9 +1026,8 @@ mod test { assert_eq!(batch.num_rows(), 0); } Poll::Ready(Some(Err(e))) => panic!("Unexpected error: {e}"), - Poll::Pending => { - continue; - } + // Keep polling + Poll::Pending => {} } } diff --git a/datafusion/physical-plan/src/topk/mod.rs b/datafusion/physical-plan/src/topk/mod.rs index 030614eed02e5..97196e174cdf1 100644 --- a/datafusion/physical-plan/src/topk/mod.rs +++ b/datafusion/physical-plan/src/topk/mod.rs @@ -1672,9 +1672,9 @@ impl PartitionedTopKRank { match classification { Some(Ordering::Equal) => { equal_indices.push(orig_idx); - continue; } - Some(Ordering::Greater) => continue, + // Strictly worse than the current boundary: drop the row. + Some(Ordering::Greater) => {} Some(Ordering::Less) | None => { // Heap path: heap not yet full, or row strictly // better than the current boundary. diff --git a/datafusion/spark/src/function/datetime/make_dt_interval.rs b/datafusion/spark/src/function/datetime/make_dt_interval.rs index 88ccae1b914a4..f7d093a84a327 100644 --- a/datafusion/spark/src/function/datetime/make_dt_interval.rs +++ b/datafusion/spark/src/function/datetime/make_dt_interval.rs @@ -189,10 +189,7 @@ fn make_dt_interval_kernel(args: &[ArrayRef]) -> Result builder.append_value(v), - None => { - builder.append_null(); - continue; - } + None => builder.append_null(), } } diff --git a/datafusion/spark/src/function/datetime/make_interval.rs b/datafusion/spark/src/function/datetime/make_interval.rs index abbf398d53d89..7ccc5cbbc8df0 100644 --- a/datafusion/spark/src/function/datetime/make_interval.rs +++ b/datafusion/spark/src/function/datetime/make_interval.rs @@ -215,10 +215,7 @@ fn make_interval_kernel(args: &[ArrayRef]) -> Result match make_interval_month_day_nano(y, mo, w, d, h, mi, s) { Some(v) => builder.append_value(v), - None => { - builder.append_null(); - continue; - } + None => builder.append_null(), } } diff --git a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs index 3ee40cd5c6c05..b60aa96299b1b 100644 --- a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs +++ b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs @@ -2401,10 +2401,7 @@ fn check_post_join_filters(rel: &Rel) -> Result<()> { } Some(RelType::Set(set)) => { for input in &set.inputs { - match check_post_join_filters(input) { - Err(e) => return Err(e), - Ok(_) => continue, - } + check_post_join_filters(input)?; } Ok(()) } @@ -2413,10 +2410,7 @@ fn check_post_join_filters(rel: &Rel) -> Result<()> { } Some(RelType::ExtensionMulti(ext)) => { for input in &ext.inputs { - match check_post_join_filters(input) { - Err(e) => return Err(e), - Ok(_) => continue, - } + check_post_join_filters(input)?; } Ok(()) } @@ -2432,15 +2426,9 @@ fn verify_post_join_filter_value(proto: &Plan) -> Result<()> { for relation in &proto.relations { match relation.rel_type.as_ref() { Some(rt) => match rt { - plan_rel::RelType::Rel(rel) => match check_post_join_filters(rel) { - Err(e) => return Err(e), - Ok(_) => continue, - }, + plan_rel::RelType::Rel(rel) => check_post_join_filters(rel)?, plan_rel::RelType::Root(root) => { - match check_post_join_filters(root.input.as_ref().unwrap()) { - Err(e) => return Err(e), - Ok(_) => continue, - } + check_post_join_filters(root.input.as_ref().unwrap())? } }, None => return plan_err!("Cannot parse plan relation: None"), @@ -2473,19 +2461,10 @@ fn assert_read_filter_count(proto: &Plan, expected_filter_count: u32) -> Result< match relation.rel_type.as_ref() { Some(rt) => match rt { plan_rel::RelType::Rel(rel) => { - match count_read_filters(rel, &mut filter_count) { - Err(e) => return Err(e), - Ok(_) => continue, - } + count_read_filters(rel, &mut filter_count)? } plan_rel::RelType::Root(root) => { - match count_read_filters( - root.input.as_ref().unwrap(), - &mut filter_count, - ) { - Err(e) => return Err(e), - Ok(_) => continue, - } + count_read_filters(root.input.as_ref().unwrap(), &mut filter_count)? } }, None => return plan_err!("Cannot parse plan relation: None"), From 1dceebd7d66277da573bc37f42c54624892f1fb7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 21 Aug 2026 18:42:29 +0200 Subject: [PATCH 7/9] Enable clippy lint `cloned_instead_of_copied` Use `Iterator::copied`/`Option::copied` instead of `cloned` for `Copy` types. Applied with `cargo clippy --fix`. Co-Authored-By: Claude Fable 5 --- Cargo.toml | 1 - datafusion-examples/examples/query_planning/pruning.rs | 2 +- datafusion/core/tests/fuzz_cases/limit_fuzz.rs | 8 ++++---- datafusion/core/tests/fuzz_cases/pruning.rs | 2 +- datafusion/core/tests/parquet/mod.rs | 10 +++++----- datafusion/datasource-parquet/src/sort.rs | 2 +- datafusion/ffi/src/udaf/groups_accumulator.rs | 4 ++-- .../src/aggregate/count_distinct/native.rs | 2 +- datafusion/functions-aggregate-common/src/utils.rs | 2 +- datafusion/functions-aggregate/src/sum.rs | 2 +- datafusion/functions-nested/benches/array_slice.rs | 2 +- datafusion/functions/src/regex/regexpcount.rs | 10 +++++----- datafusion/functions/src/regex/regexpinstr.rs | 8 ++++---- datafusion/optimizer/src/push_down_filter.rs | 2 +- datafusion/physical-expr-common/src/binary_map.rs | 2 +- datafusion/physical-expr-common/src/binary_view_map.rs | 2 +- datafusion/physical-expr/benches/case_when.rs | 4 ++-- datafusion/physical-expr/benches/in_list_strategy.rs | 2 +- datafusion/physical-expr/src/utils/guarantee.rs | 2 +- datafusion/proto-common/src/generated/pbjson.rs | 2 +- datafusion/sql/src/expr/subquery.rs | 2 +- datafusion/sql/src/unparser/plan.rs | 2 +- test-utils/src/array_gen/primitive.rs | 2 +- 23 files changed, 38 insertions(+), 39 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b2fbc3ea1100e..7982d37a5021d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -275,7 +275,6 @@ cast_possible_truncation = "allow" # 911 hits cast_possible_wrap = "allow" # 493 hits cast_precision_loss = "allow" # 266 hits cast_sign_loss = "allow" # 440 hits -cloned_instead_of_copied = "allow" # 38 hits default_trait_access = "allow" # 221 hits doc_comment_double_space_linebreaks = "allow" # 6 hits doc_markdown = "allow" # 4933 hits; needs a long `doc-valid-idents` list in `clippy.toml` diff --git a/datafusion-examples/examples/query_planning/pruning.rs b/datafusion-examples/examples/query_planning/pruning.rs index 023058f825f64..7bde0171420f3 100644 --- a/datafusion-examples/examples/query_planning/pruning.rs +++ b/datafusion-examples/examples/query_planning/pruning.rs @@ -211,5 +211,5 @@ fn create_pruning_predicate(expr: Expr, schema: &SchemaRef) -> PruningPredicate } fn i32_array<'a>(values: impl Iterator>) -> ArrayRef { - Arc::new(Int32Array::from_iter(values.cloned())) + Arc::new(Int32Array::from_iter(values.copied())) } diff --git a/datafusion/core/tests/fuzz_cases/limit_fuzz.rs b/datafusion/core/tests/fuzz_cases/limit_fuzz.rs index 1c5741e7a21b3..4ce3ffab5c814 100644 --- a/datafusion/core/tests/fuzz_cases/limit_fuzz.rs +++ b/datafusion/core/tests/fuzz_cases/limit_fuzz.rs @@ -107,7 +107,7 @@ impl SortedData { }) .collect(); - let batches = stagger_batch(int32_batch(data.iter().cloned())); + let batches = stagger_batch(int32_batch(data.iter().copied())); let mut sorted = data; sorted.sort_unstable(); @@ -131,7 +131,7 @@ impl SortedData { data.push(data[rng.random_range(0..data.len())]); } - let batches = stagger_batch(f64_batch(data.iter().cloned())); + let batches = stagger_batch(f64_batch(data.iter().copied())); let mut sorted = data; sorted.sort_by(|a, b| a.partial_cmp(b).unwrap()); @@ -197,8 +197,8 @@ impl SortedData { /// Return top top `limit` values as a RecordBatch fn topk_values(&self, limit: usize) -> RecordBatch { match self { - Self::I32 { sorted, .. } => int32_batch(sorted.iter().take(limit).cloned()), - Self::F64 { sorted, .. } => f64_batch(sorted.iter().take(limit).cloned()), + Self::I32 { sorted, .. } => int32_batch(sorted.iter().take(limit).copied()), + Self::F64 { sorted, .. } => f64_batch(sorted.iter().take(limit).copied()), Self::Str { sorted, .. } => string_batch(sorted.iter().take(limit)), Self::I64Str { sorted, .. } => i64string_batch(sorted.iter().take(limit)), } diff --git a/datafusion/core/tests/fuzz_cases/pruning.rs b/datafusion/core/tests/fuzz_cases/pruning.rs index 7624c97cf47f7..da7faffcb3a61 100644 --- a/datafusion/core/tests/fuzz_cases/pruning.rs +++ b/datafusion/core/tests/fuzz_cases/pruning.rs @@ -361,7 +361,7 @@ static VALUES: LazyLock> = LazyLock::new(|| { values.extend( characters .iter() - .cloned() + .copied() .combinations(*length) // now get all permutations of each combination .flat_map(|c| c.into_iter().permutations(*length)) diff --git a/datafusion/core/tests/parquet/mod.rs b/datafusion/core/tests/parquet/mod.rs index 7066a4147c017..98cad8bea0cd1 100644 --- a/datafusion/core/tests/parquet/mod.rs +++ b/datafusion/core/tests/parquet/mod.rs @@ -901,25 +901,25 @@ fn make_dictionary_batch(strings: Vec<&str>, integers: Vec) -> RecordBatch let large_utf8_dict = DictionaryArray::new(keys.clone(), Arc::new(large_utf8)); let binary = - BinaryArray::from_iter_values(strings.iter().cloned().map(|v| v.as_bytes())); + BinaryArray::from_iter_values(strings.iter().copied().map(|v| v.as_bytes())); let binary_dict = DictionaryArray::new(keys.clone(), Arc::new(binary)); let large_binary = - LargeBinaryArray::from_iter_values(strings.iter().cloned().map(|v| v.as_bytes())); + LargeBinaryArray::from_iter_values(strings.iter().copied().map(|v| v.as_bytes())); let large_binary_dict = DictionaryArray::new(keys.clone(), Arc::new(large_binary)); let int32 = Int32Array::from_iter_values(integers.clone()); let int32_dict = DictionaryArray::new(small_keys.clone(), Arc::new(int32)); - let int64 = Int64Array::from_iter_values(integers.iter().cloned().map(|v| v as i64)); + let int64 = Int64Array::from_iter_values(integers.iter().copied().map(|v| v as i64)); let int64_dict = DictionaryArray::new(keys.clone(), Arc::new(int64)); let uint32 = - UInt32Array::from_iter_values(integers.iter().cloned().map(|v| v as u32)); + UInt32Array::from_iter_values(integers.iter().copied().map(|v| v as u32)); let uint32_dict = DictionaryArray::new(small_keys.clone(), Arc::new(uint32)); let decimal = Decimal128Array::from_iter_values( - integers.iter().cloned().map(|v| (v * 100) as i128), + integers.iter().copied().map(|v| (v * 100) as i128), ) .with_precision_and_scale(6, 2) .unwrap(); diff --git a/datafusion/datasource-parquet/src/sort.rs b/datafusion/datasource-parquet/src/sort.rs index 0f73723a1de91..826bd2a51170b 100644 --- a/datafusion/datasource-parquet/src/sort.rs +++ b/datafusion/datasource-parquet/src/sort.rs @@ -108,7 +108,7 @@ pub fn reverse_row_selection( let mut reversed_selectors = Vec::new(); for &rg_idx in row_groups_to_scan.iter().rev() { if let Some(selectors) = rg_selections.get(&rg_idx) { - reversed_selectors.extend(selectors.iter().cloned()); + reversed_selectors.extend(selectors.iter().copied()); } else { // No specific selection for this row group means select all rows in it if let Some((_, start, end)) = diff --git a/datafusion/ffi/src/udaf/groups_accumulator.rs b/datafusion/ffi/src/udaf/groups_accumulator.rs index fb76d443a0c6b..ddf5204104030 100644 --- a/datafusion/ffi/src/udaf/groups_accumulator.rs +++ b/datafusion/ffi/src/udaf/groups_accumulator.rs @@ -311,7 +311,7 @@ impl GroupsAccumulator for ForeignGroupsAccumulator { .iter() .map(WrappedArray::try_from) .collect::, ArrowError>>()?; - let group_indices = group_indices.iter().cloned().collect(); + let group_indices = group_indices.iter().copied().collect(); let opt_filter = opt_filter .map(|bool_array| to_ffi(&bool_array.to_data())) .transpose()? @@ -373,7 +373,7 @@ impl GroupsAccumulator for ForeignGroupsAccumulator { .iter() .map(WrappedArray::try_from) .collect::, ArrowError>>()?; - let group_indices = group_indices.iter().cloned().collect(); + let group_indices = group_indices.iter().copied().collect(); df_result!((self.accumulator.merge_batch)( &mut self.accumulator, diff --git a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs index 00c1a47b9eafb..6af7131536f04 100644 --- a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs +++ b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs @@ -72,7 +72,7 @@ where { fn state(&mut self) -> datafusion_common::Result> { let arr = Arc::new( - PrimitiveArray::::from_iter_values(self.values.iter().cloned()) + PrimitiveArray::::from_iter_values(self.values.iter().copied()) .with_data_type(self.data_type.clone()), ); Ok(vec![ diff --git a/datafusion/functions-aggregate-common/src/utils.rs b/datafusion/functions-aggregate-common/src/utils.rs index 256d80a67b1df..abe2c9a79c78d 100644 --- a/datafusion/functions-aggregate-common/src/utils.rs +++ b/datafusion/functions-aggregate-common/src/utils.rs @@ -237,7 +237,7 @@ impl GenericDistinctBuffer { self.values.extend(arr.iter().flatten().map(Hashable)); } else { self.values - .extend(arr.values().iter().cloned().map(Hashable)); + .extend(arr.values().iter().copied().map(Hashable)); } Ok(()) diff --git a/datafusion/functions-aggregate/src/sum.rs b/datafusion/functions-aggregate/src/sum.rs index 1999f68d4cdd7..5b8ad51a5ae18 100644 --- a/datafusion/functions-aggregate/src/sum.rs +++ b/datafusion/functions-aggregate/src/sum.rs @@ -680,7 +680,7 @@ impl Accumulator for SlidingDistinctSumAccumulator { let keys = self .counts .keys() - .cloned() + .copied() .map(Some) .map(ScalarValue::Int64) .collect::>(); diff --git a/datafusion/functions-nested/benches/array_slice.rs b/datafusion/functions-nested/benches/array_slice.rs index b95fe47575e53..55e8de2ed84dc 100644 --- a/datafusion/functions-nested/benches/array_slice.rs +++ b/datafusion/functions-nested/benches/array_slice.rs @@ -98,7 +98,7 @@ fn random_from_to_stride( } }; - let stride = stride_choices.choose(rng).cloned().unwrap_or(None); + let stride = stride_choices.choose(rng).copied().unwrap_or(None); if from.is_none() || to.is_none() || stride.is_none_or(|s| s > 0) { (from, to, stride) diff --git a/datafusion/functions/src/regex/regexpcount.rs b/datafusion/functions/src/regex/regexpcount.rs index 8e8b4436e3ba2..2920b687ed33f 100644 --- a/datafusion/functions/src/regex/regexpcount.rs +++ b/datafusion/functions/src/regex/regexpcount.rs @@ -626,7 +626,7 @@ mod tests { // utf8 let v_sv = ScalarValue::Utf8(Some(v.to_string())); let regex_sv = ScalarValue::Utf8(Some(regex.to_string())); - let expected = expected.get(pos).cloned(); + let expected = expected.get(pos).copied(); let re = regexp_count_with_scalar_values(&[v_sv, regex_sv]); match re { Ok(ColumnarValue::Scalar(ScalarValue::Int64(v))) => { @@ -669,7 +669,7 @@ mod tests { .zip(start_positions.iter()) .enumerate() .for_each(|(pos, (&value, &start))| { - let expected = expected.get(pos).cloned(); + let expected = expected.get(pos).copied(); let start_sv = ScalarValue::Int64(Some(start)); let re = regexp_count_with_scalar_values(&[ @@ -721,7 +721,7 @@ mod tests { let v_sv = ScalarValue::Utf8(Some(v.to_string())); let regex_sv = ScalarValue::Utf8(Some(regex.to_string())); let start_sv = ScalarValue::Int64(Some(start)); - let expected = expected.get(pos).cloned(); + let expected = expected.get(pos).copied(); let re = regexp_count_with_scalar_values(&[v_sv, regex_sv, start_sv.clone()]); match re { Ok(ColumnarValue::Scalar(ScalarValue::Int64(v))) => { @@ -767,7 +767,7 @@ mod tests { let regex_sv = ScalarValue::Utf8(Some(regex.to_string())); let start_sv = ScalarValue::Int64(Some(start)); let flags_sv = ScalarValue::Utf8(Some(flags.to_string())); - let expected = expected.get(pos).cloned(); + let expected = expected.get(pos).copied(); let re = regexp_count_with_scalar_values(&[ v_sv, @@ -882,7 +882,7 @@ mod tests { let regex_sv = ScalarValue::Utf8(regex.get(pos).map(|s| (*s).to_string())); let start_sv = ScalarValue::Int64(Some(start)); let flags_sv = ScalarValue::Utf8(flags.get(pos).map(|f| (*f).to_string())); - let expected = expected.get(pos).cloned(); + let expected = expected.get(pos).copied(); let re = regexp_count_with_scalar_values(&[ v_sv, regex_sv, diff --git a/datafusion/functions/src/regex/regexpinstr.rs b/datafusion/functions/src/regex/regexpinstr.rs index 96152297fbc87..de460c56f63c5 100644 --- a/datafusion/functions/src/regex/regexpinstr.rs +++ b/datafusion/functions/src/regex/regexpinstr.rs @@ -532,7 +532,7 @@ mod tests { // utf8 let v_sv = ScalarValue::Utf8(Some(v.to_string())); let regex_sv = ScalarValue::Utf8(Some(r.to_string())); - let expected = expected.get(pos).cloned(); + let expected = expected.get(pos).copied(); let re = regexp_instr_with_scalar_values(&[v_sv, regex_sv]); // let res_exp = re.unwrap(); match re { @@ -579,7 +579,7 @@ mod tests { let v_sv = ScalarValue::Utf8(Some(v.to_string())); let regex_sv = ScalarValue::Utf8(Some(r.to_string())); let start_sv = ScalarValue::Int64(Some(s)); - let expected = expected.get(pos).cloned(); + let expected = expected.get(pos).copied(); let re = regexp_instr_with_scalar_values(&[v_sv, regex_sv, start_sv.clone()]); match re { @@ -632,7 +632,7 @@ mod tests { let regex_sv = ScalarValue::Utf8(Some(r.to_string())); let start_sv = ScalarValue::Int64(Some(s)); let nth_sv = ScalarValue::Int64(Some(n)); - let expected = expected.get(pos).cloned(); + let expected = expected.get(pos).copied(); let re = regexp_instr_with_scalar_values(&[ v_sv, regex_sv, @@ -710,7 +710,7 @@ mod tests { let nth_sv = ScalarValue::Int64(Some(n)); let flags_sv = ScalarValue::Utf8(Some(flag.to_string())); let subexp_sv = ScalarValue::Int64(Some(subexp)); - let expected = expected.get(pos).cloned(); + let expected = expected.get(pos).copied(); let re = regexp_instr_with_scalar_values(&[ v_sv, regex_sv, diff --git a/datafusion/optimizer/src/push_down_filter.rs b/datafusion/optimizer/src/push_down_filter.rs index cf54ae254746d..1ae0ee40858a9 100644 --- a/datafusion/optimizer/src/push_down_filter.rs +++ b/datafusion/optimizer/src/push_down_filter.rs @@ -648,7 +648,7 @@ impl InferredPredicates { || matches!( is_restrict_null_predicate( predicate.clone(), - replace_map.keys().cloned() + replace_map.keys().copied() ), Ok(true) ) diff --git a/datafusion/physical-expr-common/src/binary_map.rs b/datafusion/physical-expr-common/src/binary_map.rs index 8815c5d43416d..642f256d1b7a9 100644 --- a/datafusion/physical-expr-common/src/binary_map.rs +++ b/datafusion/physical-expr-common/src/binary_map.rs @@ -942,7 +942,7 @@ mod tests { // update self with new values, keeping track of newly added values for str in strings { let str = str.map(|s| s.to_string()); - let index = self.indexes.get(&str).cloned().unwrap_or_else(|| { + let index = self.indexes.get(&str).copied().unwrap_or_else(|| { actual_new_strings.push(str.clone()); let index = self.strings.len(); self.strings.push(str.clone()); diff --git a/datafusion/physical-expr-common/src/binary_view_map.rs b/datafusion/physical-expr-common/src/binary_view_map.rs index d05a419c1c93d..51f6f4fb660b1 100644 --- a/datafusion/physical-expr-common/src/binary_view_map.rs +++ b/datafusion/physical-expr-common/src/binary_view_map.rs @@ -826,7 +826,7 @@ mod tests { // update self with new values, keeping track of newly added values for str in strings { let str = str.map(|s| s.to_string()); - let index = self.indexes.get(&str).cloned().unwrap_or_else(|| { + let index = self.indexes.get(&str).copied().unwrap_or_else(|| { actual_new_strings.push(str.clone()); let index = self.strings.len(); self.strings.push(str.clone()); diff --git a/datafusion/physical-expr/benches/case_when.rs b/datafusion/physical-expr/benches/case_when.rs index 33931a2ba98e4..b6c45f002ddbf 100644 --- a/datafusion/physical-expr/benches/case_when.rs +++ b/datafusion/physical-expr/benches/case_when.rs @@ -543,8 +543,8 @@ fn benchmark_divide_by_zero_protection(c: &mut Criterion, batch_size: usize) { }) .collect(); - let divisor: Int32Array = divisor_values.iter().cloned().collect(); - let divisor_copy: Int32Array = divisor_values.iter().cloned().collect(); + let divisor: Int32Array = divisor_values.iter().copied().collect(); + let divisor_copy: Int32Array = divisor_values.iter().copied().collect(); let schema = Arc::new(Schema::new(vec![ Field::new("numerator", numerator.data_type().clone(), true), diff --git a/datafusion/physical-expr/benches/in_list_strategy.rs b/datafusion/physical-expr/benches/in_list_strategy.rs index 762c2c97a1115..c4abdcc1523ec 100644 --- a/datafusion/physical-expr/benches/in_list_strategy.rs +++ b/datafusion/physical-expr/benches/in_list_strategy.rs @@ -753,7 +753,7 @@ fn bench_dict_int32( let mut rng = StdRng::seed_from_u64(seed); let dict_values: Vec = (0..dict_size).map(|_| rng.random()).collect(); - let haystack: Vec = dict_values.iter().take(list_size).cloned().collect(); + let haystack: Vec = dict_values.iter().take(list_size).copied().collect(); let indices: Vec = (0..ARRAY_SIZE) .map(|_| rng.random_range(0..dict_size as i32)) diff --git a/datafusion/physical-expr/src/utils/guarantee.rs b/datafusion/physical-expr/src/utils/guarantee.rs index c36e69603681e..8b870c573d393 100644 --- a/datafusion/physical-expr/src/utils/guarantee.rs +++ b/datafusion/physical-expr/src/utils/guarantee.rs @@ -525,7 +525,7 @@ fn find_common_columns<'a>( if termset_cols.len() != termset.len() { return Vec::new(); } - common_cols = common_cols.intersection(&termset_cols).cloned().collect(); + common_cols = common_cols.intersection(&termset_cols).copied().collect(); } common_cols.into_iter().collect() diff --git a/datafusion/proto-common/src/generated/pbjson.rs b/datafusion/proto-common/src/generated/pbjson.rs index c222cd1cb8687..feaeaf3c5cacb 100644 --- a/datafusion/proto-common/src/generated/pbjson.rs +++ b/datafusion/proto-common/src/generated/pbjson.rs @@ -3997,7 +3997,7 @@ impl serde::Serialize for ExplainAnalyzeCategoriesNode { struct_ser.serialize_field("all", &self.all)?; } if !self.only.is_empty() { - let v = self.only.iter().cloned().map(|v| { + let v = self.only.iter().copied().map(|v| { MetricCategory::try_from(v) .map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", v))) }).collect::, _>>()?; diff --git a/datafusion/sql/src/expr/subquery.rs b/datafusion/sql/src/expr/subquery.rs index 662c44f6f2620..fb0b1207d69cf 100644 --- a/datafusion/sql/src/expr/subquery.rs +++ b/datafusion/sql/src/expr/subquery.rs @@ -149,7 +149,7 @@ impl SqlToRel<'_, S> { error_message: &str, help_message: &str, ) -> Diagnostic { - let full_span = Span::union_iter(spans.0.iter().cloned()); + let full_span = Span::union_iter(spans.0.iter().copied()); let mut diagnostic = Diagnostic::new_error(error_message, full_span); for (i, span) in spans.iter().skip(1).enumerate() { diff --git a/datafusion/sql/src/unparser/plan.rs b/datafusion/sql/src/unparser/plan.rs index e5a367f9ef76a..374095b29c867 100644 --- a/datafusion/sql/src/unparser/plan.rs +++ b/datafusion/sql/src/unparser/plan.rs @@ -2212,7 +2212,7 @@ impl Unparser<'_> { } else { let project_columns = project_vec .iter() - .cloned() + .copied() .map(|i| { let schema = table_scan.source.schema(); let field = schema.field(i); diff --git a/test-utils/src/array_gen/primitive.rs b/test-utils/src/array_gen/primitive.rs index 5944879600cb0..5b4339d873322 100644 --- a/test-utils/src/array_gen/primitive.rs +++ b/test-utils/src/array_gen/primitive.rs @@ -110,7 +110,7 @@ impl PrimitiveArrayGenerator { let mut timezone_options: Vec> = vec![None]; timezone_options.extend(TZ_VARIANTS.iter().map(Some)); - let selected_option = timezone_options.choose(&mut rng).cloned().flatten(); // random timezone/None + let selected_option = timezone_options.choose(&mut rng).copied().flatten(); // random timezone/None selected_option.map(|tz| Arc::from(tz.name())) } From 276c3026f94a8112244ecb7ef6e34a953259bf31 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 21 Aug 2026 18:57:49 +0200 Subject: [PATCH 8/9] Enable clippy lint `unnecessary_semicolon` Drop semicolons after `match`/`if` expressions in tail position. Applied with `cargo clippy --fix`. Co-Authored-By: Claude Fable 5 --- Cargo.toml | 1 - benchmarks/src/imdb/mod.rs | 2 +- benchmarks/src/tpcds/run.rs | 2 +- benchmarks/src/tpch/mod.rs | 2 +- benchmarks/src/util/run.rs | 2 +- datafusion-cli/src/catalog.rs | 2 +- datafusion-cli/src/functions.rs | 2 +- datafusion-cli/src/main.rs | 4 ++-- datafusion-cli/src/print_options.rs | 2 +- datafusion/catalog-listing/src/table.rs | 2 +- .../catalog/src/dynamic_file/catalog.rs | 2 +- datafusion/common/src/config.rs | 4 ++-- datafusion/common/src/error.rs | 2 +- .../common/src/file_options/parquet_writer.rs | 6 +++--- datafusion/common/src/scalar/mod.rs | 4 ++-- .../src/datasource/file_format/parquet.rs | 2 +- datafusion/core/src/datasource/memory_test.rs | 2 +- datafusion/core/src/execution/context/mod.rs | 4 ++-- .../core/src/execution/session_state.rs | 4 ++-- .../src/execution/session_state_defaults.rs | 2 +- datafusion/core/src/physical_planner.rs | 2 +- datafusion/core/src/test_util/parquet.rs | 2 +- datafusion/core/tests/catalog/memory.rs | 2 +- datafusion/core/tests/fifo/mod.rs | 2 +- datafusion/core/tests/memory_limit/mod.rs | 2 +- .../core/tests/parquet/filter_pushdown.rs | 4 ++-- .../enforce_distribution.rs | 4 ++-- .../physical_optimizer/enforce_sorting.rs | 4 ++-- .../physical_optimizer/join_selection.rs | 2 +- .../physical_optimizer/projection_pushdown.rs | 2 +- datafusion/core/tests/tracing/mod.rs | 2 +- .../tests/user_defined/user_defined_plan.rs | 2 +- .../datasource-parquet/src/page_filter.rs | 2 +- datafusion/datasource-parquet/src/source.rs | 2 +- datafusion/datasource/src/decoder.rs | 2 +- datafusion/datasource/src/file_stream/mod.rs | 2 +- datafusion/datasource/src/statistics.rs | 2 +- .../datasource/src/write/orchestration.rs | 2 +- datafusion/execution/src/cache/lru_queue.rs | 2 +- datafusion/execution/src/memory_pool/mod.rs | 2 +- datafusion/expr-common/src/statistics.rs | 2 +- .../expr-common/src/type_coercion/binary.rs | 4 ++-- datafusion/expr/src/expr.rs | 6 +++--- datafusion/expr/src/logical_plan/display.rs | 8 ++++---- .../expr/src/logical_plan/invariants.rs | 4 ++-- datafusion/expr/src/logical_plan/plan.rs | 8 ++++---- .../expr/src/type_coercion/functions.rs | 4 ++-- datafusion/expr/src/udaf.rs | 10 +++++----- datafusion/expr/src/window_frame.rs | 2 +- datafusion/expr/src/window_state.rs | 2 +- .../ffi/src/config/extension_options.rs | 2 +- .../ffi/src/proto/logical_extension_codec.rs | 2 +- .../ffi/src/proto/physical_extension_codec.rs | 2 +- .../src/aggregate/count_distinct/bytes.rs | 4 ++-- .../src/aggregate/count_distinct/native.rs | 12 +++++------ .../src/min_max/min_max_bytes.rs | 2 +- datafusion/functions-nested/src/array_has.rs | 2 +- datafusion/functions-nested/src/range.rs | 2 +- datafusion/functions-nested/src/resize.rs | 2 +- .../functions-table/src/generate_series.rs | 2 +- datafusion/functions/src/datetime/common.rs | 2 +- .../functions/src/datetime/to_timestamp.rs | 4 ++-- datafusion/functions/src/math/log.rs | 2 +- datafusion/functions/src/regex/mod.rs | 20 +++++++++---------- .../functions/src/regex/regexpreplace.rs | 4 ++-- .../optimizer/src/eliminate_cross_join.rs | 6 +++--- .../optimizer/src/optimize_projections/mod.rs | 2 +- datafusion/optimizer/src/push_down_filter.rs | 2 +- .../simplify_expressions/linear_aggregates.rs | 2 +- .../src/simplify_expressions/regex.rs | 2 +- .../src/simplify_expressions/unwrap_cast.rs | 2 +- .../physical-expr-common/src/binary_map.rs | 2 +- .../src/binary_view_map.rs | 2 +- .../physical-expr-common/src/metrics/mod.rs | 4 ++-- datafusion/physical-expr/src/analysis.rs | 2 +- .../src/equivalence/properties/dependency.rs | 2 +- .../physical-expr/src/window/window_expr.rs | 4 ++-- .../enforce_distribution.rs | 4 ++-- .../enforce_sorting/mod.rs | 2 +- .../replace_with_order_preserving_variants.rs | 2 +- .../enforce_sorting/sort_pushdown.rs | 2 +- .../group_values/multi_group_by/bytes.rs | 4 ++-- .../src/aggregates/grouped_hash_stream.rs | 6 +++--- .../physical-plan/src/aggregates/mod.rs | 6 +++--- .../physical-plan/src/aggregates/order/mod.rs | 2 +- .../src/aggregates/topk/priority_map.rs | 2 +- datafusion/physical-plan/src/buffer.rs | 2 +- .../physical-plan/src/coalesce_batches.rs | 4 ++-- .../src/joins/hash_join/stream.rs | 4 ++-- .../piecewise_merge_join/classic_join.rs | 4 ++-- .../sort_merge_join/materializing_stream.rs | 2 +- datafusion/physical-plan/src/joins/utils.rs | 6 +++--- datafusion/physical-plan/src/projection.rs | 2 +- .../physical-plan/src/sorts/partial_sort.rs | 2 +- .../src/sorts/sort_preserving_merge.rs | 4 ++-- datafusion/physical-plan/src/stream.rs | 2 +- datafusion/physical-plan/src/topk/mod.rs | 2 +- .../src/windows/bounded_window_agg_exec.rs | 2 +- datafusion/physical-plan/src/windows/mod.rs | 4 ++-- .../proto/src/logical_plan/from_proto.rs | 2 +- .../src/function/string/format_string.rs | 4 ++-- .../spark/src/function/url/parse_url.rs | 2 +- datafusion/sql/src/parser.rs | 2 +- datafusion/sql/src/planner.rs | 2 +- datafusion/sql/src/statement.rs | 8 ++++---- datafusion/sql/src/unparser/plan.rs | 10 +++++----- datafusion/sql/src/unparser/rewrite.rs | 2 +- datafusion/sql/src/unparser/utils.rs | 2 +- .../src/engines/postgres_engine/mod.rs | 2 +- datafusion/sqllogictest/src/test_context.rs | 2 +- .../src/logical_plan/consumer/expr/mod.rs | 4 ++-- .../consumer/rel/aggregate_rel.rs | 2 +- .../substrait/src/physical_plan/consumer.rs | 2 +- datafusion/substrait/tests/utils.rs | 10 +++++----- 114 files changed, 185 insertions(+), 186 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7982d37a5021d..bb990ab8de691 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -318,7 +318,6 @@ too_many_lines = "allow" # 484 hits trivially_copy_pass_by_ref = "allow" # 74 hits unicode_not_nfc = "allow" # 2 hits unnecessary_literal_bound = "allow" # 471 hits -unnecessary_semicolon = "allow" # 185 hits unnecessary_trailing_comma = "allow" # 49 hits unnecessary_wraps = "allow" # 427 hits unnested_or_patterns = "allow" # 68 hits diff --git a/benchmarks/src/imdb/mod.rs b/benchmarks/src/imdb/mod.rs index 87462bc3e81ba..b742ebb32afc5 100644 --- a/benchmarks/src/imdb/mod.rs +++ b/benchmarks/src/imdb/mod.rs @@ -233,7 +233,7 @@ pub fn get_query_sql(query: &str) -> Result> { .collect()); } Err(e) => errors.push(format!("{filename}: {e}")), - }; + } } plan_err!("invalid query. Could not find query: {:?}", errors) } diff --git a/benchmarks/src/tpcds/run.rs b/benchmarks/src/tpcds/run.rs index 3eaaf172c0f16..afe867ef5ce45 100644 --- a/benchmarks/src/tpcds/run.rs +++ b/benchmarks/src/tpcds/run.rs @@ -142,7 +142,7 @@ pub fn get_query_sql(base_query_path: &str, query: usize) -> Result> .collect()); } Err(e) => errors.push(format!("{filename}: {e}")), - }; + } plan_err!("invalid query. Could not find query: {:?}", errors) } else { diff --git a/benchmarks/src/tpch/mod.rs b/benchmarks/src/tpch/mod.rs index 9f3226ed5a8f6..bc67ba4c2382c 100644 --- a/benchmarks/src/tpch/mod.rs +++ b/benchmarks/src/tpch/mod.rs @@ -209,7 +209,7 @@ pub fn get_query_sql_for_scale_factor( .collect()); } Err(e) => errors.push(format!("{filename}: {e}")), - }; + } } plan_err!("invalid query. Could not find query: {:?}", errors) } else { diff --git a/benchmarks/src/util/run.rs b/benchmarks/src/util/run.rs index 772d421bc7bf4..829566d47c9e6 100644 --- a/benchmarks/src/util/run.rs +++ b/benchmarks/src/util/run.rs @@ -231,7 +231,7 @@ impl BenchmarkRun { pub fn maybe_write_json(&self, maybe_path: Option>) -> Result<()> { if let Some(path) = maybe_path { std::fs::write(path, self.to_json())?; - }; + } Ok(()) } } diff --git a/datafusion-cli/src/catalog.rs b/datafusion-cli/src/catalog.rs index 185dfb6b08006..ca24da7873bc1 100644 --- a/datafusion-cli/src/catalog.rs +++ b/datafusion-cli/src/catalog.rs @@ -180,7 +180,7 @@ impl SchemaProvider for DynamicObjectStoreSchemaProvider { } } _ => {} - }; + } state = builder.build(); let store = get_object_store( &state, diff --git a/datafusion-cli/src/functions.rs b/datafusion-cli/src/functions.rs index 657be4268d67b..0d7d8f33738fa 100644 --- a/datafusion-cli/src/functions.rs +++ b/datafusion-cli/src/functions.rs @@ -416,7 +416,7 @@ impl TableFunctionImpl for ParquetMetadataFunc { stats_distinct_count_arr.push(None); stats_min_value_arr.push(None); stats_max_value_arr.push(None); - }; + } compression_arr.push(format!("{:?}", column.compression())); // need to collect into Vec to format let encodings: Vec<_> = column.encodings().collect(); diff --git a/datafusion-cli/src/main.rs b/datafusion-cli/src/main.rs index 4be6058aef8b6..f82206a5bd184 100644 --- a/datafusion-cli/src/main.rs +++ b/datafusion-cli/src/main.rs @@ -208,7 +208,7 @@ async fn main_inner() -> Result<()> { if let Some(ref path) = args.data_path { let p = Path::new(path); env::set_current_dir(p).unwrap(); - }; + } let session_config = get_session_config(&args)?; @@ -353,7 +353,7 @@ fn get_session_config(args: &Args) -> Result { } config_options.execution.batch_size = datafusion_common::config::ConfigNonZeroUsize::try_new(batch_size)?; - }; + } // use easier to understand "tree" mode by default // if the user hasn't specified an explain format in the environment diff --git a/datafusion-cli/src/print_options.rs b/datafusion-cli/src/print_options.rs index d0810cb034df1..5367b5e65c0fb 100644 --- a/datafusion-cli/src/print_options.rs +++ b/datafusion-cli/src/print_options.rs @@ -151,7 +151,7 @@ impl PrintOptions { return Err(DataFusionError::External( "PrintFormat::Table is not implemented".to_string().into(), )); - }; + } let stdout = io::stdout(); let mut writer = stdout.lock(); diff --git a/datafusion/catalog-listing/src/table.rs b/datafusion/catalog-listing/src/table.rs index 7f5d38b9991d5..eb5480dde6944 100644 --- a/datafusion/catalog-listing/src/table.rs +++ b/datafusion/catalog-listing/src/table.rs @@ -673,7 +673,7 @@ impl ListingTable { } } None => {} // no ordering required - }; + } let output_partitioning = if let Some(output_partitioning) = declared_output_partitioning diff --git a/datafusion/catalog/src/dynamic_file/catalog.rs b/datafusion/catalog/src/dynamic_file/catalog.rs index f93bd35cd7f0a..4437d99667547 100644 --- a/datafusion/catalog/src/dynamic_file/catalog.rs +++ b/datafusion/catalog/src/dynamic_file/catalog.rs @@ -138,7 +138,7 @@ impl SchemaProvider for DynamicFileSchemaProvider { ) -> datafusion_common::Result>> { if let Some(table) = self.inner.table(name).await? { return Ok(Some(table)); - }; + } self.factory.try_new(name).await } diff --git a/datafusion/common/src/config.rs b/datafusion/common/src/config.rs index f5742f09f9b08..c46d0ada0c6e6 100644 --- a/datafusion/common/src/config.rs +++ b/datafusion/common/src/config.rs @@ -3283,7 +3283,7 @@ impl ConfigField for ConfigFileEncryptionProperties { if key.contains("::") { // Handle any column specific properties return self.column_encryption_properties.set(key, value); - }; + } let (key, rem) = key.split_once('.').unwrap_or((key, "")); match key { @@ -3463,7 +3463,7 @@ impl ConfigField for ConfigFileDecryptionProperties { if key.contains("::") { // Handle any column specific properties return self.column_decryption_properties.set(key, value); - }; + } let (key, rem) = key.split_once('.').unwrap_or((key, "")); match key { diff --git a/datafusion/common/src/error.rs b/datafusion/common/src/error.rs index 02016387c0a96..d1fcb50f73492 100644 --- a/datafusion/common/src/error.rs +++ b/datafusion/common/src/error.rs @@ -1311,7 +1311,7 @@ mod test { match std::env::var("RUST_BACKTRACE") { Ok(val) if val == "1" => {} _ => panic!("Environment variable RUST_BACKTRACE must be set to 1"), - }; + } } // To pass the test the environment variable RUST_BACKTRACE should be set to 1 to enforce backtrace diff --git a/datafusion/common/src/file_options/parquet_writer.rs b/datafusion/common/src/file_options/parquet_writer.rs index 2121be904217e..78c14da960b00 100644 --- a/datafusion/common/src/file_options/parquet_writer.rs +++ b/datafusion/common/src/file_options/parquet_writer.rs @@ -272,13 +272,13 @@ impl ParquetOptions { if let Some(bloom_filter_fpp) = bloom_filter_fpp { builder = builder.set_bloom_filter_fpp(*bloom_filter_fpp); - }; + } if let Some(bloom_filter_ndv) = bloom_filter_ndv { builder = builder.set_bloom_filter_max_ndv(*bloom_filter_ndv); - }; + } if let Some(dictionary_enabled) = dictionary_enabled { builder = builder.set_dictionary_enabled(*dictionary_enabled); - }; + } // We do not have access to default ColumnProperties set in Arrow. // Therefore, only overwrite if these settings exist. diff --git a/datafusion/common/src/scalar/mod.rs b/datafusion/common/src/scalar/mod.rs index fde5c605d5694..2b0ddbded8b67 100644 --- a/datafusion/common/src/scalar/mod.rs +++ b/datafusion/common/src/scalar/mod.rs @@ -5728,7 +5728,7 @@ impl fmt::Display for ScalarValue { ScalarValue::Dictionary(_k, v) => write!(f, "{v}")?, ScalarValue::RunEndEncoded(_, _, v) => write!(f, "{v}")?, ScalarValue::Null => write!(f, "NULL")?, - }; + } Ok(()) } } @@ -9833,7 +9833,7 @@ mod tests { let timestamp2 = ts1.sub(intervals[idx].clone()).unwrap(); let back = timestamp2.add(intervals[idx].clone()).unwrap(); assert_eq!(ts1, &back); - }; + } } } diff --git a/datafusion/core/src/datasource/file_format/parquet.rs b/datafusion/core/src/datasource/file_format/parquet.rs index bbd9d0937ad83..bfcfb74848861 100644 --- a/datafusion/core/src/datasource/file_format/parquet.rs +++ b/datafusion/core/src/datasource/file_format/parquet.rs @@ -91,7 +91,7 @@ pub(crate) mod test_util { write_in_chunks(&mut writer, &batch, ROWS_PER_PAGE); } else { writer.write(&batch).expect("Writing batch"); - }; + } writer.close().unwrap(); output }) diff --git a/datafusion/core/src/datasource/memory_test.rs b/datafusion/core/src/datasource/memory_test.rs index 9e37f77d8b49c..cc5ad539dae71 100644 --- a/datafusion/core/src/datasource/memory_test.rs +++ b/datafusion/core/src/datasource/memory_test.rs @@ -191,7 +191,7 @@ mod tests { _ => panic!("unexpected error"), }, res => panic!("Scan should failed on invalid projection, got {res:?}"), - }; + } Ok(()) } diff --git a/datafusion/core/src/execution/context/mod.rs b/datafusion/core/src/execution/context/mod.rs index 78497604da56c..ff1ad25811440 100644 --- a/datafusion/core/src/execution/context/mod.rs +++ b/datafusion/core/src/execution/context/mod.rs @@ -1256,7 +1256,7 @@ impl SessionContext { builder.with_max_spill_merge_fan_in(DEFAULT_MAX_SPILL_MERGE_FAN_IN); } _ => return plan_err!("Unknown runtime configuration: {variable}"), - }; + } *state = SessionStateBuilder::from(state.clone()) .with_runtime_env(Arc::new(builder.build()?)) .build(); @@ -1517,7 +1517,7 @@ impl SessionContext { self.state.write().register_higher_order_function(f)?; } RegisterFunction::Table(name, f) => self.register_udtf(&name, f), - }; + } self.return_empty_dataframe() } diff --git a/datafusion/core/src/execution/session_state.rs b/datafusion/core/src/execution/session_state.rs index 0c2e561cd49a0..3c34e06cebc10 100644 --- a/datafusion/core/src/execution/session_state.rs +++ b/datafusion/core/src/execution/session_state.rs @@ -954,7 +954,7 @@ impl SessionState { "File type already registered for extension {ext}. Set overwrite to true to replace this extension." ); } - }; + } Ok(()) } @@ -1667,7 +1667,7 @@ impl SessionStateBuilder { for file_format in file_formats { if let Err(e) = state.register_file_format(file_format, false) { info!("Unable to register file format: {e}") - }; + } } } diff --git a/datafusion/core/src/execution/session_state_defaults.rs b/datafusion/core/src/execution/session_state_defaults.rs index 3b46ed2523329..59d3c440c7865 100644 --- a/datafusion/core/src/execution/session_state_defaults.rs +++ b/datafusion/core/src/execution/session_state_defaults.rs @@ -234,7 +234,7 @@ impl SessionStateDefaults { for format in formats { if let Err(e) = state.register_file_format(format, false) { log::info!("Unable to register default file format: {e}") - }; + } } } } diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs index 6648658bdee50..bd00927619220 100644 --- a/datafusion/core/src/physical_planner.rs +++ b/datafusion/core/src/physical_planner.rs @@ -2707,7 +2707,7 @@ impl DefaultPhysicalPlanner { e.plan.display_graphviz().to_string(), )); } - }; + } if !stringified_plans.is_empty() { return Ok(Arc::new(ExplainExec::new( diff --git a/datafusion/core/src/test_util/parquet.rs b/datafusion/core/src/test_util/parquet.rs index e25fe746695cf..31cab41f686cf 100644 --- a/datafusion/core/src/test_util/parquet.rs +++ b/datafusion/core/src/test_util/parquet.rs @@ -114,7 +114,7 @@ impl TestParquetFile { .strip_prefix("//?/") .unwrap() .into(); - }; + } let object_store_url = ListingTableUrl::parse(canonical_path.to_str().unwrap_or_default())? diff --git a/datafusion/core/tests/catalog/memory.rs b/datafusion/core/tests/catalog/memory.rs index b49183e92e387..0b5e5fdbc5e8f 100644 --- a/datafusion/core/tests/catalog/memory.rs +++ b/datafusion/core/tests/catalog/memory.rs @@ -100,7 +100,7 @@ fn default_register_schema_not_supported() { e.strip_backtrace(), "This feature is not implemented: Registering new schemas is not supported" ), - }; + } } #[tokio::test] diff --git a/datafusion/core/tests/fifo/mod.rs b/datafusion/core/tests/fifo/mod.rs index 3d99cc72fa590..edaee514d61d8 100644 --- a/datafusion/core/tests/fifo/mod.rs +++ b/datafusion/core/tests/fifo/mod.rs @@ -311,7 +311,7 @@ mod unix_test { left += 1; } else { right += 1; - }; + } } futures::future::try_join_all(tasks).await.unwrap(); diff --git a/datafusion/core/tests/memory_limit/mod.rs b/datafusion/core/tests/memory_limit/mod.rs index bf52c4ab0f879..2daf4fb0e0210 100644 --- a/datafusion/core/tests/memory_limit/mod.rs +++ b/datafusion/core/tests/memory_limit/mod.rs @@ -907,7 +907,7 @@ impl TestCase { if let Some(pool) = memory_pool { builder = builder.with_memory_pool(pool); - }; + } let runtime = builder.build_arc().unwrap(); // Configure execution diff --git a/datafusion/core/tests/parquet/filter_pushdown.rs b/datafusion/core/tests/parquet/filter_pushdown.rs index dabb2f35b24b1..5754d6a61b072 100644 --- a/datafusion/core/tests/parquet/filter_pushdown.rs +++ b/datafusion/core/tests/parquet/filter_pushdown.rs @@ -559,7 +559,7 @@ impl<'a> TestCase<'a> { self.name ); } - }; + } let (page_index_rows_pruned, page_index_rows_matched) = get_pruning_metrics(&metrics, "page_index_rows_pruned"); @@ -584,7 +584,7 @@ impl<'a> TestCase<'a> { "Expected to filter rows via page index but none were", ); } - }; + } batch } diff --git a/datafusion/core/tests/physical_optimizer/enforce_distribution.rs b/datafusion/core/tests/physical_optimizer/enforce_distribution.rs index 2dbacf1d898ac..f58c5458cee84 100644 --- a/datafusion/core/tests/physical_optimizer/enforce_distribution.rs +++ b/datafusion/core/tests/physical_optimizer/enforce_distribution.rs @@ -1388,7 +1388,7 @@ fn multi_hash_joins() -> Result<()> { DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet "); }, - }; + } let plan_sort = test_config.to_plan(top_join, &SORT_DISTRIB_DISTRIB); @@ -1457,7 +1457,7 @@ fn multi_hash_joins() -> Result<()> { "); }, - }; + } let plan_sort = test_config.to_plan(top_join, &SORT_DISTRIB_DISTRIB); diff --git a/datafusion/core/tests/physical_optimizer/enforce_sorting.rs b/datafusion/core/tests/physical_optimizer/enforce_sorting.rs index a8162f137ed0a..82543dce2b57b 100644 --- a/datafusion/core/tests/physical_optimizer/enforce_sorting.rs +++ b/datafusion/core/tests/physical_optimizer/enforce_sorting.rs @@ -1431,7 +1431,7 @@ async fn test_sort_merge_join_order_by_left() -> Result<()> { DataSourceExec: file_groups={1 group: [[x]]}, projection=[col_a, col_b], file_type=parquet "); } - }; + } }) } } @@ -1543,7 +1543,7 @@ async fn test_sort_merge_join_order_by_right() -> Result<()> { DataSourceExec: file_groups={1 group: [[x]]}, projection=[col_a, col_b], file_type=parquet "); } - }; + } }) } } diff --git a/datafusion/core/tests/physical_optimizer/join_selection.rs b/datafusion/core/tests/physical_optimizer/join_selection.rs index 63654ae048863..f83ce98039782 100644 --- a/datafusion/core/tests/physical_optimizer/join_selection.rs +++ b/datafusion/core/tests/physical_optimizer/join_selection.rs @@ -1886,6 +1886,6 @@ fn test_join_with_maybe_swap_unbounded_case(t: TestCase) -> Result<()> { t.expecting_swap ) ); - }; + } Ok(()) } diff --git a/datafusion/core/tests/physical_optimizer/projection_pushdown.rs b/datafusion/core/tests/physical_optimizer/projection_pushdown.rs index 113552c462f76..72641e945790f 100644 --- a/datafusion/core/tests/physical_optimizer/projection_pushdown.rs +++ b/datafusion/core/tests/physical_optimizer/projection_pushdown.rs @@ -812,7 +812,7 @@ fn test_output_req_after_projection() -> Result<()> { ); } else { panic!("Expected KeyPartitioned distribution!"); - }; + } Ok(()) } diff --git a/datafusion/core/tests/tracing/mod.rs b/datafusion/core/tests/tracing/mod.rs index 0b66a49eea9f4..9f72c2c66f4cd 100644 --- a/datafusion/core/tests/tracing/mod.rs +++ b/datafusion/core/tests/tracing/mod.rs @@ -60,7 +60,7 @@ async fn test_tracer_injection() { info!("Caught expected panic: {e}"); } else { panic!("Expected the task to panic, but it completed successfully"); - }; + } // Initialize the asserting tracer and run the query. info!("Initializing tracer and re-running query"); diff --git a/datafusion/core/tests/user_defined/user_defined_plan.rs b/datafusion/core/tests/user_defined/user_defined_plan.rs index da7fdd88793e3..a1a8e3aa148cd 100644 --- a/datafusion/core/tests/user_defined/user_defined_plan.rs +++ b/datafusion/core/tests/user_defined/user_defined_plan.rs @@ -453,7 +453,7 @@ impl OptimizerRule for OptimizerMakeExtensionNodeInvalid { }), }), }))); - }; + } Ok(Transformed::no(plan)) } diff --git a/datafusion/datasource-parquet/src/page_filter.rs b/datafusion/datasource-parquet/src/page_filter.rs index 6bc1aca667981..2a3d463509929 100644 --- a/datafusion/datasource-parquet/src/page_filter.rs +++ b/datafusion/datasource-parquet/src/page_filter.rs @@ -223,7 +223,7 @@ impl PagePruningAccessPlanFilter { parquet_metadata.column_index().is_some() ); return PagePruningResult::new(access_plan, 0); - }; + } // track the total number of rows that should be skipped let mut total_skip = 0; diff --git a/datafusion/datasource-parquet/src/source.rs b/datafusion/datasource-parquet/src/source.rs index c5506dd449681..1dc103501c15f 100644 --- a/datafusion/datasource-parquet/src/source.rs +++ b/datafusion/datasource-parquet/src/source.rs @@ -806,7 +806,7 @@ impl FileSource for ParquetSource { guarantees.join(", ") )?; } - }; + } Ok(()) } DisplayFormatType::TreeRender => { diff --git a/datafusion/datasource/src/decoder.rs b/datafusion/datasource/src/decoder.rs index 9f9fc0d94bb1c..a21aaedc52c3a 100644 --- a/datafusion/datasource/src/decoder.rs +++ b/datafusion/datasource/src/decoder.rs @@ -180,7 +180,7 @@ pub fn deserialize_stream<'a>( match ready!(input.poll_next_unpin(cx)).transpose()? { Some(b) => _ = deserializer.digest(b), None => deserializer.finish(), - }; + } return match deserializer.next()? { DeserializerOutput::RecordBatch(rb) => Poll::Ready(Some(Ok(rb))), diff --git a/datafusion/datasource/src/file_stream/mod.rs b/datafusion/datasource/src/file_stream/mod.rs index 93595cb355a47..619d2cf2ef479 100644 --- a/datafusion/datasource/src/file_stream/mod.rs +++ b/datafusion/datasource/src/file_stream/mod.rs @@ -85,7 +85,7 @@ impl FileStream { FileStreamState::Error | FileStreamState::Done => { // no effect as there are no more files to process } - }; + } self } diff --git a/datafusion/datasource/src/statistics.rs b/datafusion/datasource/src/statistics.rs index 421882302600c..8b749e80bebc8 100644 --- a/datafusion/datasource/src/statistics.rs +++ b/datafusion/datasource/src/statistics.rs @@ -443,7 +443,7 @@ pub async fn get_statistics_with_limit( } } } - }; + } let mut statistics = summary_statistics; if all_files.next().await.is_some() { diff --git a/datafusion/datasource/src/write/orchestration.rs b/datafusion/datasource/src/write/orchestration.rs index f75671d950353..cd821b3b87897 100644 --- a/datafusion/datasource/src/write/orchestration.rs +++ b/datafusion/datasource/src/write/orchestration.rs @@ -122,7 +122,7 @@ pub(crate) async fn serialize_rb_stream_to_object_store( exec_datafusion_err!("Error writing to object store: {e}"), ); } - }; + } row_count += cnt; } Ok(Err(e)) => { diff --git a/datafusion/execution/src/cache/lru_queue.rs b/datafusion/execution/src/cache/lru_queue.rs index a19f13865fd3d..96e33df212200 100644 --- a/datafusion/execution/src/cache/lru_queue.rs +++ b/datafusion/execution/src/cache/lru_queue.rs @@ -184,7 +184,7 @@ impl LruQueue { n_strong.lock().prev = Some(Weak::clone(p)); p_strong.lock().next = Some(Weak::clone(n)); } - }; + } Some(old_value) } else { None diff --git a/datafusion/execution/src/memory_pool/mod.rs b/datafusion/execution/src/memory_pool/mod.rs index 40a79d136b84e..c7c40969f149d 100644 --- a/datafusion/execution/src/memory_pool/mod.rs +++ b/datafusion/execution/src/memory_pool/mod.rs @@ -457,7 +457,7 @@ impl MemoryReservation { self.try_shrink(size - capacity)?; } _ => {} - }; + } Ok(()) } diff --git a/datafusion/expr-common/src/statistics.rs b/datafusion/expr-common/src/statistics.rs index 034358b043135..6e4d700552f4e 100644 --- a/datafusion/expr-common/src/statistics.rs +++ b/datafusion/expr-common/src/statistics.rs @@ -753,7 +753,7 @@ pub fn create_bernoulli_from_comparison( &p_value, |lhs, rhs| lhs.sub_checked(rhs), )?; - }; + } return Distribution::new_bernoulli(p_value); } } else if op == &Operator::Eq { diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rs index 77ef1f59f7bb8..381897ae86fdc 100644 --- a/datafusion/expr-common/src/type_coercion/binary.rs +++ b/datafusion/expr-common/src/type_coercion/binary.rs @@ -1051,7 +1051,7 @@ pub fn binary_numeric_coercion( ) -> Option { if !lhs_type.is_numeric() || !rhs_type.is_numeric() { return None; - }; + } // same type => all good if lhs_type == rhs_type { @@ -1484,7 +1484,7 @@ fn mathematics_numerical_coercion( // Error on any non-numeric type if !both_numeric_or_null_and_numeric(lhs_type, rhs_type) { return None; - }; + } // These are ordered from most informative to least informative so // that the coercion removes the least amount of information diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs index f9c0662e682e8..647e576b122fa 100644 --- a/datafusion/expr/src/expr.rs +++ b/datafusion/expr/src/expr.rs @@ -2929,7 +2929,7 @@ impl HashNode for Expr { name.hash(state); field.hash(state); } - }; + } } } @@ -2952,7 +2952,7 @@ fn rewrite_placeholder(expr: &mut Expr, other: &Expr, schema: &DFSchema) -> Resu *field = Some(other_field.as_ref().clone().with_nullable(true).into()); } } - }; + } Ok(()) } @@ -3262,7 +3262,7 @@ impl Display for SchemaDisplay<'_> { " ORDER BY [{}]", schema_name_from_sorts(order_by)? )?; - }; + } write!(f, " {window_frame}") } diff --git a/datafusion/expr/src/logical_plan/display.rs b/datafusion/expr/src/logical_plan/display.rs index 09f41c94f64fa..4afbb5670294a 100644 --- a/datafusion/expr/src/logical_plan/display.rs +++ b/datafusion/expr/src/logical_plan/display.rs @@ -380,7 +380,7 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> { if !full_filter.is_empty() { object["Full Filters"] = serde_json::Value::String(expr_vec_fmt!(full_filter)); - }; + } if !partial_filter.is_empty() { object["Partial Filters"] = serde_json::Value::String(expr_vec_fmt!(partial_filter)); @@ -550,10 +550,10 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> { ); if let Some(s) = skip { object["Skip"] = s.to_string().into() - }; + } if let Some(f) = fetch { object["Fetch"] = f.to_string().into() - }; + } object } LogicalPlan::Subquery(Subquery { .. }) => { @@ -673,7 +673,7 @@ impl<'n> TreeNodeVisitor<'n> for PgJsonVisitor<'_, '_> { .map(serde_json::Value::String) .collect(), ); - }; + } self.objects.insert(id, object); self.parent_ids.push(id); diff --git a/datafusion/expr/src/logical_plan/invariants.rs b/datafusion/expr/src/logical_plan/invariants.rs index f36653694c21d..070a81f41b2a6 100644 --- a/datafusion/expr/src/logical_plan/invariants.rs +++ b/datafusion/expr/src/logical_plan/invariants.rs @@ -86,7 +86,7 @@ fn assert_valid_extension_nodes(plan: &LogicalPlan, check: InvariantLevel) -> Re assert_valid_extension_nodes(&subquery.subquery, check)?; } _ => {} - }; + } Ok(TreeNodeRecursion::Continue) }) }) @@ -139,7 +139,7 @@ fn assert_subqueries_are_valid(plan: &LogicalPlan) -> Result<()> { check_subquery_expr(plan, &subquery.subquery, expr)?; } _ => {} - }; + } Ok(TreeNodeRecursion::Continue) }) }) diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index ab3c26795e74a..9b79b608e3d00 100644 --- a/datafusion/expr/src/logical_plan/plan.rs +++ b/datafusion/expr/src/logical_plan/plan.rs @@ -2071,7 +2071,7 @@ impl LogicalPlan { ", full_filters=[{}]", expr_vec_fmt!(full_filter) )?; - }; + } if !partial_filter.is_empty() { write!( f, @@ -4855,7 +4855,7 @@ impl Unnest { )); } _ => {} - }; + } } // new columns dependent on the same original index @@ -4946,7 +4946,7 @@ fn get_unnested_columns( _ => { return internal_err!("trying to unnest on invalid data type {data_type}"); } - }; + } Ok(qualified_columns) } @@ -4968,7 +4968,7 @@ fn get_unnested_list_datatype_recursive( return get_unnested_list_datatype_recursive(field.data_type(), depth - 1); } _ => {} - }; + } internal_err!("trying to unnest on invalid data type {data_type}") } diff --git a/datafusion/expr/src/type_coercion/functions.rs b/datafusion/expr/src/type_coercion/functions.rs index ec3ab6f441827..781559ddd0c5c 100644 --- a/datafusion/expr/src/type_coercion/functions.rs +++ b/datafusion/expr/src/type_coercion/functions.rs @@ -365,7 +365,7 @@ pub fn value_fields_with_higher_order_udf_and_lambdas( ValueOrLambda::Lambda(_) => {} } } - }; + } Ok(new_fields) } @@ -688,7 +688,7 @@ fn get_valid_types( if !fixed_size { list_sizes.clear() - }; + } let mut list_sizes = list_sizes.into_iter(); let valid_types = arguments diff --git a/datafusion/expr/src/udaf.rs b/datafusion/expr/src/udaf.rs index 54957c273abcc..1d943ef5891d1 100644 --- a/datafusion/expr/src/udaf.rs +++ b/datafusion/expr/src/udaf.rs @@ -979,7 +979,7 @@ pub fn udaf_default_schema_name( if let Some(filter) = filter { schema_name.write_fmt(format_args!(" FILTER (WHERE {filter})"))?; - }; + } if !order_by.is_empty() { let clause = match func.supports_within_group_clause() { @@ -992,7 +992,7 @@ pub fn udaf_default_schema_name( clause, schema_name_from_sorts(order_by)? ))?; - }; + } Ok(schema_name) } @@ -1025,14 +1025,14 @@ pub fn udaf_default_human_display( if let Some(filter) = filter { schema_name.write_fmt(format_args!(" FILTER (WHERE {filter})"))?; - }; + } if !order_by.is_empty() { schema_name.write_fmt(format_args!( " ORDER BY [{}]", schema_name_from_sorts(order_by)? ))?; - }; + } Ok(schema_name) } @@ -1187,7 +1187,7 @@ pub fn udaf_default_window_function_display_name( if !order_by.is_empty() { display_name .write_fmt(format_args!(" ORDER BY [{}]", expr_vec_fmt!(order_by)))?; - }; + } display_name.write_fmt(format_args!( " {} BETWEEN {} AND {}", diff --git a/datafusion/expr/src/window_frame.rs b/datafusion/expr/src/window_frame.rs index d9db35875ab1e..fa507a0618ca0 100644 --- a/datafusion/expr/src/window_frame.rs +++ b/datafusion/expr/src/window_frame.rs @@ -135,7 +135,7 @@ impl TryFrom for WindowFrame { && val.is_null() { plan_err!("Invalid window frame: end bound cannot be UNBOUNDED PRECEDING")? - }; + } let units = value.units.into(); Ok(Self::new_bounds(units, start_bound, end_bound)) diff --git a/datafusion/expr/src/window_state.rs b/datafusion/expr/src/window_state.rs index b4d3d09069b14..9cffe2abf1ee5 100644 --- a/datafusion/expr/src/window_state.rs +++ b/datafusion/expr/src/window_state.rs @@ -80,7 +80,7 @@ impl WindowAggState { state.current_group_idx -= n_group_to_del; } None => {} - }; + } } pub fn update( diff --git a/datafusion/ffi/src/config/extension_options.rs b/datafusion/ffi/src/config/extension_options.rs index a8f759470034e..139e64e999883 100644 --- a/datafusion/ffi/src/config/extension_options.rs +++ b/datafusion/ffi/src/config/extension_options.rs @@ -176,7 +176,7 @@ impl ExtensionOptions for FFI_ExtensionOptions { fn set(&mut self, key: &str, value: &str) -> Result<()> { if key.split_once('.').is_none() { return exec_err!("Unable to set FFI config value without namespace set"); - }; + } df_result!(unsafe { (self.set)(self, key.into(), value.into()) }) } diff --git a/datafusion/ffi/src/proto/logical_extension_codec.rs b/datafusion/ffi/src/proto/logical_extension_codec.rs index 08fe285fc4434..eb91aa934911b 100644 --- a/datafusion/ffi/src/proto/logical_extension_codec.rs +++ b/datafusion/ffi/src/proto/logical_extension_codec.rs @@ -566,7 +566,7 @@ mod tests { if !node.is::() { return exec_err!("TestExtensionCodec only expects MemTable"); - }; + } if node.schema() != create_test_table().schema() { return exec_err!("Unexpected schema for encoding."); diff --git a/datafusion/ffi/src/proto/physical_extension_codec.rs b/datafusion/ffi/src/proto/physical_extension_codec.rs index 97e49ca89e84e..8b3316b68481d 100644 --- a/datafusion/ffi/src/proto/physical_extension_codec.rs +++ b/datafusion/ffi/src/proto/physical_extension_codec.rs @@ -521,7 +521,7 @@ pub(crate) mod tests { let udf = node.inner(); if !udf.is::() { return exec_err!("TestExtensionCodec only expects Abs UDF"); - }; + } buf.push(Self::ABS_FUNC_SERIALIZED); diff --git a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/bytes.rs b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/bytes.rs index 6e0d55bd64372..f6df4182a879b 100644 --- a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/bytes.rs +++ b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/bytes.rs @@ -77,7 +77,7 @@ impl Accumulator for BytesDistinctCountAccumulator { arr.iter().try_for_each(|maybe_list| { if let Some(list) = maybe_list { self.0.insert(&list); - }; + } Ok(()) }) } @@ -138,7 +138,7 @@ impl Accumulator for BytesViewDistinctCountAccumulator { arr.iter().try_for_each(|maybe_list| { if let Some(list) = maybe_list { self.0.insert(&list); - }; + } Ok(()) }) } diff --git a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs index 6af7131536f04..17cccc6f2b902 100644 --- a/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs +++ b/datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs @@ -115,7 +115,7 @@ where if let Some(list) = maybe_list { let list = as_primitive_array::(&list)?; self.values.extend(list.values()) - }; + } Ok(()) }) } @@ -224,7 +224,7 @@ impl Accumulator for BoolArray256DistinctCountAccumulator { for value in list.values().iter() { self.seen[*value as usize] = true; } - }; + } Ok(()) }) } @@ -304,7 +304,7 @@ impl Accumulator for BoolArray256DistinctCountAccumulatorI8 { for value in list.values().iter() { self.seen[*value as u8 as usize] = true; } - }; + } Ok(()) }) } @@ -397,7 +397,7 @@ impl Accumulator for Bitmap65536DistinctCountAccumulator { for value in list.values().iter() { self.set_bit(*value); } - }; + } Ok(()) }) } @@ -491,7 +491,7 @@ impl Accumulator for Bitmap65536DistinctCountAccumulatorI16 { for value in list.values().iter() { self.set_bit(*value); } - }; + } Ok(()) }) } @@ -594,7 +594,7 @@ impl Accumulator for BooleanDistinctCountAccumulator { } if let Some(list) = maybe_list { self.observe(as_boolean_array(&list)?); - }; + } Ok(()) }) } diff --git a/datafusion/functions-aggregate/src/min_max/min_max_bytes.rs b/datafusion/functions-aggregate/src/min_max/min_max_bytes.rs index efeaea314c4f5..16ec40abad286 100644 --- a/datafusion/functions-aggregate/src/min_max/min_max_bytes.rs +++ b/datafusion/functions-aggregate/src/min_max/min_max_bytes.rs @@ -463,7 +463,7 @@ impl MinMaxBytesState { vacant_entry.insert(new_val); } } - }; + } } // Update self.min_max with any new min/max values we found in the input diff --git a/datafusion/functions-nested/src/array_has.rs b/datafusion/functions-nested/src/array_has.rs index bb3c2dd13fff1..82291c3381927 100644 --- a/datafusion/functions-nested/src/array_has.rs +++ b/datafusion/functions-nested/src/array_has.rs @@ -176,7 +176,7 @@ impl ScalarUDFImpl for ArrayHas { ))); } _ => {} - }; + } Ok(ExprSimplifyResult::Original(args)) } diff --git a/datafusion/functions-nested/src/range.rs b/datafusion/functions-nested/src/range.rs index 0a02a8b7bbd72..0bc013237cfda 100644 --- a/datafusion/functions-nested/src/range.rs +++ b/datafusion/functions-nested/src/range.rs @@ -338,7 +338,7 @@ impl Range { offsets.push(values.len() as i32); valid.append_null(); } - }; + } } let arr = Arc::new(ListArray::try_new( Arc::new(Field::new_list_field(DataType::Int64, true)), diff --git a/datafusion/functions-nested/src/resize.rs b/datafusion/functions-nested/src/resize.rs index e08149ec0f938..0332ea7d5d7cb 100644 --- a/datafusion/functions-nested/src/resize.rs +++ b/datafusion/functions-nested/src/resize.rs @@ -337,7 +337,7 @@ where } else { let end = start + count; mutable.try_extend(0, start.to_usize().unwrap(), end.to_usize().unwrap())?; - }; + } offsets.push(offsets[row_index] + count); } diff --git a/datafusion/functions-table/src/generate_series.rs b/datafusion/functions-table/src/generate_series.rs index 8d9327c5acfa2..1fc195c5ada17 100644 --- a/datafusion/functions-table/src/generate_series.rs +++ b/datafusion/functions-table/src/generate_series.rs @@ -620,7 +620,7 @@ impl GenerateSeriesFuncImpl { other ); } - }; + } } let schema = Arc::new(Schema::new(vec![Field::new( diff --git a/datafusion/functions/src/datetime/common.rs b/datafusion/functions/src/datetime/common.rs index 513c8d1422bcb..3807569a6b5cf 100644 --- a/datafusion/functions/src/datetime/common.rs +++ b/datafusion/functions/src/datetime/common.rs @@ -516,7 +516,7 @@ where val = Some(r); } } - }; + } val.transpose() }) diff --git a/datafusion/functions/src/datetime/to_timestamp.rs b/datafusion/functions/src/datetime/to_timestamp.rs index 0007412500afa..5d581671f38f9 100644 --- a/datafusion/functions/src/datetime/to_timestamp.rs +++ b/datafusion/functions/src/datetime/to_timestamp.rs @@ -1827,7 +1827,7 @@ mod tests { Second => { assert_eq!(sec_expected_timestamps, parsed_array.as_ref()) } - }; + } } else { panic!("Expected a columnar array") } @@ -1858,7 +1858,7 @@ mod tests { Second => { assert_eq!(sec_expected_timestamps, parsed_array.as_ref()) } - }; + } } else { panic!("Expected a columnar array") } diff --git a/datafusion/functions/src/math/log.rs b/datafusion/functions/src/math/log.rs index 732cfff6cf053..77a730808d95b 100644 --- a/datafusion/functions/src/math/log.rs +++ b/datafusion/functions/src/math/log.rs @@ -352,7 +352,7 @@ impl ScalarUDFImpl for LogFunc { return Ok(ExprSimplifyResult::Original(args)); } _ => (), - }; + } let number = args.pop().unwrap(); let number_datatype = arg_types.pop().unwrap(); diff --git a/datafusion/functions/src/regex/mod.rs b/datafusion/functions/src/regex/mod.rs index 67241712038b9..caeab9d745d81 100644 --- a/datafusion/functions/src/regex/mod.rs +++ b/datafusion/functions/src/regex/mod.rs @@ -48,11 +48,11 @@ pub mod expr_fn { let mut args = vec![values, regex]; if let Some(start) = start { args.push(start); - }; + } if let Some(flags) = flags { args.push(flags); - }; + } super::regexp_count().call(args) } @@ -61,7 +61,7 @@ pub mod expr_fn { let mut args = vec![values, regex]; if let Some(flags) = flags { args.push(flags); - }; + } super::regexp_match().call(args) } @@ -78,19 +78,19 @@ pub mod expr_fn { let mut args = vec![values, regex]; if let Some(start) = start { args.push(start); - }; + } if let Some(n) = n { args.push(n); - }; + } if let Some(endoption) = endoption { args.push(endoption); - }; + } if let Some(flags) = flags { args.push(flags); - }; + } if let Some(subexpr) = subexpr { args.push(subexpr); - }; + } super::regexp_instr().call(args) } /// Returns true if a regex has at least one match in a string, false otherwise. @@ -98,7 +98,7 @@ pub mod expr_fn { let mut args = vec![values, regex]; if let Some(flags) = flags { args.push(flags); - }; + } super::regexp_like().call(args) } @@ -112,7 +112,7 @@ pub mod expr_fn { let mut args = vec![string, pattern, replacement]; if let Some(flags) = flags { args.push(flags); - }; + } super::regexp_replace().call(args) } } diff --git a/datafusion/functions/src/regex/regexpreplace.rs b/datafusion/functions/src/regex/regexpreplace.rs index ec4afbad47d04..8b6dc997a9166 100644 --- a/datafusion/functions/src/regex/regexpreplace.rs +++ b/datafusion/functions/src/regex/regexpreplace.rs @@ -250,7 +250,7 @@ impl OptimizedRegex { // also leave the input unchanged. if short_re.captures_read(locs, val).is_none() { return Cow::Borrowed(val); - }; + } // `captures_read` succeeded, so the overall shortened match is present. let match_end = locs.get(0).unwrap().1; @@ -259,7 +259,7 @@ impl OptimizedRegex { // regex since it won't match across lines. Fall back to the full // regex replacement. return self.re.replacen(val, limit, replacement); - }; + } // The fast path only applies to `${1}` replacements, so the result is // either capture group 1 or the empty string if that group did not match. if let Some((start, end)) = locs.get(1) { diff --git a/datafusion/optimizer/src/eliminate_cross_join.rs b/datafusion/optimizer/src/eliminate_cross_join.rs index 95b70da443d88..5614948c9e2f3 100644 --- a/datafusion/optimizer/src/eliminate_cross_join.rs +++ b/datafusion/optimizer/src/eliminate_cross_join.rs @@ -300,7 +300,7 @@ fn flatten_join_inputs( _ => { all_inputs.push(plan); } - }; + } Ok(()) } @@ -313,7 +313,7 @@ fn can_flatten_join_inputs(plan: &LogicalPlan) -> bool { match plan { LogicalPlan::Join(join) if join.join_type == JoinType::Inner => {} _ => return false, - }; + } for child in plan.inputs() { if let LogicalPlan::Join(Join { @@ -435,7 +435,7 @@ fn extract_possible_join_keys(expr: &Expr, join_keys: &mut JoinKeySet) { join_keys.insert_intersection(&left_join_keys, &right_join_keys) } _ => (), - }; + } } } diff --git a/datafusion/optimizer/src/optimize_projections/mod.rs b/datafusion/optimizer/src/optimize_projections/mod.rs index 413efd95588d6..b0543a871f52b 100644 --- a/datafusion/optimizer/src/optimize_projections/mod.rs +++ b/datafusion/optimizer/src/optimize_projections/mod.rs @@ -282,7 +282,7 @@ fn optimize_projections( } // Other node types are handled below _ => {} - }; + } // For other plan node types, calculate indices for columns they use and // try to rewrite their children diff --git a/datafusion/optimizer/src/push_down_filter.rs b/datafusion/optimizer/src/push_down_filter.rs index 1ae0ee40858a9..a0976837320ef 100644 --- a/datafusion/optimizer/src/push_down_filter.rs +++ b/datafusion/optimizer/src/push_down_filter.rs @@ -790,7 +790,7 @@ impl OptimizerRule for PushDownFilter { let _ = config; if let LogicalPlan::Join(join) = plan { return push_down_join(join, None); - }; + } let LogicalPlan::Filter(mut filter) = plan else { return Ok(Transformed::no(plan)); diff --git a/datafusion/optimizer/src/simplify_expressions/linear_aggregates.rs b/datafusion/optimizer/src/simplify_expressions/linear_aggregates.rs index 21389cf326c24..4b3b6579584bf 100644 --- a/datafusion/optimizer/src/simplify_expressions/linear_aggregates.rs +++ b/datafusion/optimizer/src/simplify_expressions/linear_aggregates.rs @@ -149,7 +149,7 @@ fn candidate_linear_param(params: &AggregateFunctionParams) -> Option<&Expr> { let arg = args.first()?; if arg.is_volatile() { return None; - }; + } Some(arg) } diff --git a/datafusion/optimizer/src/simplify_expressions/regex.rs b/datafusion/optimizer/src/simplify_expressions/regex.rs index 7dccb5b1b952d..97417bc112fbd 100644 --- a/datafusion/optimizer/src/simplify_expressions/regex.rs +++ b/datafusion/optimizer/src/simplify_expressions/regex.rs @@ -211,7 +211,7 @@ fn is_anchored_literal(v: &[Hir]) -> bool { match v.len() { 2..=3 => (), _ => return false, - }; + } let first_last = ( v.first().expect("length checked"), diff --git a/datafusion/optimizer/src/simplify_expressions/unwrap_cast.rs b/datafusion/optimizer/src/simplify_expressions/unwrap_cast.rs index 1b07cfa428df5..d0165b568a753 100644 --- a/datafusion/optimizer/src/simplify_expressions/unwrap_cast.rs +++ b/datafusion/optimizer/src/simplify_expressions/unwrap_cast.rs @@ -86,7 +86,7 @@ pub(super) fn unwrap_cast_in_comparison_for_binary( op, right: Box::new(lit(value)), }))); - }; + } // if the lit_value can be casted to the type of internal_left_expr // we need to unwrap the cast for cast/try_cast expr, and add cast to the literal diff --git a/datafusion/physical-expr-common/src/binary_map.rs b/datafusion/physical-expr-common/src/binary_map.rs index 642f256d1b7a9..4523fee7cda43 100644 --- a/datafusion/physical-expr-common/src/binary_map.rs +++ b/datafusion/physical-expr-common/src/binary_map.rs @@ -324,7 +324,7 @@ where ) } _ => unreachable!("View types should use `ArrowBytesViewMap`"), - }; + } } /// Generic version of [`Self::insert_if_new`] that handles `ByteArrayType` diff --git a/datafusion/physical-expr-common/src/binary_view_map.rs b/datafusion/physical-expr-common/src/binary_view_map.rs index 51f6f4fb660b1..6154616b6e9e7 100644 --- a/datafusion/physical-expr-common/src/binary_view_map.rs +++ b/datafusion/physical-expr-common/src/binary_view_map.rs @@ -234,7 +234,7 @@ where ) } _ => unreachable!("Utf8/Binary should use `ArrowBytesSet`"), - }; + } } /// Generic version of [`Self::insert_if_new`] that handles `ByteViewType` diff --git a/datafusion/physical-expr-common/src/metrics/mod.rs b/datafusion/physical-expr-common/src/metrics/mod.rs index 146c039c75f6a..45f7c1d91ccd0 100644 --- a/datafusion/physical-expr-common/src/metrics/mod.rs +++ b/datafusion/physical-expr-common/src/metrics/mod.rs @@ -885,7 +885,7 @@ mod tests { _ => { panic!("Not a timestamp"); } - }; + } let mut ts = aggregated .iter() @@ -903,7 +903,7 @@ mod tests { _ => { panic!("Not a timestamp"); } - }; + } } #[test] diff --git a/datafusion/physical-expr/src/analysis.rs b/datafusion/physical-expr/src/analysis.rs index 3905e4b7fcc3c..200610c7bfdc7 100644 --- a/datafusion/physical-expr/src/analysis.rs +++ b/datafusion/physical-expr/src/analysis.rs @@ -247,7 +247,7 @@ fn shrink_boundaries( .find(|bound| bound.column.eq(column)) { bound.interval = Some(graph.get_interval(*i)); - }; + } } let selectivity = calculate_selectivity(&target_boundaries, &initial_boundaries)?; diff --git a/datafusion/physical-expr/src/equivalence/properties/dependency.rs b/datafusion/physical-expr/src/equivalence/properties/dependency.rs index bd8bef84de2d8..082c1e7d2d1f7 100644 --- a/datafusion/physical-expr/src/equivalence/properties/dependency.rs +++ b/datafusion/physical-expr/src/equivalence/properties/dependency.rs @@ -135,7 +135,7 @@ impl<'a> DependencyEnumerator<'a> { // Return its projected version, which is the target_expression. if node.dependencies.is_empty() { return vec![[target.clone()].into()]; - }; + } node.dependencies .iter() diff --git a/datafusion/physical-expr/src/window/window_expr.rs b/datafusion/physical-expr/src/window/window_expr.rs index 59edd5e865900..0af4f0a4ebbf4 100644 --- a/datafusion/physical-expr/src/window/window_expr.rs +++ b/datafusion/physical-expr/src/window/window_expr.rs @@ -254,7 +254,7 @@ pub trait AggregateWindowExpr: WindowExpr { published: false, }, ); - }; + } let window_state = window_agg_state .get_mut(partition_row) .ok_or_else(|| exec_datafusion_err!("Cannot find state"))?; @@ -435,7 +435,7 @@ pub(crate) fn is_end_bound_safe( if sort_exprs.is_empty() { // Early return if no sort expressions are present: return Ok(false); - }; + } match window_frame_ctx { WindowFrameContext::Rows(window_frame) => { diff --git a/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs b/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs index 19e308283ec81..484d89d3deebd 100644 --- a/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs +++ b/datafusion/physical-optimizer/src/ensure_requirements/enforce_distribution.rs @@ -1196,7 +1196,7 @@ pub fn ensure_distribution( )? { plan = updated_window; - }; + } // For joins in partitioned mode, we need exact hash matching between // both sides, so subset partitioning logic must be disabled. @@ -1392,7 +1392,7 @@ pub fn ensure_distribution( child = add_roundrobin_on_top(child, target_partitions)?; } } - }; + } Ok(DistributionChildState { context: child, diff --git a/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/mod.rs b/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/mod.rs index 42a157257341d..e9467d508aa10 100644 --- a/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/mod.rs +++ b/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/mod.rs @@ -782,7 +782,7 @@ fn remove_corresponding_sort_from_sub_plan( repartition.properties().output_partitioning().clone(), )?) as _; } - }; + } // Deleting a merging sort may invalidate distribution requirements. // Ensure that we stay compliant with such requirements: if requires_single_partition && node.plan.output_partitioning().partition_count() > 1 diff --git a/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/replace_with_order_preserving_variants.rs b/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/replace_with_order_preserving_variants.rs index 6ab84dc95eab9..d7b3f16a8f139 100644 --- a/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/replace_with_order_preserving_variants.rs +++ b/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/replace_with_order_preserving_variants.rs @@ -154,7 +154,7 @@ pub fn plan_with_order_preserving_variants( Some(coalesce_fetch) } }; - }; + } // When the input of a `CoalescePartitionsExec` has an ordering, // replace it with a `SortPreservingMergeExec` if appropriate: let spm = SortPreservingMergeExec::new(ordering.clone(), Arc::clone(child)) diff --git a/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/sort_pushdown.rs b/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/sort_pushdown.rs index 5c17ffbd1e7db..de5a46b96baea 100644 --- a/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/sort_pushdown.rs +++ b/datafusion/physical-optimizer/src/ensure_requirements/enforce_sorting/sort_pushdown.rs @@ -816,7 +816,7 @@ fn expr_source_side( } false }); - }; + } if !(valid_left || valid_right) { return None; } diff --git a/datafusion/physical-plan/src/aggregates/group_values/multi_group_by/bytes.rs b/datafusion/physical-plan/src/aggregates/group_values/multi_group_by/bytes.rs index c83b1da4049bc..d56aeca0e08ed 100644 --- a/datafusion/physical-plan/src/aggregates/group_values/multi_group_by/bytes.rs +++ b/datafusion/physical-plan/src/aggregates/group_values/multi_group_by/bytes.rs @@ -262,7 +262,7 @@ where self.append_val_inner::>(column, row)? } _ => unreachable!("View types should use `ArrowBytesViewMap`"), - }; + } Ok(()) } @@ -321,7 +321,7 @@ where self.vectorized_append_inner::>(column, rows)? } _ => unreachable!("View types should use `ArrowBytesViewMap`"), - }; + } Ok(()) } diff --git a/datafusion/physical-plan/src/aggregates/grouped_hash_stream.rs b/datafusion/physical-plan/src/aggregates/grouped_hash_stream.rs index c0253093c8a7b..b58c0d65065b6 100644 --- a/datafusion/physical-plan/src/aggregates/grouped_hash_stream.rs +++ b/datafusion/physical-plan/src/aggregates/grouped_hash_stream.rs @@ -699,7 +699,7 @@ impl Stream for GroupedHashAggregateStream { if let Some(batch) = self.emit(to_emit, false)? { self.exec_state = ExecutionState::ProducingOutput(batch); - }; + } // make sure the exec_state just set is not overwritten below break 'reading_input; } @@ -1360,7 +1360,7 @@ impl GroupedHashAggregateStream { // currently spilling is not supported for Partial aggregation assert!(self.spill_state.spills.is_empty()); probe.update_state(input_rows, self.group_values.len()); - }; + } } /// In case the probe indicates that aggregation may be @@ -1375,7 +1375,7 @@ impl GroupedHashAggregateStream { && let Some(batch) = self.emit(EmitTo::All, false)? { return Ok(Some(ExecutionState::ProducingOutput(batch))); - }; + } Ok(None) } diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs index 3c1df7076c47f..0792fb48acae0 100644 --- a/datafusion/physical-plan/src/aggregates/mod.rs +++ b/datafusion/physical-plan/src/aggregates/mod.rs @@ -3531,7 +3531,7 @@ mod tests { " ); } - }; + } let merge = Arc::new(CoalescePartitionsExec::new(partial_aggregate)); @@ -3652,7 +3652,7 @@ mod tests { +---+---------------+-------------+ "); } - }; + } let merge = Arc::new(CoalescePartitionsExec::new(partial_aggregate)); @@ -5110,7 +5110,7 @@ mod tests { +---+-------------------------------------------+ "); } - }; + } Ok(()) } diff --git a/datafusion/physical-plan/src/aggregates/order/mod.rs b/datafusion/physical-plan/src/aggregates/order/mod.rs index 259411b00b697..147e4e0d6f18d 100644 --- a/datafusion/physical-plan/src/aggregates/order/mod.rs +++ b/datafusion/physical-plan/src/aggregates/order/mod.rs @@ -143,7 +143,7 @@ impl GroupOrdering { GroupOrdering::Full(full) => { full.new_groups(total_num_groups); } - }; + } Ok(()) } diff --git a/datafusion/physical-plan/src/aggregates/topk/priority_map.rs b/datafusion/physical-plan/src/aggregates/topk/priority_map.rs index f46cb22a7a63c..f36e0f762849c 100644 --- a/datafusion/physical-plan/src/aggregates/topk/priority_map.rs +++ b/datafusion/physical-plan/src/aggregates/topk/priority_map.rs @@ -105,7 +105,7 @@ impl PriorityMap { self.heap.insert(row_idx, map_idx, map); self.map.update_heap_idx(map); return Ok(()); - }; + } // this is a value for an existing group map.clear(); diff --git a/datafusion/physical-plan/src/buffer.rs b/datafusion/physical-plan/src/buffer.rs index 72df0f5345041..1d59a4fda92d8 100644 --- a/datafusion/physical-plan/src/buffer.rs +++ b/datafusion/physical-plan/src/buffer.rs @@ -476,7 +476,7 @@ impl MemoryBufferedStream { if batch_tx.send(Ok((item, permit))).is_err() { break; // stream was closed - }; + } } }); diff --git a/datafusion/physical-plan/src/coalesce_batches.rs b/datafusion/physical-plan/src/coalesce_batches.rs index 87957ced7b11c..41f289a402ceb 100644 --- a/datafusion/physical-plan/src/coalesce_batches.rs +++ b/datafusion/physical-plan/src/coalesce_batches.rs @@ -136,7 +136,7 @@ impl DisplayAs for CoalesceBatchesExec { )?; if let Some(fetch) = self.fetch { write!(f, ", fetch={fetch}")?; - }; + } Ok(()) } @@ -144,7 +144,7 @@ impl DisplayAs for CoalesceBatchesExec { writeln!(f, "target_batch_size={}", self.target_batch_size)?; if let Some(fetch) = self.fetch { write!(f, "limit={fetch}")?; - }; + } Ok(()) } } diff --git a/datafusion/physical-plan/src/joins/hash_join/stream.rs b/datafusion/physical-plan/src/joins/hash_join/stream.rs index 63a94e1987d91..2513d04a1cb3c 100644 --- a/datafusion/physical-plan/src/joins/hash_join/stream.rs +++ b/datafusion/physical-plan/src/joins/hash_join/stream.rs @@ -729,7 +729,7 @@ impl HashJoinStream { }); } Some(Err(err)) => return Poll::Ready(Err(err)), - }; + } Poll::Ready(Ok(StatefulStreamResult::Continue)) } @@ -991,7 +991,7 @@ impl HashJoinStream { .ok_or_else(|| internal_datafusion_err!("unexpected None offset"))?, last_joined_right_idx, ) - }; + } Ok(StatefulStreamResult::Continue) } diff --git a/datafusion/physical-plan/src/joins/piecewise_merge_join/classic_join.rs b/datafusion/physical-plan/src/joins/piecewise_merge_join/classic_join.rs index bc69ae5140831..40be9a787066a 100644 --- a/datafusion/physical-plan/src/joins/piecewise_merge_join/classic_join.rs +++ b/datafusion/physical-plan/src/joins/piecewise_merge_join/classic_join.rs @@ -256,7 +256,7 @@ impl ClassicPWMJStream { ); } Some(Err(err)) => return Poll::Ready(Err(err)), - }; + } Poll::Ready(Ok(StatefulStreamResult::Continue)) } @@ -532,7 +532,7 @@ fn resolve_classic_join( operator ); } - }; + } // Increment buffer_idx after every row buffer_idx += 1; diff --git a/datafusion/physical-plan/src/joins/sort_merge_join/materializing_stream.rs b/datafusion/physical-plan/src/joins/sort_merge_join/materializing_stream.rs index 30abff1ad4711..2ca92af514be8 100644 --- a/datafusion/physical-plan/src/joins/sort_merge_join/materializing_stream.rs +++ b/datafusion/physical-plan/src/joins/sort_merge_join/materializing_stream.rs @@ -144,7 +144,7 @@ impl StreamedBatch { buffered_indices: UInt64Builder::with_capacity(capacity), }); self.buffered_batch_idx = buffered_batch_idx; - }; + } let current_chunk = self.output_indices.last_mut().unwrap(); // Append index of streamed batch and index of buffered batch into current chunk diff --git a/datafusion/physical-plan/src/joins/utils.rs b/datafusion/physical-plan/src/joins/utils.rs index fe19123cb20c5..25887ea283d34 100644 --- a/datafusion/physical-plan/src/joins/utils.rs +++ b/datafusion/physical-plan/src/joins/utils.rs @@ -124,7 +124,7 @@ fn check_join_set_is_valid( return plan_err!( "The left or right side of the join does not have all columns on \"on\": \nMissing on the left: {left_missing:?}\nMissing on the right: {right_missing:?}" ); - }; + } Ok(()) } @@ -797,7 +797,7 @@ fn estimate_inner_join_cardinality( // Immediately return if inputs considered as non-overlapping if let Some(estimation) = estimate_disjoint_inputs(&left_stats, &right_stats) { return Some(estimation); - }; + } let Statistics { num_rows: left_num_rows, @@ -1257,7 +1257,7 @@ pub(crate) fn apply_join_filter_to_indices( ) -> Result<(UInt64Array, UInt32Array)> { if build_indices.is_empty() && probe_indices.is_empty() { return Ok((build_indices, probe_indices)); - }; + } let filter_result = if let Some(max_size) = max_intermediate_size { let mut filter_results = diff --git a/datafusion/physical-plan/src/projection.rs b/datafusion/physical-plan/src/projection.rs index 2a24eb60e6fbc..c4096457c168a 100644 --- a/datafusion/physical-plan/src/projection.rs +++ b/datafusion/physical-plan/src/projection.rs @@ -785,7 +785,7 @@ pub fn try_embed_projection( if projection_index.is_empty() { return Ok(None); - }; + } let columns_reduced = projection_index.len() < execution_plan.schema().fields().len(); diff --git a/datafusion/physical-plan/src/sorts/partial_sort.rs b/datafusion/physical-plan/src/sorts/partial_sort.rs index 478ac14e119d2..80520d58dfa9b 100644 --- a/datafusion/physical-plan/src/sorts/partial_sort.rs +++ b/datafusion/physical-plan/src/sorts/partial_sort.rs @@ -579,7 +579,7 @@ impl PartialSortStream { Poll::Ready(None) }; } - }; + } } } diff --git a/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs b/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs index 9fadeb972d4ed..7596676d84934 100644 --- a/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs +++ b/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs @@ -198,14 +198,14 @@ impl DisplayAs for SortPreservingMergeExec { write!(f, "SortPreservingMergeExec: [{}]", self.expr)?; if let Some(fetch) = self.fetch { write!(f, ", fetch={fetch}")?; - }; + } Ok(()) } DisplayFormatType::TreeRender => { if let Some(fetch) = self.fetch { writeln!(f, "limit={fetch}")?; - }; + } for (i, e) in self.expr().iter().enumerate() { e.fmt_sql(f)?; diff --git a/datafusion/physical-plan/src/stream.rs b/datafusion/physical-plan/src/stream.rs index a1c89daa31b39..bc549f442001c 100644 --- a/datafusion/physical-plan/src/stream.rs +++ b/datafusion/physical-plan/src/stream.rs @@ -570,7 +570,7 @@ impl ObservedStream { self.release_inner(); } return Poll::Ready(Some(Ok(batch))); - }; + } self.produced += batch.num_rows() } poll diff --git a/datafusion/physical-plan/src/topk/mod.rs b/datafusion/physical-plan/src/topk/mod.rs index 97196e174cdf1..94504aa7bd8f4 100644 --- a/datafusion/physical-plan/src/topk/mod.rs +++ b/datafusion/physical-plan/src/topk/mod.rs @@ -822,7 +822,7 @@ impl TopK { batch = batch.slice(batch_size, remaining_length); } } - }; + } Ok(Box::pin(RecordBatchStreamAdapter::new( schema, futures::stream::iter(batches), diff --git a/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs b/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs index 11d0f677600ea..c0129425f7ca8 100644 --- a/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs +++ b/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs @@ -1844,7 +1844,7 @@ mod tests { .is_ok() { return Err(exec_datafusion_err!("shouldn't have completed")); - }; + } Ok(results) } diff --git a/datafusion/physical-plan/src/windows/mod.rs b/datafusion/physical-plan/src/windows/mod.rs index 18a877b0df469..3f33dfedfd850 100644 --- a/datafusion/physical-plan/src/windows/mod.rs +++ b/datafusion/physical-plan/src/windows/mod.rs @@ -568,7 +568,7 @@ pub(crate) fn window_equivalence_properties( Arc::new(window_col), SortOptions::new(true, false), )]); - }; + } } } } @@ -615,7 +615,7 @@ pub fn get_best_fitting_window( // Executor has bounded input and `input_order_mode` is not `InputOrderMode::Sorted` // in this case removing the sort is not helpful, return: return Ok(None); - }; + } let window_expr = if should_reverse { if let Some(reversed_window_expr) = window_exprs diff --git a/datafusion/proto/src/logical_plan/from_proto.rs b/datafusion/proto/src/logical_plan/from_proto.rs index d4d0ea7292ffe..a1a1ff6f04fe4 100644 --- a/datafusion/proto/src/logical_plan/from_proto.rs +++ b/datafusion/proto/src/logical_plan/from_proto.rs @@ -255,7 +255,7 @@ pub fn parse_expr( if expr.distinct { builder = builder.distinct(); - }; + } if let Some(filter) = parse_optional_expr(expr.filter.as_deref(), ctx, codec)? { diff --git a/datafusion/spark/src/function/string/format_string.rs b/datafusion/spark/src/function/string/format_string.rs index f2ab85265c82a..131d1c14dfe5b 100644 --- a/datafusion/spark/src/function/string/format_string.rs +++ b/datafusion/spark/src/function/string/format_string.rs @@ -1581,7 +1581,7 @@ impl ConversionSpecifier { temp = format!("{prefix}p{iexp}"); } } - }; + } if self.conversion_type.is_upper() { temp = temp.to_ascii_uppercase(); @@ -1614,7 +1614,7 @@ impl ConversionSpecifier { temp = " ".to_owned() + &temp; } writer.push_str(&temp); - }; + } Ok(()) } diff --git a/datafusion/spark/src/function/url/parse_url.rs b/datafusion/spark/src/function/url/parse_url.rs index 1a20cdc10b44a..c385f43e49343 100644 --- a/datafusion/spark/src/function/url/parse_url.rs +++ b/datafusion/spark/src/function/url/parse_url.rs @@ -112,7 +112,7 @@ impl ParseUrl { "The url is invalid: {value}. Use `try_parse_url` to tolerate invalid URL and return NULL instead. SQLSTATE: 22P02" )) }; - }; + } url.map_err(|e| exec_datafusion_err!("{e:?}")) .map(|url| match part { "HOST" => url.host_str().map(String::from), diff --git a/datafusion/sql/src/parser.rs b/datafusion/sql/src/parser.rs index f554a57838881..fcf4708f1bf94 100644 --- a/datafusion/sql/src/parser.rs +++ b/datafusion/sql/src/parser.rs @@ -1082,7 +1082,7 @@ impl<'a> DFParser<'a> { options.push(ColumnOptionDef { name: None, option }); } else { break; - }; + } } Ok(ColumnDef { name, diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs index 1db11d66b7ec7..a3e6d75fdbfac 100644 --- a/datafusion/sql/src/planner.rs +++ b/datafusion/sql/src/planner.rs @@ -376,7 +376,7 @@ impl PlannerContext { match self.outer_from_schema.as_mut() { Some(from_schema) => Arc::make_mut(from_schema).merge(schema), None => self.outer_from_schema = Some(Arc::clone(schema)), - }; + } Ok(()) } diff --git a/datafusion/sql/src/statement.rs b/datafusion/sql/src/statement.rs index 33791227b3f81..1a9072212f2f3 100644 --- a/datafusion/sql/src/statement.rs +++ b/datafusion/sql/src/statement.rs @@ -1091,12 +1091,12 @@ impl SqlToRel<'_, S> { plan_err!( "Inserts with a table alias not supported: {table_alias:?}" )? - }; + } if let Some(priority) = priority { plan_err!( "Inserts with a `PRIORITY` clause not supported: {priority:?}" )? - }; + } if insert_alias.is_some() { plan_err!("Inserts with an alias not supported")?; } @@ -1305,10 +1305,10 @@ impl SqlToRel<'_, S> { } => { if end { return not_impl_err!("COMMIT AND END not supported"); - }; + } if let Some(modifier) = modifier { return not_impl_err!("COMMIT {modifier} not supported"); - }; + } let statement = PlanStatement::TransactionEnd(TransactionEnd { conclusion: TransactionConclusion::Commit, chain, diff --git a/datafusion/sql/src/unparser/plan.rs b/datafusion/sql/src/unparser/plan.rs index 374095b29c867..30320acbb24dc 100644 --- a/datafusion/sql/src/unparser/plan.rs +++ b/datafusion/sql/src/unparser/plan.rs @@ -329,7 +329,7 @@ impl Unparser<'_> { .map(|e| unproject_unnest_expr(e, unnest)) .collect::>>()?; } - }; + } // Rewrite column references that point to FLATTEN table aliases: // in Snowflake, FLATTEN output is accessed via .VALUE, not the @@ -1170,7 +1170,7 @@ impl Unparser<'_> { fetch.to_string(), false, )))); - }; + } let agg = find_agg_node_within_select(plan, select.already_projected()); // unproject sort expressions @@ -1473,7 +1473,7 @@ impl Unparser<'_> { select.projection(projection); } } - }; + } Ok(()) } @@ -1995,7 +1995,7 @@ impl Unparser<'_> { // which is normally safe to unnest as a table factor. // However, in the future, more comprehensive checks can be added here. return Ok(None); - }; + } let exprs = projection .expr @@ -2227,7 +2227,7 @@ impl Unparser<'_> { }) .collect::>(); builder = builder.project(project_columns)?; - }; + } } let filter_expr: Result> = table_scan diff --git a/datafusion/sql/src/unparser/rewrite.rs b/datafusion/sql/src/unparser/rewrite.rs index 6ee66f61938f0..63cdad5fc8d69 100644 --- a/datafusion/sql/src/unparser/rewrite.rs +++ b/datafusion/sql/src/unparser/rewrite.rs @@ -377,7 +377,7 @@ pub(super) fn subquery_alias_inner_query_and_columns( if outer_alias.expr.to_string() != inner_expr_string { return (plan, vec![]); - }; + } columns.push(outer_alias.name.as_str().into()); } diff --git a/datafusion/sql/src/unparser/utils.rs b/datafusion/sql/src/unparser/utils.rs index 949b49eb77be9..240032d26c845 100644 --- a/datafusion/sql/src/unparser/utils.rs +++ b/datafusion/sql/src/unparser/utils.rs @@ -519,7 +519,7 @@ pub(crate) fn date_part_to_sql( )); } _ => {} - }; + } Ok(None) } diff --git a/datafusion/sqllogictest/src/engines/postgres_engine/mod.rs b/datafusion/sqllogictest/src/engines/postgres_engine/mod.rs index 5d01befbf9041..3c7087e7dca58 100644 --- a/datafusion/sqllogictest/src/engines/postgres_engine/mod.rs +++ b/datafusion/sqllogictest/src/engines/postgres_engine/mod.rs @@ -85,7 +85,7 @@ impl Postgres { let res = config.connect(tokio_postgres::NoTls).await; if res.is_err() { eprintln!("Error connecting to postgres using PG_URI={uri}"); - }; + } let (client, connection) = res?; diff --git a/datafusion/sqllogictest/src/test_context.rs b/datafusion/sqllogictest/src/test_context.rs index 9b97d3f59dac4..f3090c4fd0f7a 100644 --- a/datafusion/sqllogictest/src/test_context.rs +++ b/datafusion/sqllogictest/src/test_context.rs @@ -209,7 +209,7 @@ impl TestContext { _ => { info!("Using default SessionContext"); } - }; + } Some(test_ctx) } diff --git a/datafusion/substrait/src/logical_plan/consumer/expr/mod.rs b/datafusion/substrait/src/logical_plan/consumer/expr/mod.rs index 2fcc11f4e417d..2cd295cb48fcd 100644 --- a/datafusion/substrait/src/logical_plan/consumer/expr/mod.rs +++ b/datafusion/substrait/src/logical_plan/consumer/expr/mod.rs @@ -239,7 +239,7 @@ mod tests { assert_eq!(window_function.params.order_by.len(), 1) } _ => panic!("expr was not a WindowFunction"), - }; + } Ok(()) } @@ -266,7 +266,7 @@ mod tests { assert_eq!(window_function.params.args.len(), 1) } _ => panic!("expr was not a WindowFunction"), - }; + } Ok(()) } diff --git a/datafusion/substrait/src/logical_plan/consumer/rel/aggregate_rel.rs b/datafusion/substrait/src/logical_plan/consumer/rel/aggregate_rel.rs index 413ee4b537c29..8c0114b90ee13 100644 --- a/datafusion/substrait/src/logical_plan/consumer/rel/aggregate_rel.rs +++ b/datafusion/substrait/src/logical_plan/consumer/rel/aggregate_rel.rs @@ -71,7 +71,7 @@ pub async fn from_aggregate_rel( group_exprs .push(Expr::GroupingSet(GroupingSet::GroupingSets(grouping_sets))); } - }; + } for m in &agg.measures { let filter = match &m.filter { diff --git a/datafusion/substrait/src/physical_plan/consumer.rs b/datafusion/substrait/src/physical_plan/consumer.rs index ccaf1abec4245..3c0df01b4ad38 100644 --- a/datafusion/substrait/src/physical_plan/consumer.rs +++ b/datafusion/substrait/src/physical_plan/consumer.rs @@ -87,7 +87,7 @@ pub async fn from_substrait_rel( ); } Err(e) => return Err(e), - }; + } match &read.as_ref().read_type { Some(ReadType::LocalFiles(files)) => { diff --git a/datafusion/substrait/tests/utils.rs b/datafusion/substrait/tests/utils.rs index 4d9b5ca83e5e0..89363931f1594 100644 --- a/datafusion/substrait/tests/utils.rs +++ b/datafusion/substrait/tests/utils.rs @@ -179,10 +179,10 @@ pub mod test { } if let Some(expr) = r.filter.as_ref() { self.collect_schemas_from_expr(expr)? - }; + } if let Some(expr) = r.best_effort_filter.as_ref() { self.collect_schemas_from_expr(expr)? - }; + } } RelType::Filter(f) => { self.apply(f.input.as_ref().map(|b| b.as_ref()))?; @@ -376,14 +376,14 @@ pub mod test { for if_clause in it.ifs.iter() { if let Some(expr) = if_clause.r#if.as_ref() { self.collect_schemas_from_expr(expr)?; - }; + } if let Some(expr) = if_clause.then.as_ref() { self.collect_schemas_from_expr(expr)?; - }; + } } if let Some(expr) = it.r#else.as_ref() { self.collect_schemas_from_expr(expr)?; - }; + } } RexType::SwitchExpression(se) => { if let Some(expr) = se.r#match.as_ref() { From 3965bd23e4cf9dc7b7705a6d64d53af1ee41dff1 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 21 Aug 2026 19:15:33 +0200 Subject: [PATCH 9/9] Enable clippy lint `unnecessary_trailing_comma` Drop trailing commas after single-item non-tuple parens/brackets. Applied with `cargo clippy --fix`. Co-Authored-By: Claude Fable 5 --- Cargo.toml | 1 - .../examples/data_io/parquet_embedded_index.rs | 2 +- .../examples/data_io/parquet_index.rs | 2 +- .../examples/query_planning/thread_pools.rs | 2 +- .../provider_filter_pushdown.rs | 2 +- .../core/tests/datasource/object_store_access.rs | 2 +- .../tests/parquet/dynamic_row_group_pruning.rs | 2 +- .../core/tests/parquet/external_access_plan.rs | 8 ++++---- .../tests/physical_optimizer/enforce_sorting.rs | 4 ++-- datafusion/datasource-arrow/src/file_format.rs | 2 +- datafusion/datasource-csv/src/file_format.rs | 2 +- datafusion/datasource-json/src/file_format.rs | 2 +- datafusion/datasource-parquet/src/sink.rs | 2 +- datafusion/expr-common/src/interval_arithmetic.rs | 14 +++++++------- datafusion/expr/src/expr.rs | 6 +++--- datafusion/expr/src/logical_plan/plan.rs | 4 ++-- .../benches/unicode_expressions/substr.rs | 12 ++++++------ datafusion/functions/src/datetime/to_date.rs | 2 +- .../physical-expr/src/equivalence/ordering.rs | 3 +-- datafusion/physical-plan/src/repartition/mod.rs | 2 +- datafusion/physical-plan/src/sorts/sort.rs | 2 +- .../src/sorts/sort_preserving_merge.rs | 2 +- datafusion/physical-plan/src/test/exec.rs | 4 ++-- .../proto/tests/cases/plans/dynamic_filters.rs | 4 ++-- datafusion/spark/benches/substring.rs | 12 ++++++------ 25 files changed, 49 insertions(+), 51 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb990ab8de691..d8a5d00970421 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -318,7 +318,6 @@ too_many_lines = "allow" # 484 hits trivially_copy_pass_by_ref = "allow" # 74 hits unicode_not_nfc = "allow" # 2 hits unnecessary_literal_bound = "allow" # 471 hits -unnecessary_trailing_comma = "allow" # 49 hits unnecessary_wraps = "allow" # 427 hits unnested_or_patterns = "allow" # 68 hits unreadable_literal = "allow" # 502 hits diff --git a/datafusion-examples/examples/data_io/parquet_embedded_index.rs b/datafusion-examples/examples/data_io/parquet_embedded_index.rs index 5e48600650702..9f205b8b8e306 100644 --- a/datafusion-examples/examples/data_io/parquet_embedded_index.rs +++ b/datafusion-examples/examples/data_io/parquet_embedded_index.rs @@ -367,7 +367,7 @@ fn read_distinct_index(path: &Path) -> Result { let file = File::open(path)?; let file_size = file.metadata()?.len(); - println!("Reading index from {} (size: {file_size})", path.display(),); + println!("Reading index from {} (size: {file_size})", path.display()); let reader = SerializedFileReader::new(file.try_clone()?)?; let meta = reader.metadata().file_metadata(); diff --git a/datafusion-examples/examples/data_io/parquet_index.rs b/datafusion-examples/examples/data_io/parquet_index.rs index b2b9fe877a4bb..8ca63516b2c08 100644 --- a/datafusion-examples/examples/data_io/parquet_index.rs +++ b/datafusion-examples/examples/data_io/parquet_index.rs @@ -311,7 +311,7 @@ impl Display for ParquetMetadataIndex { self.last_num_pruned() )?; let batches = pretty_format_batches(std::slice::from_ref(&self.index)).unwrap(); - write!(f, "{batches}",) + write!(f, "{batches}") } } diff --git a/datafusion-examples/examples/query_planning/thread_pools.rs b/datafusion-examples/examples/query_planning/thread_pools.rs index 2ff73a77c4024..af3806e77d816 100644 --- a/datafusion-examples/examples/query_planning/thread_pools.rs +++ b/datafusion-examples/examples/query_planning/thread_pools.rs @@ -305,7 +305,7 @@ impl Drop for CpuRuntime { // If the thread is still running, we wait for it to finish print!("Shutting down CPU runtime thread..."); if let Err(e) = thread_join_handle.join() { - eprintln!("Error joining CPU runtime thread: {e:?}",); + eprintln!("Error joining CPU runtime thread: {e:?}"); } else { println!("CPU runtime thread shutdown successfully."); } diff --git a/datafusion/core/tests/custom_sources_cases/provider_filter_pushdown.rs b/datafusion/core/tests/custom_sources_cases/provider_filter_pushdown.rs index d4693b025a5d4..4ec9747058140 100644 --- a/datafusion/core/tests/custom_sources_cases/provider_filter_pushdown.rs +++ b/datafusion/core/tests/custom_sources_cases/provider_filter_pushdown.rs @@ -94,7 +94,7 @@ impl DisplayAs for CustomPlan { ) -> std::fmt::Result { match t { DisplayFormatType::Default | DisplayFormatType::Verbose => { - write!(f, "CustomPlan: batch_size={}", self.batches.len(),) + write!(f, "CustomPlan: batch_size={}", self.batches.len()) } DisplayFormatType::TreeRender => { // TODO: collect info diff --git a/datafusion/core/tests/datasource/object_store_access.rs b/datafusion/core/tests/datasource/object_store_access.rs index 2ed97abb02213..16d894bde1303 100644 --- a/datafusion/core/tests/datasource/object_store_access.rs +++ b/datafusion/core/tests/datasource/object_store_access.rs @@ -1069,7 +1069,7 @@ impl Test { ); self = self .with_bytes( - &format!("/data/a={i}/b={}/c={}/file_{i}.csv", i * 10, i * 100,), + &format!("/data/a={i}/b={}/c={}/file_{i}.csv", i * 10, i * 100), csv_data1, ) .await; diff --git a/datafusion/core/tests/parquet/dynamic_row_group_pruning.rs b/datafusion/core/tests/parquet/dynamic_row_group_pruning.rs index 5ee42b30674bf..d3ce8dc6f4240 100644 --- a/datafusion/core/tests/parquet/dynamic_row_group_pruning.rs +++ b/datafusion/core/tests/parquet/dynamic_row_group_pruning.rs @@ -91,7 +91,7 @@ async fn dynamic_rg_pruning_metric_fires_for_topk_descending_limit() { let output = ctx.query("SELECT v FROM t ORDER BY v DESC LIMIT 5").await; - assert_eq!(output.result_rows, 5, "query must return LIMIT rows",); + assert_eq!(output.result_rows, 5, "query must return LIMIT rows"); let pruned = output .row_groups_pruned_dynamic_filter() diff --git a/datafusion/core/tests/parquet/external_access_plan.rs b/datafusion/core/tests/parquet/external_access_plan.rs index 8fd9689ae3a8d..81acba37cbbf8 100644 --- a/datafusion/core/tests/parquet/external_access_plan.rs +++ b/datafusion/core/tests/parquet/external_access_plan.rs @@ -70,7 +70,7 @@ async fn scan_all() { // Verify that some bytes were read let bytes_scanned = metric_value(&parquet_metrics, "bytes_scanned").unwrap(); - assert_ne!(bytes_scanned, 0, "metrics : {parquet_metrics:#?}",); + assert_ne!(bytes_scanned, 0, "metrics : {parquet_metrics:#?}"); } #[tokio::test] @@ -87,7 +87,7 @@ async fn skip_all() { // Verify that skipping all row groups skips reading any data at all let bytes_scanned = metric_value(&parquet_metrics, "bytes_scanned").unwrap(); - assert_eq!(bytes_scanned, 0, "metrics : {parquet_metrics:#?}",); + assert_eq!(bytes_scanned, 0, "metrics : {parquet_metrics:#?}"); } #[tokio::test] @@ -184,7 +184,7 @@ async fn row_selection_extension() { // only the first row group is read, so some bytes are scanned let bytes_scanned = metric_value(&parquet_metrics, "bytes_scanned").unwrap(); - assert_ne!(bytes_scanned, 0, "metrics : {parquet_metrics:#?}",); + assert_ne!(bytes_scanned, 0, "metrics : {parquet_metrics:#?}"); } #[tokio::test] @@ -215,7 +215,7 @@ async fn row_selection_extension_spanning_row_groups() { .unwrap(); let bytes_scanned = metric_value(&parquet_metrics, "bytes_scanned").unwrap(); - assert_ne!(bytes_scanned, 0, "metrics : {parquet_metrics:#?}",); + assert_ne!(bytes_scanned, 0, "metrics : {parquet_metrics:#?}"); } #[tokio::test] diff --git a/datafusion/core/tests/physical_optimizer/enforce_sorting.rs b/datafusion/core/tests/physical_optimizer/enforce_sorting.rs index 82543dce2b57b..cc089914bf904 100644 --- a/datafusion/core/tests/physical_optimizer/enforce_sorting.rs +++ b/datafusion/core/tests/physical_optimizer/enforce_sorting.rs @@ -200,7 +200,7 @@ impl EnforceSortingTest { .to_string(); if input_plan_string == optimized_plan_string { - format!("Input / Optimized Plan:\n{input_plan_string}",) + format!("Input / Optimized Plan:\n{input_plan_string}") } else { format!( "Input Plan:\n{input_plan_string}\nOptimized Plan:\n{optimized_plan_string}", @@ -2888,7 +2888,7 @@ async fn test_partial_sort_with_homogeneous_batches() -> Result<()> { .downcast_ref::() .unwrap(); let actual = c_array.values().iter().copied().collect::>(); - assert_eq!(actual, expected_values[i], "Batch {i} not sorted correctly",); + assert_eq!(actual, expected_values[i], "Batch {i} not sorted correctly"); } assert_eq!( diff --git a/datafusion/datasource-arrow/src/file_format.rs b/datafusion/datasource-arrow/src/file_format.rs index c50ad98dfca0b..2bee57ef17581 100644 --- a/datafusion/datasource-arrow/src/file_format.rs +++ b/datafusion/datasource-arrow/src/file_format.rs @@ -350,7 +350,7 @@ impl DisplayAs for ArrowFileSink { fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter<'_>) -> fmt::Result { match t { DisplayFormatType::Default | DisplayFormatType::Verbose => { - write!(f, "ArrowFileSink(file_groups=",)?; + write!(f, "ArrowFileSink(file_groups=")?; FileGroupDisplay(&self.config.file_group).fmt_as(t, f)?; write!(f, ")") } diff --git a/datafusion/datasource-csv/src/file_format.rs b/datafusion/datasource-csv/src/file_format.rs index a094fdc3bfe44..f14924563cdb6 100644 --- a/datafusion/datasource-csv/src/file_format.rs +++ b/datafusion/datasource-csv/src/file_format.rs @@ -765,7 +765,7 @@ impl DisplayAs for CsvSink { fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter<'_>) -> fmt::Result { match t { DisplayFormatType::Default | DisplayFormatType::Verbose => { - write!(f, "CsvSink(file_groups=",)?; + write!(f, "CsvSink(file_groups=")?; FileGroupDisplay(&self.config.file_group).fmt_as(t, f)?; write!(f, ")") } diff --git a/datafusion/datasource-json/src/file_format.rs b/datafusion/datasource-json/src/file_format.rs index 62d03d67ccd43..211011f95c31b 100644 --- a/datafusion/datasource-json/src/file_format.rs +++ b/datafusion/datasource-json/src/file_format.rs @@ -423,7 +423,7 @@ impl DisplayAs for JsonSink { fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter<'_>) -> fmt::Result { match t { DisplayFormatType::Default | DisplayFormatType::Verbose => { - write!(f, "JsonSink(file_groups=",)?; + write!(f, "JsonSink(file_groups=")?; FileGroupDisplay(&self.config.file_group).fmt_as(t, f)?; write!(f, ")") } diff --git a/datafusion/datasource-parquet/src/sink.rs b/datafusion/datasource-parquet/src/sink.rs index 53f6f1e6b4323..1b79ae665bb14 100644 --- a/datafusion/datasource-parquet/src/sink.rs +++ b/datafusion/datasource-parquet/src/sink.rs @@ -100,7 +100,7 @@ impl DisplayAs for ParquetSink { fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter<'_>) -> fmt::Result { match t { DisplayFormatType::Default | DisplayFormatType::Verbose => { - write!(f, "ParquetSink(file_groups=",)?; + write!(f, "ParquetSink(file_groups=")?; FileGroupDisplay(&self.config.file_group).fmt_as(t, f)?; write!(f, ")") } diff --git a/datafusion/expr-common/src/interval_arithmetic.rs b/datafusion/expr-common/src/interval_arithmetic.rs index 68541e1e6b32c..9f1291353dc29 100644 --- a/datafusion/expr-common/src/interval_arithmetic.rs +++ b/datafusion/expr-common/src/interval_arithmetic.rs @@ -4811,7 +4811,7 @@ mod tests { ]; for case in cases { - assert_eq!(case.0.not().unwrap(), case.1, "Failed for NOT {}", case.0,); + assert_eq!(case.0.not().unwrap(), case.1, "Failed for NOT {}", case.0); } Ok(()) } @@ -4832,7 +4832,7 @@ mod tests { for (interval, expected) in test_cases { let result = interval.is_certainly_true(); - assert_eq!(result, expected, "Failed for interval: {interval}",); + assert_eq!(result, expected, "Failed for interval: {interval}"); } } @@ -4852,7 +4852,7 @@ mod tests { for (interval, expected) in test_cases { let result = interval.is_true().unwrap(); - assert_eq!(result, expected, "Failed for interval: {interval}",); + assert_eq!(result, expected, "Failed for interval: {interval}"); } } @@ -4872,7 +4872,7 @@ mod tests { for (interval, expected) in test_cases { let result = interval.is_certainly_false(); - assert_eq!(result, expected, "Failed for interval: {interval}",); + assert_eq!(result, expected, "Failed for interval: {interval}"); } } @@ -4892,7 +4892,7 @@ mod tests { for (interval, expected) in test_cases { let result = interval.is_false().unwrap(); - assert_eq!(result, expected, "Failed for interval: {interval}",); + assert_eq!(result, expected, "Failed for interval: {interval}"); } } @@ -4912,7 +4912,7 @@ mod tests { for (interval, expected) in test_cases { let result = interval.is_certainly_unknown(); - assert_eq!(result, expected, "Failed for interval: {interval}",); + assert_eq!(result, expected, "Failed for interval: {interval}"); } } @@ -4932,7 +4932,7 @@ mod tests { for (interval, expected) in test_cases { let result = interval.is_unknown().unwrap(); - assert_eq!(result, expected, "Failed for interval: {interval}",); + assert_eq!(result, expected, "Failed for interval: {interval}"); } } diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs index 647e576b122fa..3b708b4edeec9 100644 --- a/datafusion/expr/src/expr.rs +++ b/datafusion/expr/src/expr.rs @@ -3042,7 +3042,7 @@ impl Display for SchemaDisplay<'_> { } } Expr::BinaryExpr(BinaryExpr { left, op, right }) => { - write!(f, "{} {op} {}", SchemaDisplay(left), SchemaDisplay(right),) + write!(f, "{} {op} {}", SchemaDisplay(left), SchemaDisplay(right)) } Expr::Case(Case { expr, @@ -3324,7 +3324,7 @@ impl Display for SqlDisplay<'_> { } } Expr::BinaryExpr(BinaryExpr { left, op, right }) => { - write!(f, "{} {op} {}", SqlDisplay(left), SqlDisplay(right),) + write!(f, "{} {op} {}", SqlDisplay(left), SqlDisplay(right)) } Expr::Case(Case { expr, @@ -3338,7 +3338,7 @@ impl Display for SqlDisplay<'_> { } for (when, then) in when_then_expr { - write!(f, "WHEN {} THEN {} ", SqlDisplay(when), SqlDisplay(then),)?; + write!(f, "WHEN {} THEN {} ", SqlDisplay(when), SqlDisplay(then))?; } if let Some(e) = else_expr { diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index 9b79b608e3d00..dd9357f26b738 100644 --- a/datafusion/expr/src/logical_plan/plan.rs +++ b/datafusion/expr/src/logical_plan/plan.rs @@ -2189,7 +2189,7 @@ impl LogicalPlan { }; match join_constraint { JoinConstraint::On => { - write!(f, "{join_type} Join:",)?; + write!(f, "{join_type} Join:")?; if !join_expr.is_empty() || !filter_expr.is_empty() { write!( f, @@ -2260,7 +2260,7 @@ impl LogicalPlan { .as_ref() .map_or_else(|| "None".to_string(), |x| x.to_string()), }; - write!(f, "Limit: skip={skip_str}, fetch={fetch_str}",) + write!(f, "Limit: skip={skip_str}, fetch={fetch_str}") } LogicalPlan::Subquery(Subquery { .. }) => { write!(f, "Subquery:") diff --git a/datafusion/functions/benches/unicode_expressions/substr.rs b/datafusion/functions/benches/unicode_expressions/substr.rs index c98c7d99c2706..a59dd7a007034 100644 --- a/datafusion/functions/benches/unicode_expressions/substr.rs +++ b/datafusion/functions/benches/unicode_expressions/substr.rs @@ -136,19 +136,19 @@ fn criterion_benchmark(c: &mut Criterion) { let args = create_args_with_count::(size, len, count, true, false); group.bench_function( - format!("substr_string_view [size={size}, count={count}, strlen={len}]",), + format!("substr_string_view [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); let args = create_args_with_count::(size, len, count, false, false); group.bench_function( - format!("substr_string [size={size}, count={count}, strlen={len}]",), + format!("substr_string [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); let args = create_args_with_count::(size, len, count, false, false); group.bench_function( - format!("substr_large_string [size={size}, count={count}, strlen={len}]",), + format!("substr_large_string [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); @@ -163,19 +163,19 @@ fn criterion_benchmark(c: &mut Criterion) { let args = create_args_with_count::(size, len, count, true, false); group.bench_function( - format!("substr_string_view [size={size}, count={count}, strlen={len}]",), + format!("substr_string_view [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); let args = create_args_with_count::(size, len, count, false, false); group.bench_function( - format!("substr_string [size={size}, count={count}, strlen={len}]",), + format!("substr_string [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); let args = create_args_with_count::(size, len, count, false, false); group.bench_function( - format!("substr_large_string [size={size}, count={count}, strlen={len}]",), + format!("substr_large_string [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); diff --git a/datafusion/functions/src/datetime/to_date.rs b/datafusion/functions/src/datetime/to_date.rs index 668c6ce029751..b22a30e8dd728 100644 --- a/datafusion/functions/src/datetime/to_date.rs +++ b/datafusion/functions/src/datetime/to_date.rs @@ -458,7 +458,7 @@ mod tests { "to_date created wrong value for date with 2 format strings" ); } - _ => panic!("Conversion failed",), + _ => panic!("Conversion failed"), } } diff --git a/datafusion/physical-expr/src/equivalence/ordering.rs b/datafusion/physical-expr/src/equivalence/ordering.rs index 499187a603979..12f243357ef69 100644 --- a/datafusion/physical-expr/src/equivalence/ordering.rs +++ b/datafusion/physical-expr/src/equivalence/ordering.rs @@ -748,8 +748,7 @@ mod tests { ]; for (reqs, expected) in test_cases { - let err_msg = - format!("error in test reqs: {reqs:?}, expected: {expected:?}",); + let err_msg = format!("error in test reqs: {reqs:?}, expected: {expected:?}"); let reqs = convert_to_sort_exprs(&reqs); assert_eq!(eq_properties.ordering_satisfy(reqs)?, expected, "{err_msg}"); } diff --git a/datafusion/physical-plan/src/repartition/mod.rs b/datafusion/physical-plan/src/repartition/mod.rs index 806f69495a4ef..7822c6facd7c9 100644 --- a/datafusion/physical-plan/src/repartition/mod.rs +++ b/datafusion/physical-plan/src/repartition/mod.rs @@ -1523,7 +1523,7 @@ impl DisplayAs for RepartitionExec { Ok(()) } DisplayFormatType::TreeRender => { - writeln!(f, "partitioning_scheme={}", self.partitioning(),)?; + writeln!(f, "partitioning_scheme={}", self.partitioning())?; let output_partition_count = self.partitioning().partition_count(); let input_to_output_partition_str = format!("{input_partition_count} -> {output_partition_count}"); diff --git a/datafusion/physical-plan/src/sorts/sort.rs b/datafusion/physical-plan/src/sorts/sort.rs index c91df46351e24..3ba1fb0ed0c6e 100644 --- a/datafusion/physical-plan/src/sorts/sort.rs +++ b/datafusion/physical-plan/src/sorts/sort.rs @@ -2109,7 +2109,7 @@ mod tests { match t { DisplayFormatType::Default | DisplayFormatType::Verbose - | DisplayFormatType::TreeRender => write!(f, "UnboundableExec",).unwrap(), + | DisplayFormatType::TreeRender => write!(f, "UnboundableExec").unwrap(), } Ok(()) } diff --git a/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs b/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs index 7596676d84934..38983d22b118d 100644 --- a/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs +++ b/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs @@ -1927,7 +1927,7 @@ mod tests { fn fmt_as(&self, t: DisplayFormatType, f: &mut Formatter) -> std::fmt::Result { match t { DisplayFormatType::Default | DisplayFormatType::Verbose => { - write!(f, "CongestedExec",).unwrap() + write!(f, "CongestedExec").unwrap() } DisplayFormatType::TreeRender => { // TODO: collect info diff --git a/datafusion/physical-plan/src/test/exec.rs b/datafusion/physical-plan/src/test/exec.rs index 1e2005e908fbf..f9517469d55ab 100644 --- a/datafusion/physical-plan/src/test/exec.rs +++ b/datafusion/physical-plan/src/test/exec.rs @@ -817,7 +817,7 @@ impl DisplayAs for BlockingExec { ) -> std::fmt::Result { match t { DisplayFormatType::Default | DisplayFormatType::Verbose => { - write!(f, "BlockingExec",) + write!(f, "BlockingExec") } DisplayFormatType::TreeRender => { // TODO: collect info @@ -977,7 +977,7 @@ impl DisplayAs for PanicExec { ) -> std::fmt::Result { match t { DisplayFormatType::Default | DisplayFormatType::Verbose => { - write!(f, "PanicExec",) + write!(f, "PanicExec") } DisplayFormatType::TreeRender => { // TODO: collect info diff --git a/datafusion/proto/tests/cases/plans/dynamic_filters.rs b/datafusion/proto/tests/cases/plans/dynamic_filters.rs index ee0ff9d8b1faf..7892ffd9a1ab0 100644 --- a/datafusion/proto/tests/cases/plans/dynamic_filters.rs +++ b/datafusion/proto/tests/cases/plans/dynamic_filters.rs @@ -253,8 +253,8 @@ fn assert_dynamic_filter_update_is_visible( // Ensure both filters have the updated expr. let expected_current = r#"Literal { value: Int64(123), field: Field { name: "lit", data_type: Int64 } }"#; - assert_eq!(expected_current, format!("{:?}", left_filter.current()?),); - assert_eq!(expected_current, format!("{:?}", right_filter.current()?),); + assert_eq!(expected_current, format!("{:?}", left_filter.current()?)); + assert_eq!(expected_current, format!("{:?}", right_filter.current()?)); Ok(()) } diff --git a/datafusion/spark/benches/substring.rs b/datafusion/spark/benches/substring.rs index d6eac817c322f..ccc3f67a2ccfd 100644 --- a/datafusion/spark/benches/substring.rs +++ b/datafusion/spark/benches/substring.rs @@ -154,19 +154,19 @@ fn criterion_benchmark(c: &mut Criterion) { let args = create_args_with_count::(size, len, count, true); group.bench_function( - format!("substr_string_view [size={size}, count={count}, strlen={len}]",), + format!("substr_string_view [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); let args = create_args_with_count::(size, len, count, false); group.bench_function( - format!("substr_string [size={size}, count={count}, strlen={len}]",), + format!("substr_string [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); let args = create_args_with_count::(size, len, count, false); group.bench_function( - format!("substr_large_string [size={size}, count={count}, strlen={len}]",), + format!("substr_large_string [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); @@ -181,19 +181,19 @@ fn criterion_benchmark(c: &mut Criterion) { let args = create_args_with_count::(size, len, count, true); group.bench_function( - format!("substr_string_view [size={size}, count={count}, strlen={len}]",), + format!("substr_string_view [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); let args = create_args_with_count::(size, len, count, false); group.bench_function( - format!("substr_string [size={size}, count={count}, strlen={len}]",), + format!("substr_string [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), ); let args = create_args_with_count::(size, len, count, false); group.bench_function( - format!("substr_large_string [size={size}, count={count}, strlen={len}]",), + format!("substr_large_string [size={size}, count={count}, strlen={len}]"), |b| b.iter(|| black_box(invoke_substr_with_args(args.clone(), size))), );