Skip to content

Apache DataFusion SQL Query Engine

minor: enforce lint rule clippy::needless_pass_by_value to datafusion-ffi (#18764)

Alan Tang8b8bdc4ad42d
diff --git a/datafusion/ffi/src/arrow_wrappers.rs b/datafusion/ffi/src/arrow_wrappers.rs
index 7b3751dcae..c60a055baf 100644
--- a/datafusion/ffi/src/arrow_wrappers.rs
+++ b/datafusion/ffi/src/arrow_wrappers.rs
@@ -50,14 +50,15 @@ impl From<SchemaRef> for WrappedSchema {
/// give the user a warning, and return some kind of result. In this case we default to an
/// empty schema.
#[cfg(not(tarpaulin_include))]
-fn catch_df_schema_error(e: ArrowError) -> Schema {
+fn catch_df_schema_error(e: &ArrowError) -> Schema {
error!("Unable to convert from FFI_ArrowSchema to DataFusion Schema in FFI_PlanProperties. {e}");
Schema::empty()
}
impl From<WrappedSchema> for SchemaRef {
fn from(value: WrappedSchema) -> Self {
- let schema = Schema::try_from(&value.0).unwrap_or_else(catch_df_schema_error);
+ let schema =
+ Schema::try_from(&value.0).unwrap_or_else(|e| catch_df_schema_error(&e));
Arc::new(schema)
}
}
diff --git a/datafusion/ffi/src/lib.rs b/datafusion/ffi/src/lib.rs
index 0c2340e8ce..abaf975685 100644
--- a/datafusion/ffi/src/lib.rs
+++ b/datafusion/ffi/src/lib.rs
@@ -23,6 +23,9 @@
// Make sure fast / cheap clones on Arc are explicit:
// https://github.com/apache/datafusion/issues/11143
#![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))]
pub mod arrow_wrappers;
pub mod catalog_provider;
diff --git a/datafusion/ffi/src/tests/async_provider.rs b/datafusion/ffi/src/tests/async_provider.rs
index cef4161d8c..67421f5880 100644
--- a/datafusion/ffi/src/tests/async_provider.rs
+++ b/datafusion/ffi/src/tests/async_provider.rs
@@ -60,7 +60,7 @@ fn async_table_provider_thread(
mut shutdown: mpsc::Receiver<bool>,
mut batch_request: mpsc::Receiver<bool>,
batch_sender: broadcast::Sender<Option<RecordBatch>>,
- tokio_rt: mpsc::Sender<Handle>,
+ tokio_rt: &mpsc::Sender<Handle>,
) {
let runtime = Arc::new(
tokio::runtime::Builder::new_current_thread()
@@ -107,7 +107,7 @@ pub fn start_async_provider() -> (AsyncTableProvider, Handle) {
shutdown_rx,
batch_request_rx,
record_batch_tx,
- tokio_rt_tx,
+ &tokio_rt_tx,
)
}));