From a4db34a0227243870874ce34c4883f65b386c0a0 Mon Sep 17 00:00:00 2001 From: dentiny Date: Fri, 14 Aug 2026 06:42:16 +0000 Subject: [PATCH] Reduce datafusion-spark dependency footprint (#24351) ## Which issue does this PR close? N/A ## Rationale for this change `datafusion-spark` pulls unnecessary crates into its production dependency graph, increasing compilation time and artifact size for downstream users. ## What changes are included in this PR? - Replace compatibility re-exports with the narrower crates that define `TableFunction` and `FunctionRegistry`. - Remove the unused `crypto_expressions` activation; Spark provides its own SHA-1, SHA-2, and CRC32 implementations. - Fix the `quote` import so builds without the optional `core` feature continue to compile. These changes reduce the production dependency graph from 279 to 257 packages. Cargo Machete does not report these dependencies because they are referenced in source through re-exports or activated through Cargo features. ## Are these changes tested? Yes ## Are there any user-facing changes? No. Public APIs and default behavior remain unchanged. --- Cargo.lock | 3 +-- datafusion/spark/Cargo.toml | 5 ++--- datafusion/spark/src/function/string/quote.rs | 6 ++++-- datafusion/spark/src/function/table/mod.rs | 2 +- datafusion/spark/src/lib.rs | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 141d5b6fdddb6..02e3fc5252211 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2623,14 +2623,13 @@ dependencies = [ "crc32fast", "criterion", "datafusion", - "datafusion-catalog", "datafusion-common", - "datafusion-execution", "datafusion-expr", "datafusion-functions", "datafusion-functions-aggregate", "datafusion-functions-aggregate-common", "datafusion-functions-nested", + "datafusion-session", "log", "num-traits", "percent-encoding", diff --git a/datafusion/spark/Cargo.toml b/datafusion/spark/Cargo.toml index 93987b553f2f5..01fd9ec9b3f5b 100644 --- a/datafusion/spark/Cargo.toml +++ b/datafusion/spark/Cargo.toml @@ -49,14 +49,13 @@ chrono = { workspace = true } crc32fast = "1.4" # Optional dependency for SessionStateBuilderSpark extension trait datafusion = { workspace = true, optional = true, default-features = false } -datafusion-catalog = { workspace = true } datafusion-common = { workspace = true } -datafusion-execution = { workspace = true } datafusion-expr = { workspace = true } -datafusion-functions = { workspace = true, features = ["crypto_expressions"] } +datafusion-functions = { workspace = true } datafusion-functions-aggregate = { workspace = true } datafusion-functions-aggregate-common = { workspace = true } datafusion-functions-nested = { workspace = true } +datafusion-session = { workspace = true } log = { workspace = true } num-traits = { workspace = true } percent-encoding = "2.3.2" diff --git a/datafusion/spark/src/function/string/quote.rs b/datafusion/spark/src/function/string/quote.rs index 39ad8bf841764..55d827fb7a280 100644 --- a/datafusion/spark/src/function/string/quote.rs +++ b/datafusion/spark/src/function/string/quote.rs @@ -17,12 +17,14 @@ use arrow::array::{ArrayRef, OffsetSizeTrait, StringArray}; use arrow::datatypes::DataType; -use datafusion::logical_expr::{Coercion, ColumnarValue, Signature, TypeSignatureClass}; use datafusion_common::cast::{as_generic_string_array, as_string_view_array}; use datafusion_common::types::{NativeType, logical_string}; use datafusion_common::utils::take_function_args; use datafusion_common::{Result, exec_err}; -use datafusion_expr::{ScalarFunctionArgs, ScalarUDFImpl, Volatility}; +use datafusion_expr::{ + Coercion, ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, + TypeSignatureClass, Volatility, +}; use datafusion_functions::utils::make_scalar_function; use std::sync::Arc; diff --git a/datafusion/spark/src/function/table/mod.rs b/datafusion/spark/src/function/table/mod.rs index aba7b7ceb78ea..5ccf8d91df045 100644 --- a/datafusion/spark/src/function/table/mod.rs +++ b/datafusion/spark/src/function/table/mod.rs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -use datafusion_catalog::TableFunction; +use datafusion_session::TableFunction; use std::sync::Arc; pub mod expr_fn {} diff --git a/datafusion/spark/src/lib.rs b/datafusion/spark/src/lib.rs index 6cd4678da7560..c75f94142ff8a 100644 --- a/datafusion/spark/src/lib.rs +++ b/datafusion/spark/src/lib.rs @@ -42,7 +42,7 @@ //! Spark functions taking priority. //! //! ``` -//! # use datafusion_execution::FunctionRegistry; +//! # use datafusion_expr::registry::FunctionRegistry; //! # use datafusion_expr::{ScalarUDF, AggregateUDF, WindowUDF, HigherOrderUDF}; //! # use datafusion_expr::planner::ExprPlanner; //! # use datafusion_common::Result; @@ -137,10 +137,10 @@ mod session_state; #[cfg(feature = "core")] pub use session_state::SessionStateBuilderSpark; -use datafusion_catalog::TableFunction; use datafusion_common::Result; -use datafusion_execution::FunctionRegistry; +use datafusion_expr::registry::FunctionRegistry; use datafusion_expr::{AggregateUDF, ScalarUDF, WindowUDF}; +use datafusion_session::TableFunction; use log::debug; use std::sync::Arc;