From fe149c28507472b247829311fc7d109c81855965 Mon Sep 17 00:00:00 2001 From: dragonknightk <37928252+dragonknightk@users.noreply.github.com> Date: Wed, 2 Dec 2026 20:10:57 +0800 Subject: [PATCH 1/2] fix: stop enabling DataFusion default features in iceberg-datafusion Closes issue 136. ## Rationale for this change `iceberg-datafusion` depended on `datafusion` with its default features, which include `sql`, although the library never uses SQL. Cargo unifies features across a build, so every project that depends on `iceberg-datafusion` also gets `sql`. That breaks projects that build DataFusion without `sql`. With `sql` on, `DataFusionError` gains a `SQL` variant, so a `match` that lists every variant no longer compiles. ## What changes are included in this PR? The workspace now declares `datafusion` with `default-features = false`, and the library enables no extra features. The crates that need more ask for it themselves: - `iceberg-datafusion-test-tools` enables `sql` (its harness calls `SessionContext::sql`) and `parquet` (it uses the Parquet re-export). - The library enables `parquet` and `sql` for its own tests as a dev-dependency only, so they are not part of a downstream build. ## Are these changes tested? This only changes manifests, so there is no new test. `cargo test -p iceberg-datafusion` still passes. A small downstream crate (not part of this PR) builds `datafusion-common` without `sql` and matches every `DataFusionError` variant. Before this change it fails with a non-exhaustive match on `SQL`. After it, it compiles. `cargo tree -e normal,features -i datafusion-common -p iceberg-datafusion` no longer lists `sql`. ## Are there any user-facing changes? Yes. `iceberg-datafusion` no longer turns on any DataFusion default feature (`sql`, `parquet`, compression codecs, and so on) for downstream builds. A project that relied on it for one of them must enable that feature on its own `datafusion` dependency. Signed-off-by: dragonknightk <37928252+dragonknightk@users.noreply.github.com> --- Cargo.toml | 2 +- crates/datafusion/Cargo.toml | 1 + crates/test-tools/Cargo.toml | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3bf3e3a5..3b0cf0b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ version = "0.12.0" [workspace.dependencies] anyhow = "1.0.72" async-trait = "0.1.89" -datafusion = "56.0.0" +datafusion = { version = "56.0.0", default-features = false } datafusion-cli = "56.0.0" iceberg-datafusion = { path = "crates/datafusion" } iceberg-datafusion-test-tools = { path = "crates/test-tools" } diff --git a/crates/datafusion/Cargo.toml b/crates/datafusion/Cargo.toml index c0e376c0..9c9adcdc 100644 --- a/crates/datafusion/Cargo.toml +++ b/crates/datafusion/Cargo.toml @@ -41,6 +41,7 @@ tokio = { workspace = true } uuid = { version = "1.18", features = ["v7"] } [dev-dependencies] +datafusion = { workspace = true, features = ["parquet", "sql"] } iceberg-datafusion-test-tools = { workspace = true } insta = "1" parquet = "60" diff --git a/crates/test-tools/Cargo.toml b/crates/test-tools/Cargo.toml index 5d6d41e5..564c2b02 100644 --- a/crates/test-tools/Cargo.toml +++ b/crates/test-tools/Cargo.toml @@ -28,9 +28,9 @@ version = { workspace = true } [dependencies] async-trait = { workspace = true } bytes = "1" -# Only for its Arrow and Parquet re-exports, which keep this crate on the -# versions the rest of the workspace resolves to. -datafusion = { workspace = true } +# For its Arrow and Parquet re-exports, which keep this crate on the versions the +# rest of the workspace resolves to, and for `SessionContext::sql` in the harness. +datafusion = { workspace = true, features = ["parquet", "sql"] } futures = "0.3" iceberg = { workspace = true } rand = { version = "0.10", default-features = false, features = ["alloc"] } From d2f586eaf967d2153392f10c975bd32f3869e0e7 Mon Sep 17 00:00:00 2001 From: dragonknightk <37928252+dragonknightk@users.noreply.github.com> Date: Fri, 4 Dec 2026 17:33:49 +0800 Subject: [PATCH 2/2] fix: check library feature isolation in CI and fix doc link Closes issue 136. ## Rationale for this change `iceberg-datafusion` depended on `datafusion` with its default features, which include `sql`, even though the library never uses SQL. Cargo unifies features across a build, so every downstream project depending on `iceberg-datafusion` also gets `sql`. That breaks projects that build DataFusion without `sql`. With `sql` on, `DataFusionError` gains a `SQL` variant, so an exhaustive `match` on `DataFusionError` fails to compile. Workspace-only CI commands (`--workspace`) do not catch regressions because workspace dev-dependencies and tooling crates turn `sql` back on via feature unification. ## What changes are included in this PR? - Disable DataFusion default features in the workspace declaration, leaving `iceberg-datafusion` with no extra DataFusion features. - Enable `parquet` and `sql` explicitly where directly used: `iceberg-datafusion-test-tools` (Parquet re-export and `SessionContext::sql` in the harness) and `iceberg-datafusion` dev-dependencies (tests only, excluded from downstream builds). `iceberg-sqllogictest` and `iceberg-playground` do not call `SessionContext::sql` directly and remain unchanged. - Add `cargo check --locked -p iceberg-datafusion --lib` to the existing CI Clippy job so future library changes that rely on DataFusion default features fail CI. - Change the `datafusion::sql::planner::SqlToRel::external_table_to_plan` doc reference in `factory.rs` from an intra-doc link to plain inline code, since `datafusion::sql` is absent without `sql`. ## Are these changes tested? - Library isolation: verified that `iceberg-datafusion --lib` compiles without DataFusion default features and that its normal dependency tree for `datafusion-common` no longer includes `sql`. - Documentation: verified strict rustdoc build for `iceberg-datafusion` passes with no unresolved intra-doc links in the modified code. - Workspace and downstream compatibility: full workspace tests and clippy pass; a downstream crate matching all non-`sql` `DataFusionError` variants fails with a non-exhaustive match on `SQL` before this PR and compiles after it. ## Are there any user-facing changes? Yes. `iceberg-datafusion` no longer enables any DataFusion default feature (`sql`, `parquet`, compression codecs, and so on) for downstream builds. A project relying on any of those features must enable it on its own `datafusion` dependency. Signed-off-by: dragonknightk <37928252+dragonknightk@users.noreply.github.com> --- .github/workflows/ci.yml | 3 +++ crates/datafusion/src/table_provider/factory.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2b84619..ecdce75b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,9 @@ jobs: components: clippy cache: "true" - run: cargo clippy --workspace --locked --all-targets -- -D warnings + # Ensure the library builds without DataFusion features unified in by + # workspace dev-dependencies or tooling crates. + - run: cargo check --locked -p iceberg-datafusion --lib test: name: Test diff --git a/crates/datafusion/src/table_provider/factory.rs b/crates/datafusion/src/table_provider/factory.rs index 0c5b381e..e424a1e0 100644 --- a/crates/datafusion/src/table_provider/factory.rs +++ b/crates/datafusion/src/table_provider/factory.rs @@ -190,7 +190,7 @@ fn check_cmd(cmd: &CreateExternalTable) -> Result<&str> { /// /// # See also /// - [`iceberg::NamespaceIdent`] -/// - [`datafusion::sql::planner::SqlToRel::external_table_to_plan`] +/// - `datafusion::sql::planner::SqlToRel::external_table_to_plan` fn complement_namespace_if_necessary( table_name: &TableReference, ) -> Cow<'_, TableReference> {