dbt-labs/dbt-core · critical

Datafusion

Error message

Datafusion

What it means

A `todo!()` panic raised when `metadata_adapter` tries to construct a metadata adapter for the Datafusion adapter type. No Datafusion metadata adapter implementation exists yet in the dispatch table at crates/dbt-adapter/src/adapter/adapter_impl.rs:318-323, so the arm unconditionally panics with the message "Datafusion". This is a placeholder marking unfinished work that aborts instead of returning an error.

Source

Thrown at crates/dbt-adapter/src/adapter/adapter_impl.rs:321

                            as Box<dyn MetadataAdapter>,
                        DuckDB => {
                            Box::new(DuckDBMetadataAdapter::new(engine)) as Box<dyn MetadataAdapter>
                        }
                        LakeCompute => {
                            Box::new(DuckDBMetadataAdapter::new(engine)) as Box<dyn MetadataAdapter>
                        }
                        Fabric => {
                            Box::new(FabricMetadataAdapter::new(engine)) as Box<dyn MetadataAdapter>
                        }
                        ClickHouse => Box::new(ClickHouseMetadataAdapter::new(engine))
                            as Box<dyn MetadataAdapter>,
                        Exasol => {
                            Box::new(ExasolMetadataAdapter::new(engine)) as Box<dyn MetadataAdapter>
                        }
                        Starburst => todo!("Starburst"),
                        Athena => todo!("Athena"),
                        Trino => todo!("Trino"),
                        Datafusion => todo!("Datafusion"),
                        Dremio => todo!("Dremio"),
                        Oracle => todo!("Oracle"),
                    };
                Some(metadata_adapter)
            }
        }
    }

    /// Execute `use warehouse [name]` statement for Snowflake.
    /// For other warehouses, this is noop.
    /// Returns whether the connection changed and must be restored.
    pub fn use_warehouse(
        &self,
        conn: &'_ mut dyn Connection,
        warehouse: String,
        node_id: &str,
        token: CancellationToken,
    ) -> FsResult<bool> {

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Switch to an implemented adapter type (Snowflake, Bigquery, Databricks, Redshift, Postgres, DuckDB, Fabric, ClickHouse, Exasol, etc.) until Datafusion is supported.
  2. Implement the Datafusion arm: replace `Datafusion => todo!("Datafusion")` with construction of a Datafusion metadata adapter, e.g. `Box::new(DatafusionMetadataAdapter::new(engine)) as Box<dyn MetadataAdapter>`.
  3. Use sidecar mode so schema hydration is handled via db_runner and `metadata_adapter` returns None before reaching the match.

Example fix

// before
Datafusion => todo!("Datafusion"),
// after
Datafusion => Box::new(DatafusionMetadataAdapter::new(engine)) as Box<dyn MetadataAdapter>,
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED: &[AdapterType] = &[
    AdapterType::Snowflake, AdapterType::Bigquery, AdapterType::Databricks,
    AdapterType::Spark, AdapterType::Redshift, AdapterType::Salesforce,
    AdapterType::Postgres, AdapterType::DuckDB, AdapterType::LakeCompute,
    AdapterType::Fabric, AdapterType::ClickHouse, AdapterType::Exasol,
];
assert!(SUPPORTED.contains(&adapter.adapter_type()), "Datafusion metadata adapter not implemented");

Type guard

fn datafusion_supported(t: &AdapterType) -> bool {
    !matches!(t, AdapterType::Datafusion | AdapterType::Starburst | AdapterType::Athena | AdapterType::Trino | AdapterType::Dremio | AdapterType::Oracle)
}

Try / catch

let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| adapter.metadata_adapter()));
if result.is_err() {
    eprintln!("metadata adapter dispatch is unimplemented for this adapter type; use a supported engine or sidecar mode");
}

Prevention

When it happens

Trigger: Calling `metadata_adapter()` on a DbtAdapter whose adapter_type() is AdapterType::Datafusion in non-sidecar, non-explicit-mock mode.

Common situations: Running dbt against a Datafusion profile before Datafusion support is added; enumerating adapter types in tests or tooling; a config that selects datafusion as the adapter while the feature is still unimplemented.

Related errors


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/a1c064f0356d6a49. Report an issue: GitHub.