Skip to content

Apache DataFusion SQL Query Engine

Enable more clippy lints (#24566)

Emil Ernerfeldt17547e2b5f0a
diff --git a/Cargo.toml b/Cargo.toml
index d529f551e9..79a5077bf6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -270,70 +270,61 @@ 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
-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
-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_sign_loss = "allow" # 440 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`
+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_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
+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_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/benchmarks/src/imdb/mod.rs b/benchmarks/src/imdb/mod.rs
index 87462bc3e8..b742ebb32a 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<Vec<String>> {
.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 3eaaf172c0..afe867ef5c 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<Vec<String>>
.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 9f3226ed5a..bc67ba4c23 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 772d421bc7..829566d47c 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<impl AsRef<Path>>) -> 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 185dfb6b08..ca24da7873 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/exec.rs b/datafusion-cli/src/exec.rs
index fc230d5362..288ce4b735 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-cli/src/functions.rs b/datafusion-cli/src/functions.rs
index 657be4268d..0d7d8f3373 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 4be6058aef..f82206a5bd 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<SessionConfig> {
}
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 d0810cb034..5367b5e65c 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-examples/examples/data_io/parquet_embedded_index.rs b/datafusion-examples/examples/data_io/parquet_embedded_index.rs
index 5e48600650..9f205b8b8e 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<DistinctIndex> {
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 b2b9fe877a..8ca63516b2 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/pruning.rs b/datafusion-examples/examples/query_planning/pruning.rs
index 023058f825..7bde017142 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<Item = &'a Option<i32>>) -> ArrayRef {
- Arc::new(Int32Array::from_iter(values.cloned()))
+ Arc::new(Int32Array::from_iter(values.copied()))
}
diff --git a/datafusion-examples/examples/query_planning/thread_pools.rs b/datafusion-examples/examples/query_planning/thread_pools.rs
index 2ff73a77c4..af3806e77d 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/catalog-listing/src/helpers.rs b/datafusion/catalog-listing/src/helpers.rs
index 098f3d51ef..dc090378a8 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<TableReference>,
+ table_ref: Option<&TableReference>,
) -> Result<Option<PartitionedFile>> {
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/catalog-listing/src/table.rs b/datafusion/catalog-listing/src/table.rs
index 7f5d38b999..eb5480dde6 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 f93bd35cd7..4437d99667 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<Option<Arc<dyn TableProvider>>> {
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/column.rs b/datafusion/common/src/column.rs
index 7a6bef8381..b36b8f8977 100644
--- a/datafusion/common/src/column.rs
+++ b/datafusion/common/src/column.rs
@@ -237,7 +237,7 @@ impl Column {
.flat_map(|s| s.qualified_fields_with_unqualified_name(&self.name))
.collect::<Vec<_>>();
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/common/src/config.rs b/datafusion/common/src/config.rs
index 7c7604e041..4258ce6f00 100644
--- a/datafusion/common/src/config.rs
+++ b/datafusion/common/src/config.rs
@@ -3418,7 +3418,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 {
@@ -3598,7 +3598,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 02016387c0..d1fcb50f73 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 c539245764..78c14da960 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.
@@ -344,7 +344,7 @@ fn split_compression_string(str_setting: &str) -> Result<(String, Option<u32>)>
/// 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<u32>) -> 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 ea88eca4a6..0c71013cb0 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<Expr>, name: &str) -> Result<bool> {
+fn parse_bool_arg(arg: Option<&Expr>, name: &str) -> Result<bool> {
let Some(expr) = arg else {
return Ok(true);
};
@@ -605,8 +605,8 @@ fn parse_bool_arg(arg: &Option<Expr>, name: &str) -> Result<bool> {
/// Parse an identifier-or-string argument (used for `FORMAT`, `METRICS`,
/// `LEVEL`).
#[cfg(feature = "sql")]
-fn parse_ident_or_string_arg(arg: &Option<Expr>, name: &str) -> Result<String> {
- let expr = arg.as_ref().ok_or_else(|| {
+fn parse_ident_or_string_arg(arg: Option<&Expr>, name: &str) -> Result<String> {
+ let expr = arg.ok_or_else(|| {
DataFusionError::Plan(format!(
"EXPLAIN option {} requires an argument",
name.to_ascii_uppercase()
diff --git a/datafusion/common/src/hash_utils.rs b/datafusion/common/src/hash_utils.rs
index e9ca02cd20..2b8411ead6 100644
--- a/datafusion/common/src/hash_utils.rs
+++ b/datafusion/common/src/hash_utils.rs
@@ -740,8 +740,8 @@ where
OffsetSize: OffsetSizeTrait,
{
// In case values is sliced, hash only the bytes used by the offsets of this ListArray
- let first_offset = array.value_offsets().first().cloned().unwrap_or_default();
- let last_offset = array.value_offsets().last().cloned().unwrap_or_default();
+ let first_offset = array.value_offsets().first().copied().unwrap_or_default();
+ let last_offset = array.value_offsets().last().copied().unwrap_or_default();
let value_bytes_len = (last_offset - first_offset).as_usize();
let mut values_hashes = vec![0u64; value_bytes_len];
child_hashing.create_hashes(
@@ -1579,11 +1579,11 @@ mod tests {
fn test_create_hashes_dictionary_with_custom_hasher() {
let strings = [Some("foo"), None, Some("bar"), Some("foo"), None];
let string_array: ArrayRef =
- Arc::new(strings.iter().cloned().collect::<StringArray>());
+ Arc::new(strings.iter().copied().collect::<StringArray>());
let dict_array: ArrayRef = Arc::new(
strings
.iter()
- .cloned()
+ .copied()
.collect::<DictionaryArray<Int8Type>>(),
);
let hash_builder = BuildHasherDefault::<TestHasher>::default();
@@ -1751,11 +1751,11 @@ mod tests {
let strings = [Some("foo"), None, Some("bar"), Some("foo"), None];
let string_array: ArrayRef =
- Arc::new(strings.iter().cloned().collect::<StringArray>());
+ Arc::new(strings.iter().copied().collect::<StringArray>());
let dict_array: ArrayRef = Arc::new(
strings
.iter()
- .cloned()
+ .copied()
.collect::<DictionaryArray<Int8Type>>(),
);
@@ -2112,11 +2112,11 @@ mod tests {
let strings2 = [Some("blarg"), Some("blah"), None];
let string_array: ArrayRef =
- Arc::new(strings1.iter().cloned().collect::<StringArray>());
+ Arc::new(strings1.iter().copied().collect::<StringArray>());
let dict_array: ArrayRef = Arc::new(
strings2
.iter()
- .cloned()
+ .copied()
.collect::<DictionaryArray<Int32Type>>(),
);
diff --git a/datafusion/common/src/scalar/mod.rs b/datafusion/common/src/scalar/mod.rs
index 461ebe1b8d..bad526a3a2 100644
--- a/datafusion/common/src/scalar/mod.rs
+++ b/datafusion/common/src/scalar/mod.rs
@@ -1115,14 +1115,18 @@ fn dict_from_scalar<K: ArrowDictionaryKeyType>(
/// Useful for wrapping arrays in dictionary form.
///
/// # Input
+/// ```text
/// ["alice", "bob", "alice", null, "carol"]
+/// ```
///
/// # Output
/// `DictionaryArray<Int32>`
+/// ```text
/// {
/// keys: [0, 1, 2, 3, 4],
/// values: ["alice", "bob", "alice", null, "carol"]
/// }
+/// ```
pub fn dict_from_values<K: ArrowDictionaryKeyType>(
values_array: ArrayRef,
) -> Result<ArrayRef> {
@@ -5756,7 +5760,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(())
}
}
@@ -9898,7 +9902,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/benches/preserve_file_partitioning.rs b/datafusion/core/benches/preserve_file_partitioning.rs
index 9b1f59adc6..c459853d5e 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<Vec<Vec<SortExpr>>>,
+ file_sort_order: Option<&Vec<Vec<SortExpr>>>,
) {
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/core/src/datasource/file_format/csv.rs b/datafusion/core/src/datasource/file_format/csv.rs
index 447d5244f9..2fb64fd648 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(())
diff --git a/datafusion/core/src/datasource/file_format/options.rs b/datafusion/core/src/datasource/file_format/options.rs
index f2903405c8..d672641389 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/core/src/datasource/file_format/parquet.rs b/datafusion/core/src/datasource/file_format/parquet.rs
index bbd9d0937a..bfcfb74848 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 9e37f77d8b..cc5ad539da 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 78497604da..ff1ad25811 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 4502bb9b07..aa8ba4c3b7 100644
--- a/datafusion/core/src/execution/session_state.rs
+++ b/datafusion/core/src/execution/session_state.rs
@@ -990,7 +990,7 @@ impl SessionState {
"File type already registered for extension {ext}. Set overwrite to true to replace this extension."
);
}
- };
+ }
Ok(())
}
@@ -1712,7 +1712,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 3b46ed2523..59d3c440c7 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 aad3926937..3bcbc4d43c 100644
--- a/datafusion/core/src/physical_planner.rs
+++ b/datafusion/core/src/physical_planner.rs
@@ -2712,7 +2712,7 @@ impl DefaultPhysicalPlanner {
e.plan.display_graphviz().to_string(),
));
}
- };
+ }
if !stringified_plans.is_empty() {
return Ok(Arc::new(ExplainExec::new(
@@ -4280,9 +4280,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"));
diff --git a/datafusion/core/src/test_util/parquet.rs b/datafusion/core/src/test_util/parquet.rs
index e25fe74669..31cab41f68 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 b49183e92e..0b5e5fdbc5 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/custom_sources_cases/provider_filter_pushdown.rs b/datafusion/core/tests/custom_sources_cases/provider_filter_pushdown.rs
index d4693b025a..4ec9747058 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 2ed97abb02..16d894bde1 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/fifo/mod.rs b/datafusion/core/tests/fifo/mod.rs
index 3d99cc72fa..edaee514d6 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/fuzz_cases/limit_fuzz.rs b/datafusion/core/tests/fuzz_cases/limit_fuzz.rs
index 1c5741e7a2..4ce3ffab5c 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 7624c97cf4..da7faffcb3 100644
--- a/datafusion/core/tests/fuzz_cases/pruning.rs
+++ b/datafusion/core/tests/fuzz_cases/pruning.rs
@@ -361,7 +361,7 @@ static VALUES: LazyLock<Vec<String>> = 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/fuzz_cases/scalar_value_fuzz.rs b/datafusion/core/tests/fuzz_cases/scalar_value_fuzz.rs
index 3ac6d89e1d..da65c4a1d9 100644
--- a/datafusion/core/tests/fuzz_cases/scalar_value_fuzz.rs
+++ b/datafusion/core/tests/fuzz_cases/scalar_value_fuzz.rs
@@ -195,19 +195,19 @@ fn type_parameter_mutations(scalar: &ScalarValue) -> Vec<(MutationKind, ScalarVa
),
TimestampSecond(value, timezone) => vec![(
MutationKind::TimestampTimezone,
- TimestampSecond(*value, toggled_timezone(timezone)),
+ TimestampSecond(*value, toggled_timezone(timezone.as_ref())),
)],
TimestampMillisecond(value, timezone) => vec![(
MutationKind::TimestampTimezone,
- TimestampMillisecond(*value, toggled_timezone(timezone)),
+ TimestampMillisecond(*value, toggled_timezone(timezone.as_ref())),
)],
TimestampMicrosecond(value, timezone) => vec![(
MutationKind::TimestampTimezone,
- TimestampMicrosecond(*value, toggled_timezone(timezone)),
+ TimestampMicrosecond(*value, toggled_timezone(timezone.as_ref())),
)],
TimestampNanosecond(value, timezone) => vec![(
MutationKind::TimestampTimezone,
- TimestampNanosecond(*value, toggled_timezone(timezone)),
+ TimestampNanosecond(*value, toggled_timezone(timezone.as_ref())),
)],
FixedSizeBinary(width, _) => vec![(
MutationKind::FixedSizeBinaryWidth,
@@ -236,7 +236,7 @@ fn different_scale(scale: i8) -> i8 {
}
fn toggled_timezone(
- timezone: &Option<std::sync::Arc<str>>,
+ timezone: Option<&std::sync::Arc<str>>,
) -> Option<std::sync::Arc<str>> {
if timezone.is_some() {
None
diff --git a/datafusion/core/tests/memory_limit/mod.rs b/datafusion/core/tests/memory_limit/mod.rs
index 02856ebb5a..15b224d200 100644
--- a/datafusion/core/tests/memory_limit/mod.rs
+++ b/datafusion/core/tests/memory_limit/mod.rs
@@ -909,7 +909,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/dynamic_row_group_pruning.rs b/datafusion/core/tests/parquet/dynamic_row_group_pruning.rs
index 678aad9f5b..251b7cddd5 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 8fd9689ae3..81acba37cb 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/parquet/filter_pushdown.rs b/datafusion/core/tests/parquet/filter_pushdown.rs
index 25952f8193..d337979e5f 100644
--- a/datafusion/core/tests/parquet/filter_pushdown.rs
+++ b/datafusion/core/tests/parquet/filter_pushdown.rs
@@ -565,7 +565,7 @@ impl<'a> TestCase<'a> {
self.name
);
}
- };
+ }
let (page_index_rows_pruned, page_index_rows_matched) =
get_pruning_metrics(&metrics, "page_index_rows_pruned");
@@ -590,7 +590,7 @@ impl<'a> TestCase<'a> {
"Expected to filter rows via page index but none were",
);
}
- };
+ }
batch
}
diff --git a/datafusion/core/tests/parquet/mod.rs b/datafusion/core/tests/parquet/mod.rs
index cf2e557aba..7080637763 100644
--- a/datafusion/core/tests/parquet/mod.rs
+++ b/datafusion/core/tests/parquet/mod.rs
@@ -902,25 +902,25 @@ fn make_dictionary_batch(strings: Vec<&str>, integers: Vec<i32>) -> 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/core/tests/physical_optimizer/enforce_distribution.rs b/datafusion/core/tests/physical_optimizer/enforce_distribution.rs
index 489076331b..1f742bc38b 100644
--- a/datafusion/core/tests/physical_optimizer/enforce_distribution.rs
+++ b/datafusion/core/tests/physical_optimizer/enforce_distribution.rs
@@ -1486,7 +1486,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);
@@ -1555,7 +1555,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 76af9b0c29..f298fa1e47 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}",
@@ -1465,7 +1465,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
");
}
- };
+ }
})
}
}
@@ -1577,7 +1577,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
");
}
- };
+ }
})
}
}
@@ -2922,7 +2922,7 @@ async fn test_partial_sort_with_homogeneous_batches() -> Result<()> {
.downcast_ref::<Int32Array>()
.unwrap();
let actual = c_array.values().iter().copied().collect::<Vec<i32>>();
- 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/core/tests/physical_optimizer/join_selection.rs b/datafusion/core/tests/physical_optimizer/join_selection.rs
index 5bf457ed5d..5617f5bd89 100644
--- a/datafusion/core/tests/physical_optimizer/join_selection.rs
+++ b/datafusion/core/tests/physical_optimizer/join_selection.rs
@@ -1896,6 +1896,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 4e8d479740..10bdcd2d5d 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 0b66a49eea..9f72c2c66f 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 da7fdd8879..a1a8e3aa14 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-arrow/src/file_format.rs b/datafusion/datasource-arrow/src/file_format.rs
index c50ad98dfc..2bee57ef17 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 a094fdc3bf..f14924563c 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 62d03d67cc..211011f95c 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/nested_schema_pruning.rs b/datafusion/datasource-parquet/src/nested_schema_pruning.rs
index 2f7ceba3c6..f84ae78884 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<HashMap<&'a str, &'a FieldRef>>,
+ 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/datasource-parquet/src/page_filter.rs b/datafusion/datasource-parquet/src/page_filter.rs
index 236a08c560..cd28eb24fd 100644
--- a/datafusion/datasource-parquet/src/page_filter.rs
+++ b/datafusion/datasource-parquet/src/page_filter.rs
@@ -234,7 +234,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/sink.rs b/datafusion/datasource-parquet/src/sink.rs
index 53f6f1e6b4..1b79ae665b 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/datasource-parquet/src/sort.rs b/datafusion/datasource-parquet/src/sort.rs
index b5bcd7eaba..e60c257652 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/datasource-parquet/src/source.rs b/datafusion/datasource-parquet/src/source.rs
index 28bdf71065..087da50365 100644
--- a/datafusion/datasource-parquet/src/source.rs
+++ b/datafusion/datasource-parquet/src/source.rs
@@ -805,7 +805,7 @@ impl FileSource for ParquetSource {
guarantees.join(", ")
)?;
}
- };
+ }
Ok(())
}
DisplayFormatType::TreeRender => {
diff --git a/datafusion/datasource-parquet/src/statistics_order_tests.rs b/datafusion/datasource-parquet/src/statistics_order_tests.rs
index 5081abf2cb..e25c2c0da5 100644
--- a/datafusion/datasource-parquet/src/statistics_order_tests.rs
+++ b/datafusion/datasource-parquet/src/statistics_order_tests.rs
@@ -414,7 +414,7 @@ fn large_string_in_list_preserves_rows_with_untrusted_page_order() {
},
"order={order:?}",
);
- assert_eq!(file.matching_rows(&physical, pages), 1, "order={order:?}",);
+ assert_eq!(file.matching_rows(&physical, pages), 1, "order={order:?}");
assert_eq!(
file_metrics.page_index_rows_pruned.pruned(),
if order == StatisticsOrder::Modern {
diff --git a/datafusion/datasource/src/boundary_stream.rs b/datafusion/datasource/src/boundary_stream.rs
index 496a740853..a1d10651b5 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/decoder.rs b/datafusion/datasource/src/decoder.rs
index 9f9fc0d94b..a21aaedc52 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 6daed7c338..619d2cf2ef 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
}
@@ -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/datasource/src/write/orchestration.rs b/datafusion/datasource/src/write/orchestration.rs
index f75671d950..cd821b3b87 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/cache_manager.rs b/datafusion/execution/src/cache/cache_manager.rs
index 5b8c098e3a..bbbcaa4c77 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<Path>) -> Vec<ObjectMeta> {
+ fn filter_by_prefix(&self, prefix: Option<&Path>) -> Vec<ObjectMeta> {
match prefix {
Some(prefix) => self
.files
@@ -194,7 +194,7 @@ impl CachedFileList {
pub fn files_matching_prefix(&self, prefix: &Option<Path>) -> Arc<Vec<ObjectMeta>> {
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/execution/src/cache/lru_queue.rs b/datafusion/execution/src/cache/lru_queue.rs
index a19f13865f..96e33df212 100644
--- a/datafusion/execution/src/cache/lru_queue.rs
+++ b/datafusion/execution/src/cache/lru_queue.rs
@@ -184,7 +184,7 @@ impl<K: Eq + Hash + Clone, V> LruQueue<K, V> {
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 40a79d136b..c7c40969f1 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/interval_arithmetic.rs b/datafusion/expr-common/src/interval_arithmetic.rs
index 68541e1e6b..9f1291353d 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-common/src/statistics.rs b/datafusion/expr-common/src/statistics.rs
index 034358b043..6e4d700552 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 77ef1f59f7..381897ae86 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<DataType> {
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 f9c0662e68..3b708b4ede 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(())
}
@@ -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,
@@ -3262,7 +3262,7 @@ impl Display for SchemaDisplay<'_> {
" ORDER BY [{}]",
schema_name_from_sorts(order_by)?
)?;
- };
+ }
write!(f, " {window_frame}")
}
@@ -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/expr_rewriter/mod.rs b/datafusion/expr/src/expr_rewriter/mod.rs
index 7a6ac3fc8b..4e9839e2f7 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<Item = Expr>) -> Vec<Expr> {
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/expr/src/logical_plan/display.rs b/datafusion/expr/src/logical_plan/display.rs
index 09f41c94f6..4afbb56702 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 f36653694c..070a81f41b 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 1a8cd81aa7..2c909b6534 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,
@@ -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:")
@@ -4865,7 +4865,7 @@ impl Unnest {
));
}
_ => {}
- };
+ }
}
// new columns dependent on the same original index
@@ -4956,7 +4956,7 @@ fn get_unnested_columns(
_ => {
return internal_err!("trying to unnest on invalid data type {data_type}");
}
- };
+ }
Ok(qualified_columns)
}
@@ -4978,7 +4978,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 ec3ab6f441..781559ddd0 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 ce0457c3cb..8f7e9cc6cf 100644
--- a/datafusion/expr/src/udaf.rs
+++ b/datafusion/expr/src/udaf.rs
@@ -1043,7 +1043,7 @@ impl<'a> UdafSchemaNameBuilder<'a> {
if let Some(filter) = filter {
schema_name.write_fmt(format_args!(" FILTER (WHERE {filter})"))?;
- };
+ }
if !order_by.is_empty() {
let clause = match supports_within_group_clause {
@@ -1056,7 +1056,7 @@ impl<'a> UdafSchemaNameBuilder<'a> {
clause,
schema_name_from_sorts(order_by)?
))?;
- };
+ }
Ok(schema_name)
}
@@ -1132,14 +1132,14 @@ impl<'a> UdafHumanDisplayBuilder<'a> {
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)
}
@@ -1426,7 +1426,7 @@ impl<'a> UdafWindowFunctionDisplayNameBuilder<'a> {
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 d9db35875a..fa507a0618 100644
--- a/datafusion/expr/src/window_frame.rs
+++ b/datafusion/expr/src/window_frame.rs
@@ -135,7 +135,7 @@ impl TryFrom<ast::WindowFrame> 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 fd424467ab..b5083a3b77 100644
--- a/datafusion/expr/src/window_state.rs
+++ b/datafusion/expr/src/window_state.rs
@@ -87,7 +87,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 a8f7594700..139e64e999 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/expr/distribution.rs b/datafusion/ffi/src/expr/distribution.rs
index 91b6c4ce75..feacbdc6b0 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/ffi/src/proto/logical_extension_codec.rs b/datafusion/ffi/src/proto/logical_extension_codec.rs
index 2668421a93..7c49983cd5 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<Handle> {
+ 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<Arc<TaskContext>> {
@@ -151,7 +151,7 @@ unsafe extern "C" fn try_decode_table_provider_fn_wrapper(
schema: WrappedSchema,
) -> FFI_Result<FFI_TableProvider> {
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())
}
@@ -579,7 +579,7 @@ mod tests {
if !node.is::<MemTable>() {
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 ad8a208967..21da5acbc0 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<Handle> {
+ 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<u8>,
inputs: SVec<FFI_ExecutionPlan>,
) -> FFI_Result<FFI_ExecutionPlan> {
- let runtime = codec.runtime().clone();
+ let runtime = codec.runtime().cloned();
let task_ctx: Arc<TaskContext> =
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())
}
@@ -534,7 +534,7 @@ pub(crate) mod tests {
let udf = node.inner();
if !udf.is::<AbsFunc>() {
return exec_err!("TestExtensionCodec only expects Abs UDF");
- };
+ }
buf.push(Self::ABS_FUNC_SERIALIZED);
diff --git a/datafusion/ffi/src/session/mod.rs b/datafusion/ffi/src/session/mod.rs
index f215a6ba5a..9c37158a2c 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<Handle> {
+ 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<u8>,
) -> FfiFuture<FFI_Result<FFI_ExecutionPlan>> {
unsafe {
- let runtime = session.runtime().clone();
+ let runtime = session.runtime().cloned();
let session = session.clone();
async move {
let logical_codec: Arc<dyn LogicalExtensionCodec> =
@@ -375,7 +375,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<FFI_PhysicalOptimizerRule> {
- 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 de226f780e..7f3deccbb2 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<Handle> {
+ 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<FFI_Result<FFI_ExecutionPlan>> {
let task_ctx: Result<Arc<TaskContext>, DataFusionError> =
(&provider.logical_codec.task_ctx_provider).try_into();
- let runtime = provider.runtime().clone();
+ let runtime = provider.runtime().cloned();
let logical_codec: Arc<dyn LogicalExtensionCodec> = (&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<FFI_Result<FFI_ExecutionPlan>> {
- 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<FFI_Result<FFI_ExecutionPlan>> {
let task_ctx: Result<Arc<TaskContext>, DataFusionError> =
(&provider.logical_codec.task_ctx_provider).try_into();
- let runtime = provider.runtime().clone();
+ let runtime = provider.runtime().cloned();
let logical_codec: Arc<dyn LogicalExtensionCodec> = (&provider.logical_codec).into();
let internal_provider = Arc::clone(provider.inner());
@@ -411,7 +411,7 @@ unsafe extern "C" fn update_fn_wrapper(
) -> FfiFuture<FFI_Result<FFI_ExecutionPlan>> {
let task_ctx: Result<Arc<TaskContext>, DataFusionError> =
(&provider.logical_codec.task_ctx_provider).try_into();
- let runtime = provider.runtime().clone();
+ let runtime = provider.runtime().cloned();
let logical_codec: Arc<dyn LogicalExtensionCodec> = (&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<FFI_Result<FFI_ExecutionPlan>> {
- 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 63ebb51bb1..5972be38d3 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<Handle> {
+ 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<u8>,
) -> Result<FFI_TableProvider, DataFusionError> {
- 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/ffi/src/udaf/accumulator.rs b/datafusion/ffi/src/udaf/accumulator.rs
index 4d696cadb7..8e6e5983bb 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<dyn Accumulator> = Box::new(original_accum);
diff --git a/datafusion/ffi/src/udaf/groups_accumulator.rs b/datafusion/ffi/src/udaf/groups_accumulator.rs
index ad2714da0c..ddf5204104 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::<std::result::Result<Vec<_>, 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::<std::result::Result<Vec<_>, 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,
@@ -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<dyn GroupsAccumulator> = Box::new(original_accum);
diff --git a/datafusion/ffi/src/udwf/partition_evaluator.rs b/datafusion/ffi/src/udwf/partition_evaluator.rs
index 2e6243ddd1..1074c1a019 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 {};
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 6e0d55bd64..f6df4182a8 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<O: OffsetSizeTrait> Accumulator for BytesDistinctCountAccumulator<O> {
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 00c1a47b9e..17cccc6f2b 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<Vec<ScalarValue>> {
let arr = Arc::new(
- PrimitiveArray::<T>::from_iter_values(self.values.iter().cloned())
+ PrimitiveArray::<T>::from_iter_values(self.values.iter().copied())
.with_data_type(self.data_type.clone()),
);
Ok(vec![
@@ -115,7 +115,7 @@ where
if let Some(list) = maybe_list {
let list = as_primitive_array::<T>(&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-common/src/min_max.rs b/datafusion/functions-aggregate-common/src/min_max.rs
index 2c381faccc..f0a4a52a4a 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<T: Clone + Ord>(
- lhs: &Option<T>,
- rhs: &Option<T>,
+ lhs: Option<&T>,
+ rhs: Option<&T>,
ordering: Ordering,
) -> Option<T> {
match (lhs, rhs) {
@@ -65,8 +65,8 @@ fn min_max_option<T: Clone + Ord>(
}
fn min_max_float_option<T: Copy>(
- lhs: &Option<T>,
- rhs: &Option<T>,
+ lhs: Option<&T>,
+ rhs: Option<&T>,
ordering: Ordering,
cmp: impl Fn(&T, &T) -> Ordering,
) -> Option<T> {
@@ -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-aggregate-common/src/utils.rs b/datafusion/functions-aggregate-common/src/utils.rs
index 256d80a67b..abe2c9a79c 100644
--- a/datafusion/functions-aggregate-common/src/utils.rs
+++ b/datafusion/functions-aggregate-common/src/utils.rs
@@ -237,7 +237,7 @@ impl<T: ArrowPrimitiveType> GenericDistinctBuffer<T> {
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/count.rs b/datafusion/functions-aggregate/src/count.rs
index 87d3adeca2..a3ebe0699e 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<DictionaryArray<Int32Type>> {
let values = StringArray::from(vec![Some("a"), None, Some("c")]);
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 efeaea314c..16ec40abad 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-aggregate/src/sum.rs b/datafusion/functions-aggregate/src/sum.rs
index 1999f68d4c..5b8ad51a5a 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::<Vec<_>>();
diff --git a/datafusion/functions-nested/benches/array_slice.rs b/datafusion/functions-nested/benches/array_slice.rs
index b95fe47575..55e8de2ed8 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-nested/src/array_has.rs b/datafusion/functions-nested/src/array_has.rs
index 9ae521b401..24a9913d2c 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 787886f795..f9384586d6 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 e08149ec0f..0332ea7d5d 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 4b4fc01af9..cf5e026581 100644
--- a/datafusion/functions-table/src/generate_series.rs
+++ b/datafusion/functions-table/src/generate_series.rs
@@ -623,7 +623,7 @@ impl GenerateSeriesFuncImpl {
other
);
}
- };
+ }
}
let schema = Arc::new(Schema::new(vec![Field::new(
diff --git a/datafusion/functions/benches/unicode_expressions/substr.rs b/datafusion/functions/benches/unicode_expressions/substr.rs
index c98c7d99c2..a59dd7a007 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::<i32>(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::<i32>(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::<i64>(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::<i32>(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::<i32>(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::<i64>(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/common.rs b/datafusion/functions/src/datetime/common.rs
index efde66beba..118b6b371b 100644
--- a/datafusion/functions/src/datetime/common.rs
+++ b/datafusion/functions/src/datetime/common.rs
@@ -56,10 +56,10 @@ static UTC: LazyLock<Tz> = 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<Tz>,
+ timezone: Option<&Tz>,
s: &str,
) -> Result<i64> {
- 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<T: TimeZone>(
/// [`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<Tz>,
+ timezone: Option<&Tz>,
s: &str,
format: &str,
) -> Result<i64, DataFusionError> {
- 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}"))?;
@@ -521,7 +521,7 @@ where
val = Some(r);
}
}
- };
+ }
val.transpose()
})
diff --git a/datafusion/functions/src/datetime/date_bin.rs b/datafusion/functions/src/datetime/date_bin.rs
index c973015843..15cdecc3c2 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<Arc<str>>,
+ tz_opt: Option<&Arc<str>>,
) -> Result<ColumnarValue>
where
T: ArrowTimestampType,
@@ -697,29 +697,45 @@ fn date_bin_impl(
date_bin_timestamp_value::<T>(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::<TimestampNanosecondType>(
- origin, stride, stride_fn, array, tz_opt,
+ origin,
+ stride,
+ stride_fn,
+ array,
+ tz_opt.as_ref(),
)?
}
Timestamp(Microsecond, tz_opt) => {
transform_array_with_stride::<TimestampMicrosecondType>(
- origin, stride, stride_fn, array, tz_opt,
+ origin,
+ stride,
+ stride_fn,
+ array,
+ tz_opt.as_ref(),
)?
}
Timestamp(Millisecond, tz_opt) => {
transform_array_with_stride::<TimestampMillisecondType>(
- origin, stride, stride_fn, array, tz_opt,
+ origin,
+ stride,
+ stride_fn,
+ array,
+ tz_opt.as_ref(),
)?
}
Timestamp(Second, tz_opt) => {
transform_array_with_stride::<TimestampSecondType>(
- 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 0c73a06c3b..926653c0d1 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<T: ArrowTimestampType>(
array: &dyn Array,
granularity: DateTruncGranularity,
- tz_opt: &Option<Arc<str>>,
+ tz_opt: Option<&Arc<str>>,
) -> Result<ColumnarValue> {
let parsed_tz = parse_tz(tz_opt)?;
let array = as_primitive_array::<T>(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<T> = 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<T: ArrowTimestampType>(
- v: &Option<i64>,
+ v: Option<&i64>,
granularity: DateTruncGranularity,
- tz_opt: &Option<Arc<str>>,
+ tz_opt: Option<&Arc<str>>,
) -> Result<ColumnarValue> {
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::<T>(value, tz_opt.clone());
+ let value = ScalarValue::new_timestamp::<T>(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::<TimestampNanosecondType>(v, granularity, tz_opt)?
+ process_scalar::<TimestampNanosecondType>(
+ v.as_ref(),
+ granularity,
+ tz_opt.as_ref(),
+ )?
}
ColumnarValue::Scalar(ScalarValue::TimestampMicrosecond(v, tz_opt)) => {
- process_scalar::<TimestampMicrosecondType>(v, granularity, tz_opt)?
+ process_scalar::<TimestampMicrosecondType>(
+ v.as_ref(),
+ granularity,
+ tz_opt.as_ref(),
+ )?
}
ColumnarValue::Scalar(ScalarValue::TimestampMillisecond(v, tz_opt)) => {
- process_scalar::<TimestampMillisecondType>(v, granularity, tz_opt)?
+ process_scalar::<TimestampMillisecondType>(
+ v.as_ref(),
+ granularity,
+ tz_opt.as_ref(),
+ )?
}
ColumnarValue::Scalar(ScalarValue::TimestampSecond(v, tz_opt)) => {
- process_scalar::<TimestampSecondType>(v, granularity, tz_opt)?
+ process_scalar::<TimestampSecondType>(
+ 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::<TimestampSecondType>(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::<TimestampSecondType>(
+ array,
+ granularity,
+ tz_opt.as_ref(),
)?,
+ Timestamp(Millisecond, tz_opt) => {
+ process_array::<TimestampMillisecondType>(
+ array,
+ granularity,
+ tz_opt.as_ref(),
+ )?
+ }
+ Timestamp(Microsecond, tz_opt) => {
+ process_array::<TimestampMicrosecondType>(
+ array,
+ granularity,
+ tz_opt.as_ref(),
+ )?
+ }
+ Timestamp(Nanosecond, tz_opt) => {
+ process_array::<TimestampNanosecondType>(
+ array,
+ granularity,
+ tz_opt.as_ref(),
+ )?
+ }
Time64(Nanosecond) => {
let arr = as_primitive_array::<Time64NanosecondType>(array)?;
let result: PrimitiveArray<Time64NanosecondType> =
@@ -866,13 +890,12 @@ fn general_date_trunc(
Ok(result)
}
-fn parse_tz(tz: &Option<Arc<str>>) -> Result<Option<Tz>> {
- 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<str>>) -> Result<Option<Tz>> {
+ 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_date.rs b/datafusion/functions/src/datetime/to_date.rs
index 3c4c780b10..54f3f117b0 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/functions/src/datetime/to_timestamp.rs b/datafusion/functions/src/datetime/to_timestamp.rs
index dd85551137..57a2634a2a 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::<TimestampNanosecondType>(&args, "to_timestamp", &tz)
- }
+ Utf8View | LargeUtf8 | Utf8 => to_timestamp_impl::<TimestampNanosecondType>(
+ &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::<TimestampSecondType>(
&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::<TimestampMillisecondType>(
&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::<TimestampMicrosecondType>(
&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::<TimestampNanosecondType>(
&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<T: ArrowTimestampType + ScalarType<i64>>(
args: &[ColumnarValue],
name: &str,
- timezone: &Option<Arc<str>>,
+ timezone: Option<&Arc<str>>,
) -> Result<ColumnarValue> {
let factor = match T::UNIT {
Second => 1_000_000_000,
@@ -803,7 +805,7 @@ fn to_timestamp_impl<T: ArrowTimestampType + ScalarType<i64>>(
Nanosecond => 1,
};
- let tz = match timezone.clone() {
+ let tz = match timezone {
Some(tz) => Some(tz.parse::<Tz>()?),
None => None,
};
@@ -811,18 +813,21 @@ fn to_timestamp_impl<T: ArrowTimestampType + ScalarType<i64>>(
match args.len() {
1 => handle::<T, _>(
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::<T, _, _>(
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}"),
}
@@ -849,7 +854,11 @@ mod tests {
fn to_timestamp(args: &[ColumnarValue]) -> Result<ColumnarValue> {
let timezone: Option<Arc<str>> = Some("UTC".into());
- to_timestamp_impl::<TimestampNanosecondType>(args, "to_timestamp", &timezone)
+ to_timestamp_impl::<TimestampNanosecondType>(
+ args,
+ "to_timestamp",
+ timezone.as_ref(),
+ )
}
/// to_timestamp_millis SQL function
@@ -858,7 +867,7 @@ mod tests {
to_timestamp_impl::<TimestampMillisecondType>(
args,
"to_timestamp_millis",
- &timezone,
+ timezone.as_ref(),
)
}
@@ -868,7 +877,7 @@ mod tests {
to_timestamp_impl::<TimestampMicrosecondType>(
args,
"to_timestamp_micros",
- &timezone,
+ timezone.as_ref(),
)
}
@@ -878,14 +887,18 @@ mod tests {
to_timestamp_impl::<TimestampNanosecondType>(
args,
"to_timestamp_nanos",
- &timezone,
+ timezone.as_ref(),
)
}
/// to_timestamp_seconds SQL function
fn to_timestamp_seconds(args: &[ColumnarValue]) -> Result<ColumnarValue> {
let timezone: Option<Arc<str>> = Some("UTC".into());
- to_timestamp_impl::<TimestampSecondType>(args, "to_timestamp_seconds", &timezone)
+ to_timestamp_impl::<TimestampSecondType>(
+ args,
+ "to_timestamp_seconds",
+ timezone.as_ref(),
+ )
}
fn udfs_and_timeunit() -> Vec<(Box<dyn ScalarUDFImpl>, TimeUnit)> {
@@ -1636,11 +1649,9 @@ mod tests {
}
fn parse_timestamp_formatted(s: &str, format: &str) -> Result<i64, DataFusionError> {
- 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:?}");
}
@@ -1885,7 +1896,7 @@ mod tests {
Second => {
assert_eq!(sec_expected_timestamps, parsed_array.as_ref())
}
- };
+ }
} else {
panic!("Expected a columnar array")
}
@@ -1919,7 +1930,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 732cfff6cf..77a730808d 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 6724171203..caeab9d745 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/regexpcount.rs b/datafusion/functions/src/regex/regexpcount.rs
index 8e8b4436e3..2920b687ed 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 96152297fb..de460c56f6 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/functions/src/regex/regexpreplace.rs b/datafusion/functions/src/regex/regexpreplace.rs
index ec4afbad47..8b6dc997a9 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 95b70da443..5614948c9e 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/extract_leaf_expressions.rs b/datafusion/optimizer/src/extract_leaf_expressions.rs
index 4f9e94fad8..107758cf6b 100644
--- a/datafusion/optimizer/src/extract_leaf_expressions.rs
+++ b/datafusion/optimizer/src/extract_leaf_expressions.rs
@@ -1681,8 +1681,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/optimizer/src/optimize_projections/mod.rs b/datafusion/optimizer/src/optimize_projections/mod.rs
index 413efd9558..b0543a871f 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 8f72c1a8c3..8a1dcc12ef 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)
)
@@ -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 21389cf326..4b3b657958 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 7dccb5b1b9..97417bc112 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 1b07cfa428..d0165b568a 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 8815c5d434..4523fee7cd 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`
@@ -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 d05a419c1c..6154616b6e 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`
@@ -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-common/src/metrics/mod.rs b/datafusion/physical-expr-common/src/metrics/mod.rs
index 7292c94ba4..516a947685 100644
--- a/datafusion/physical-expr-common/src/metrics/mod.rs
+++ b/datafusion/physical-expr-common/src/metrics/mod.rs
@@ -941,7 +941,7 @@ mod tests {
_ => {
panic!("Not a timestamp");
}
- };
+ }
let mut ts = aggregated
.iter()
@@ -959,7 +959,7 @@ mod tests {
_ => {
panic!("Not a timestamp");
}
- };
+ }
}
#[test]
diff --git a/datafusion/physical-expr/benches/case_when.rs b/datafusion/physical-expr/benches/case_when.rs
index 33931a2ba9..b6c45f002d 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 24ca0ae176..4c266a7fbe 100644
--- a/datafusion/physical-expr/benches/in_list_strategy.rs
+++ b/datafusion/physical-expr/benches/in_list_strategy.rs
@@ -759,7 +759,7 @@ fn bench_dict_int32(
let mut rng = StdRng::seed_from_u64(seed);
let dict_values: Vec<i32> = (0..dict_size).map(|_| rng.random()).collect();
- let haystack: Vec<i32> = dict_values.iter().take(list_size).cloned().collect();
+ let haystack: Vec<i32> = dict_values.iter().take(list_size).copied().collect();
let indices: Vec<i32> = (0..ARRAY_SIZE)
.map(|_| rng.random_range(0..dict_size as i32))
@@ -1169,6 +1169,8 @@ fn generate_fixed_size_binary_data(
(haystack, values)
}
+// The cast only checks alignment; the pointer is never dereferenced.
+#[expect(clippy::cast_ptr_alignment)]
fn unaligned_fixed_size_binary_16(values: &[Vec<u8>]) -> FixedSizeBinaryArray {
const WIDTH: usize = 16;
let payload_len = values.len() * WIDTH;
diff --git a/datafusion/physical-expr/src/analysis.rs b/datafusion/physical-expr/src/analysis.rs
index 2f46ba42d3..ceac0094ed 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/ordering.rs b/datafusion/physical-expr/src/equivalence/ordering.rs
index 499187a603..12f243357e 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-expr/src/equivalence/properties/dependency.rs b/datafusion/physical-expr/src/equivalence/properties/dependency.rs
index bd8bef84de..082c1e7d2d 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/expressions/in_list.rs b/datafusion/physical-expr/src/expressions/in_list.rs
index a505f3d077..0a4ad0b804 100644
--- a/datafusion/physical-expr/src/expressions/in_list.rs
+++ b/datafusion/physical-expr/src/expressions/in_list.rs
@@ -896,7 +896,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-expr/src/expressions/in_list/fixed_size_binary_filter.rs b/datafusion/physical-expr/src/expressions/in_list/fixed_size_binary_filter.rs
index b0e86cf932..86592b0c9f 100644
--- a/datafusion/physical-expr/src/expressions/in_list/fixed_size_binary_filter.rs
+++ b/datafusion/physical-expr/src/expressions/in_list/fixed_size_binary_filter.rs
@@ -321,6 +321,8 @@ mod tests {
Ok(())
}
+ // The cast only checks alignment; the pointer is never dereferenced.
+ #[expect(clippy::cast_ptr_alignment)]
fn unaligned_i128_array(
values: &[Vec<u8>],
nulls: Option<NullBuffer>,
diff --git a/datafusion/physical-expr/src/utils/guarantee.rs b/datafusion/physical-expr/src/utils/guarantee.rs
index c36e696036..8b870c573d 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/physical-expr/src/window/window_expr.rs b/datafusion/physical-expr/src/window/window_expr.rs
index 59edd5e865..0af4f0a4eb 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 0368577f9a..7b4c748030 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(
@@ -1382,7 +1382,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.
@@ -1578,7 +1578,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 42a1572573..e9467d508a 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 6ab84dc95e..d7b3f16a8f 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 03a28e5f64..1f7acd8f86 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-optimizer/src/output_requirements.rs b/datafusion/physical-optimizer/src/output_requirements.rs
index 5419812701..83cef91ec4 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<usize>,
) -> 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<dyn ExecutionPlan>,
- fetch: &Option<usize>,
+ fetch: Option<usize>,
) -> PlanProperties {
let boundedness = if fetch.is_some() {
Boundedness::Bounded
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 3b0e9bcb0c..8d6dabc141 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
@@ -263,7 +263,7 @@ where
self.append_val_inner::<GenericStringType<O>>(column, row)?
}
_ => unreachable!("View types should use `ArrowBytesViewMap`"),
- };
+ }
Ok(())
}
@@ -322,7 +322,7 @@ where
self.vectorized_append_inner::<GenericStringType<O>>(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 3b3dba8620..3f6f3f8ce8 100644
--- a/datafusion/physical-plan/src/aggregates/grouped_hash_stream.rs
+++ b/datafusion/physical-plan/src/aggregates/grouped_hash_stream.rs
@@ -714,7 +714,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;
}
@@ -1403,7 +1403,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
@@ -1418,7 +1418,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/hash_stream.rs b/datafusion/physical-plan/src/aggregates/hash_stream.rs
index 2df5960188..340bf5cfc1 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/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs
index 375e392e6a..f00f1a160e 100644
--- a/datafusion/physical-plan/src/aggregates/mod.rs
+++ b/datafusion/physical-plan/src/aggregates/mod.rs
@@ -2836,7 +2836,7 @@ pub fn concat_slices<T: Clone>(lhs: &[T], rhs: &[T]) -> Vec<T> {
// 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<LexOrdering>,
+ current: Option<&LexOrdering>,
candidate: &LexOrdering,
) -> Option<bool> {
if let Some(ordering) = current {
@@ -2894,7 +2894,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;
@@ -2921,7 +2921,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())? {
@@ -3557,7 +3558,7 @@ mod tests {
"
);
}
- };
+ }
let merge = Arc::new(CoalescePartitionsExec::new(partial_aggregate));
@@ -3678,7 +3679,7 @@ mod tests {
+---+---------------+-------------+
");
}
- };
+ }
let merge = Arc::new(CoalescePartitionsExec::new(partial_aggregate));
@@ -5274,7 +5275,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 259411b00b..147e4e0d6f 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/ordered_final_stream.rs b/datafusion/physical-plan/src/aggregates/ordered_final_stream.rs
index 2c26b74da7..8823dcb32f 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 da00b42e5c..701dee4e81 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 2f4535e66f..9eedf86847 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 3e306d72a7..7b8b08c15b 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/aggregates/topk/priority_map.rs b/datafusion/physical-plan/src/aggregates/topk/priority_map.rs
index f46cb22a7a..f36e0f7628 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 e1452b75bc..df87fee7da 100644
--- a/datafusion/physical-plan/src/buffer.rs
+++ b/datafusion/physical-plan/src/buffer.rs
@@ -478,7 +478,7 @@ impl<T: Send + SizedMessage + 'static> MemoryBufferedStream<T> {
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 0b3359bc7c..9da7df822f 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/execution_plan.rs b/datafusion/physical-plan/src/execution_plan.rs
index c0fa4c6bed..6cb3eeef8c 100644
--- a/datafusion/physical-plan/src/execution_plan.rs
+++ b/datafusion/physical-plan/src/execution_plan.rs
@@ -1472,7 +1472,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/hash_join/exec.rs b/datafusion/physical-plan/src/joins/hash_join/exec.rs
index 1b36dabebc..1539fd4e73 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<PartitionBounds>,
+ bounds: Option<&PartitionBounds>,
schema: &SchemaRef,
batches: &[RecordBatch],
on_left: &[PhysicalExprRef],
@@ -2666,7 +2666,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/hash_join/stream.rs b/datafusion/physical-plan/src/joins/hash_join/stream.rs
index fe6eaff9e5..e01a751777 100644
--- a/datafusion/physical-plan/src/joins/hash_join/stream.rs
+++ b/datafusion/physical-plan/src/joins/hash_join/stream.rs
@@ -731,7 +731,7 @@ impl HashJoinStream {
});
}
Some(Err(err)) => return Poll::Ready(Err(err)),
- };
+ }
Poll::Ready(Ok(StatefulStreamResult::Continue))
}
@@ -993,7 +993,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/nested_loop_join.rs b/datafusion/physical-plan/src/joins/nested_loop_join.rs
index bb91735369..f63418f63e 100644
--- a/datafusion/physical-plan/src/joins/nested_loop_join.rs
+++ b/datafusion/physical-plan/src/joins/nested_loop_join.rs
@@ -1384,9 +1384,9 @@ pub(crate) struct NestedLoopJoinStream {
pub(crate) left_data: OnceFut<LeftLoad>,
/// 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.
@@ -1532,7 +1532,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,
}
}
@@ -1567,7 +1567,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,
}
}
@@ -1594,7 +1594,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);
}
@@ -1615,7 +1615,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);
}
@@ -1637,7 +1637,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);
}
@@ -1667,7 +1667,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);
}
@@ -1686,7 +1686,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/joins/piecewise_merge_join/classic_join.rs b/datafusion/physical-plan/src/joins/piecewise_merge_join/classic_join.rs
index 41da213beb..4eebbcf079 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
@@ -259,7 +259,7 @@ impl ClassicPWMJStream {
);
}
Some(Err(err)) => return Poll::Ready(Err(err)),
- };
+ }
Poll::Ready(Ok(StatefulStreamResult::Continue))
}
@@ -548,7 +548,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/filter.rs b/datafusion/physical-plan/src/joins/sort_merge_join/filter.rs
index 4fc6cccaa8..306a154666 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<JoinFilter>,
+ 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<JoinFilter>,
+ join_filter: Option<&JoinFilter>,
left_columns: &[ArrayRef],
right_columns: &[ArrayRef],
) -> Vec<ArrayRef> {
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 43306248d0..96b903f63b 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
@@ -566,7 +566,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: new_output_coalescer(Arc::clone(&schema), batch_size),
@@ -1548,9 +1548,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/physical-plan/src/joins/utils.rs b/datafusion/physical-plan/src/joins/utils.rs
index 5e8f3c5de9..4702493f4e 100644
--- a/datafusion/physical-plan/src/joins/utils.rs
+++ b/datafusion/physical-plan/src/joins/utils.rs
@@ -125,7 +125,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(())
}
@@ -798,7 +798,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,
@@ -1258,7 +1258,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 =
@@ -1966,7 +1966,7 @@ pub(crate) trait BatchTransformer: Debug + Clone {
}
fn count_retained_batch_memory(
- batch: &Option<RecordBatch>,
+ batch: Option<&RecordBatch>,
counter: &mut RecordBatchMemoryCounter,
) {
if let Some(batch) = batch {
@@ -1997,7 +1997,7 @@ impl BatchTransformer for NoopBatchTransformer {
}
fn count_memory(&self, counter: &mut RecordBatchMemoryCounter) {
- count_retained_batch_memory(&self.batch, counter);
+ count_retained_batch_memory(self.batch.as_ref(), counter);
}
}
@@ -2049,7 +2049,7 @@ impl BatchTransformer for BatchSplitter {
}
fn count_memory(&self, counter: &mut RecordBatchMemoryCounter) {
- count_retained_batch_memory(&self.batch, counter);
+ count_retained_batch_memory(self.batch.as_ref(), counter);
}
}
diff --git a/datafusion/physical-plan/src/projection.rs b/datafusion/physical-plan/src/projection.rs
index 2a24eb60e6..c4096457c1 100644
--- a/datafusion/physical-plan/src/projection.rs
+++ b/datafusion/physical-plan/src/projection.rs
@@ -785,7 +785,7 @@ pub fn try_embed_projection<Exec: EmbeddedProjection + 'static>(
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/repartition/mod.rs b/datafusion/physical-plan/src/repartition/mod.rs
index 8f4b8558a5..7822c6facd 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}");
@@ -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/partial_sort.rs b/datafusion/physical-plan/src/sorts/partial_sort.rs
index 478ac14e11..80520d58df 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.rs b/datafusion/physical-plan/src/sorts/sort.rs
index 09655648ab..04629f4608 100644
--- a/datafusion/physical-plan/src/sorts/sort.rs
+++ b/datafusion/physical-plan/src/sorts/sort.rs
@@ -2128,7 +2128,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 c988105108..3551631b41 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)?;
@@ -1940,7 +1940,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/sorts/stream.rs b/datafusion/physical-plan/src/sorts/stream.rs
index 652276c26d..bb9c009493 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 9d0b964886..bc549f4420 100644
--- a/datafusion/physical-plan/src/stream.rs
+++ b/datafusion/physical-plan/src/stream.rs
@@ -133,14 +133,10 @@ impl<O: Send + 'static> ReceiverStreamBuilder<O> {
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() {
@@ -574,7 +570,7 @@ impl ObservedStream {
self.release_inner();
}
return Poll::Ready(Some(Ok(batch)));
- };
+ }
self.produced += batch.num_rows()
}
poll
@@ -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/test/exec.rs b/datafusion/physical-plan/src/test/exec.rs
index 1e2005e908..f9517469d5 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/physical-plan/src/topk/mod.rs b/datafusion/physical-plan/src/topk/mod.rs
index 5fd64389d4..0ca700cb37 100644
--- a/datafusion/physical-plan/src/topk/mod.rs
+++ b/datafusion/physical-plan/src/topk/mod.rs
@@ -823,7 +823,7 @@ impl TopK {
batch = batch.slice(batch_size, remaining_length);
}
}
- };
+ }
Ok(Box::pin(RecordBatchStreamAdapter::new(
schema,
futures::stream::iter(batches),
@@ -1758,9 +1758,9 @@ impl PartitionedTopKRank {
match classification {
Some(Ordering::Equal) => {
equal_indices.push(sub_idx as u32);
- 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/physical-plan/src/visitor.rs b/datafusion/physical-plan/src/visitor.rs
index 892e603a01..31d1bb9831 100644
--- a/datafusion/physical-plan/src/visitor.rs
+++ b/datafusion/physical-plan/src/visitor.rs
@@ -40,7 +40,7 @@ pub fn accept<V: ExecutionPlanVisitor>(
/// 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/physical-plan/src/windows/bounded_window_agg_exec.rs b/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs
index b52be42c5e..0c6e77a1d6 100644
--- a/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs
+++ b/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs
@@ -1846,7 +1846,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 18a877b0df..3f33dfedfd 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-common/src/generated/pbjson.rs b/datafusion/proto-common/src/generated/pbjson.rs
index c222cd1cb8..feaeaf3c5c 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::<std::result::Result<Vec<_>, _>>()?;
diff --git a/datafusion/proto/src/logical_plan/from_proto.rs b/datafusion/proto/src/logical_plan/from_proto.rs
index d4d0ea7292..a1a1ff6f04 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/proto/src/logical_plan/mod.rs b/datafusion/proto/src/logical_plan/mod.rs
index 73cfc6e710..7fa6fd4ed5 100644
--- a/datafusion/proto/src/logical_plan/mod.rs
+++ b/datafusion/proto/src/logical_plan/mod.rs
@@ -377,7 +377,7 @@ fn from_table_reference(
/// method to be used to deserialize nodes
/// serialized by [from_table_source]
fn to_table_source(
- node: &Option<Box<LogicalPlanNode>>,
+ node: Option<&LogicalPlanNode>,
ctx: &TaskContext,
extension_codec: &dyn LogicalExtensionCodec,
) -> Result<Arc<dyn TableSource>> {
@@ -1300,7 +1300,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/proto/tests/cases/plans/dynamic_filters.rs b/datafusion/proto/tests/cases/plans/dynamic_filters.rs
index ee0ff9d8b1..7892ffd9a1 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/pruning/src/pruning_predicate.rs b/datafusion/pruning/src/pruning_predicate.rs
index 4985cadac7..a30d52bd34 100644
--- a/datafusion/pruning/src/pruning_predicate.rs
+++ b/datafusion/pruning/src/pruning_predicate.rs
@@ -5087,6 +5087,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"]
@@ -5096,6 +5097,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)]));
diff --git a/datafusion/spark/benches/substring.rs b/datafusion/spark/benches/substring.rs
index d6eac817c3..ccc3f67a2c 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::<i32>(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::<i32>(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::<i64>(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::<i32>(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::<i32>(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::<i64>(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))),
);
diff --git a/datafusion/spark/src/function/datetime/make_dt_interval.rs b/datafusion/spark/src/function/datetime/make_dt_interval.rs
index 88ccae1b91..f7d093a84a 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<ArrayRef, DataFusionErro
match make_interval_dt_nano(d, h, mi, s) {
Some(v) => 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 abbf398d53..7ccc5cbbc8 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<ArrayRef, DataFusionError>
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/spark/src/function/string/format_string.rs b/datafusion/spark/src/function/string/format_string.rs
index 64346dd823..131d1c14df 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<T>(
&self,
writer: &mut String,
- value: &Option<T>,
+ 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 {
@@ -1565,7 +1581,7 @@ impl ConversionSpecifier {
temp = format!("{prefix}p{iexp}");
}
}
- };
+ }
if self.conversion_type.is_upper() {
temp = temp.to_ascii_uppercase();
@@ -1598,7 +1614,7 @@ impl ConversionSpecifier {
temp = " ".to_owned() + &temp;
}
writer.push_str(&temp);
- };
+ }
Ok(())
}
@@ -1644,8 +1660,8 @@ impl ConversionSpecifier {
}
}
- fn format_boolean(&self, writer: &mut String, value: &Option<bool>) -> 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<Arc<str>>,
+ timezone: Option<&Arc<str>>,
) -> 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<Arc<str>>,
+ _timezone: Option<&Arc<str>>,
) -> Result<String> {
// Convert nanoseconds to seconds and nanoseconds remainder
let secs = timestamp_nanos / 1_000_000_000;
diff --git a/datafusion/spark/src/function/url/parse_url.rs b/datafusion/spark/src/function/url/parse_url.rs
index 1a20cdc10b..c385f43e49 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/expr/subquery.rs b/datafusion/sql/src/expr/subquery.rs
index 662c44f6f2..fb0b1207d6 100644
--- a/datafusion/sql/src/expr/subquery.rs
+++ b/datafusion/sql/src/expr/subquery.rs
@@ -149,7 +149,7 @@ impl<S: ContextProvider> 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/parser.rs b/datafusion/sql/src/parser.rs
index 71493fb9c9..fcf4708f1b 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<T>(field: &Option<T>, name: &str) -> Result<(), DataFusionError> {
+fn ensure_not_set<T>(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()?);
}
_ => {
@@ -1079,7 +1082,7 @@ impl<'a> DFParser<'a> {
options.push(ColumnOptionDef { name: None, option });
} else {
break;
- };
+ }
}
Ok(ColumnDef {
name,
@@ -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/planner.rs b/datafusion/sql/src/planner.rs
index 1db11d66b7..a3e6d75fdb 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 33791227b3..1a9072212f 100644
--- a/datafusion/sql/src/statement.rs
+++ b/datafusion/sql/src/statement.rs
@@ -1091,12 +1091,12 @@ impl<S: ContextProvider> 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<S: ContextProvider> 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/expr.rs b/datafusion/sql/src/unparser/expr.rs
index 898330018c..cd3ac1f3a4 100644
--- a/datafusion/sql/src/unparser/expr.rs
+++ b/datafusion/sql/src/unparser/expr.rs
@@ -1202,7 +1202,7 @@ impl Unparser<'_> {
fn handle_timestamp<T: ArrowTemporalType>(
&self,
v: &ScalarValue,
- tz: &Option<Arc<str>>,
+ tz: Option<&Arc<str>>,
) -> Result<ast::Expr>
where
i64: From<T::Native>,
@@ -1498,25 +1498,25 @@ impl Unparser<'_> {
}
ScalarValue::Time64Nanosecond(None) => Ok(ast::Expr::value(ast::Value::Null)),
ScalarValue::TimestampSecond(Some(_ts), tz) => {
- self.handle_timestamp::<TimestampSecondType>(v, tz)
+ self.handle_timestamp::<TimestampSecondType>(v, tz.as_ref())
}
ScalarValue::TimestampSecond(None, _) => {
Ok(ast::Expr::value(ast::Value::Null))
}
ScalarValue::TimestampMillisecond(Some(_ts), tz) => {
- self.handle_timestamp::<TimestampMillisecondType>(v, tz)
+ self.handle_timestamp::<TimestampMillisecondType>(v, tz.as_ref())
}
ScalarValue::TimestampMillisecond(None, _) => {
Ok(ast::Expr::value(ast::Value::Null))
}
ScalarValue::TimestampMicrosecond(Some(_ts), tz) => {
- self.handle_timestamp::<TimestampMicrosecondType>(v, tz)
+ self.handle_timestamp::<TimestampMicrosecondType>(v, tz.as_ref())
}
ScalarValue::TimestampMicrosecond(None, _) => {
Ok(ast::Expr::value(ast::Value::Null))
}
ScalarValue::TimestampNanosecond(Some(_ts), tz) => {
- self.handle_timestamp::<TimestampNanosecondType>(v, tz)
+ self.handle_timestamp::<TimestampNanosecondType>(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 9922509a0e..30320acbb2 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::<Result<Vec<_>>>()?;
}
- };
+ }
// 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
@@ -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 {
@@ -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
@@ -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);
@@ -2227,7 +2227,7 @@ impl Unparser<'_> {
})
.collect::<Vec<_>>();
builder = builder.project(project_columns)?;
- };
+ }
}
let filter_expr: Result<Option<Expr>> = table_scan
@@ -2571,17 +2571,17 @@ impl Unparser<'_> {
/// Returns `(on_filter, where_filters)`.
fn split_join_on_and_where_filters(
join_type: JoinType,
- join_filter: &Option<Expr>,
+ join_filter: Option<&Expr>,
table_scan_filters: Vec<Expr>,
) -> (Option<Expr>, Vec<Expr>) {
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/sql/src/unparser/rewrite.rs b/datafusion/sql/src/unparser/rewrite.rs
index 6ee66f6193..63cdad5fc8 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 949b49eb77..240032d26c 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 5d01befbf9..3c7087e7dc 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 be5830f4e7..307a8876ab 100644
--- a/datafusion/sqllogictest/src/test_context.rs
+++ b/datafusion/sqllogictest/src/test_context.rs
@@ -219,7 +219,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 ad52d9f0dc..623bb715cd 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/expr/window_function.rs b/datafusion/substrait/src/logical_plan/consumer/expr/window_function.rs
index 3f32ed7268..d39b325a54 100644
--- a/datafusion/substrait/src/logical_plan/consumer/expr/window_function.rs
+++ b/datafusion/substrait/src/logical_plan/consumer/expr/window_function.rs
@@ -85,8 +85,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)?;
@@ -130,7 +130,7 @@ pub async fn from_window_function(
}
fn from_substrait_bound(
- bound: &Option<Bound>,
+ bound: Option<&Bound>,
is_lower: bool,
) -> datafusion::common::Result<WindowFrameBound> {
match bound {
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 413ee4b537..8c0114b90e 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/logical_plan/consumer/rel/read_rel.rs b/datafusion/substrait/src/logical_plan/consumer/rel/read_rel.rs
index 78951a3aff..2cad144080 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<MaskExpression>,
- filter: &Option<Box<Expression>>,
+ projection: Option<&MaskExpression>,
+ filter: Option<&Expression>,
) -> datafusion::common::Result<LogicalPlan> {
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<MaskExpression>,
+ mask_expression: Option<&MaskExpression>,
) -> datafusion::common::Result<DFSchema> {
match mask_expression {
Some(MaskExpression { select, .. }) => match &select.as_ref() {
diff --git a/datafusion/substrait/src/physical_plan/consumer.rs b/datafusion/substrait/src/physical_plan/consumer.rs
index ccaf1abec4..3c0df01b4a 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/cases/roundtrip_logical_plan.rs b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
index 9dcd702456..c9f874dd9b 100644
--- a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
+++ b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
@@ -2440,10 +2440,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(())
}
@@ -2452,10 +2449,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(())
}
@@ -2471,15 +2465,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"),
@@ -2512,19 +2500,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"),
diff --git a/datafusion/substrait/tests/utils.rs b/datafusion/substrait/tests/utils.rs
index 4d9b5ca83e..89363931f1 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() {
diff --git a/test-utils/src/array_gen/primitive.rs b/test-utils/src/array_gen/primitive.rs
index 5944879600..5b4339d873 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<Option<&Tz>> = 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()))
}