diff --git a/datafusion/substrait/src/extensions.rs b/datafusion/substrait/src/extensions.rs index 079292898226..27d6c150304d 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 registered diff --git a/datafusion/substrait/src/lib.rs b/datafusion/substrait/src/lib.rs index 8bc31569f294..51e3d8365130 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.rs index 7358f1422f1b..ba892259852a 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.rs index db08e0f7bfd0..54fa9ea5daa4 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 {