Apache DataFusion SQL Query Engine
chore: enforce clippy lint needless_pass_by_value to datafusion-substrait (#18703)
Dhanush0cd6a19bc850
diff --git a/datafusion/substrait/src/extensions.rs b/datafusion/substrait/src/extensions.rsindex 0792928982..27d6c15030 100644--- a/datafusion/substrait/src/extensions.rs+++ b/datafusion/substrait/src/extensions.rs@@ -38,7 +38,7 @@ impl Extensions {/// Registers a function and returns the anchor (reference) to it. If the function has already/// been registered, it returns the existing anchor./// Function names are case-insensitive (converted to lowercase).- pub fn register_function(&mut self, function_name: String) -> u32 {+ pub fn register_function(&mut self, function_name: &str) -> u32 {let function_name = function_name.to_lowercase();// Some functions are named differently in Substrait default extensions than in DF@@ -64,7 +64,7 @@ impl Extensions {/// Registers a type and returns the anchor (reference) to it. If the type has already/// been registered, it returns the existing anchor.- pub fn register_type(&mut self, type_name: String) -> u32 {+ pub fn register_type(&mut self, type_name: &str) -> u32 {let type_name = type_name.to_lowercase();match self.types.iter().find(|(_, t)| *t == &type_name) {Some((type_anchor, _)) => *type_anchor, // Type has been registereddiff --git a/datafusion/substrait/src/lib.rs b/datafusion/substrait/src/lib.rsindex 8bc31569f2..51e3d83651 100644--- a/datafusion/substrait/src/lib.rs+++ b/datafusion/substrait/src/lib.rs@@ -23,6 +23,9 @@// Make sure fast / cheap clones on Arc are explicit:// https://github.com/apache/datafusion/issues/11143#![cfg_attr(not(test), deny(clippy::clone_on_ref_ptr))]+// https://github.com/apache/datafusion/issues/18503+#![deny(clippy::needless_pass_by_value)]+#![cfg_attr(test, allow(clippy::needless_pass_by_value))]//! Serialize / Deserialize DataFusion Plans to [Substrait.io]//!diff --git a/datafusion/substrait/src/logical_plan/consumer/expr/mod.rs b/datafusion/substrait/src/logical_plan/consumer/expr/mod.rsindex 7358f1422f..ba89225985 100644--- a/datafusion/substrait/src/logical_plan/consumer/expr/mod.rs+++ b/datafusion/substrait/src/logical_plan/consumer/expr/mod.rs@@ -221,7 +221,7 @@ mod tests {// Just registering a single function (index 0) so that the plan// does not throw a "function not found" error.let mut extensions = Extensions::default();- extensions.register_function("count".to_string());+ extensions.register_function("count");consumer.extensions = &extensions;match from_substrait_rex(&consumer, &substrait, &DFSchema::empty()).await? {@@ -248,7 +248,7 @@ mod tests {let mut consumer = test_consumer();let mut extensions = Extensions::default();- extensions.register_function("count".to_string());+ extensions.register_function("count");consumer.extensions = &extensions;match from_substrait_rex(&consumer, &substrait, &DFSchema::empty()).await? {diff --git a/datafusion/substrait/src/logical_plan/producer/substrait_producer.rs b/datafusion/substrait/src/logical_plan/producer/substrait_producer.rsindex db08e0f7bf..54fa9ea5da 100644--- a/datafusion/substrait/src/logical_plan/producer/substrait_producer.rs+++ b/datafusion/substrait/src/logical_plan/producer/substrait_producer.rs@@ -67,11 +67,11 @@ use substrait::proto::{/// impl SubstraitProducer for CustomSubstraitProducer {////// fn register_function(&mut self, signature: String) -> u32 {-/// self.extensions.register_function(signature)+/// self.extensions.register_function(&signature)/// }////// fn register_type(&mut self, type_name: String) -> u32 {-/// self.extensions.register_type(type_name)+/// self.extensions.register_type(&type_name)/// }////// fn get_extensions(self) -> Extensions {@@ -377,11 +377,11 @@ impl<'a> DefaultSubstraitProducer<'a> {impl SubstraitProducer for DefaultSubstraitProducer<'_> {fn register_function(&mut self, fn_name: String) -> u32 {- self.extensions.register_function(fn_name)+ self.extensions.register_function(&fn_name)}fn register_type(&mut self, type_name: String) -> u32 {- self.extensions.register_type(type_name)+ self.extensions.register_type(&type_name)}fn get_extensions(self) -> Extensions {