dbt-labs/dbt-core · error

PostgresAdapter::freshness

Error message

PostgresAdapter::freshness

What it means

This is a Rust `todo!()` panic: `PostgresAdapter::freshness_inner`, the source-freshness hook, is unimplemented, so any freshness check on Postgres panics with 'PostgresAdapter::freshness'. Freshness queries (last-updated timestamps for sources) were never wired up for the Postgres adapter.

Source

Thrown at crates/dbt-adapter/src/metadata/postgres/mod.rs:174

    ) -> AsyncAdapterResult<'_, HashMap<String, AdapterResult<Arc<Schema>>>> {
        let future = async move { todo!("PostgreSQL's list_relations_schemas") };
        Box::pin(future)
    }

    fn list_relations_schemas_by_patterns_inner(
        &self,
        _patterns: &[RelationPattern],
        _token: CancellationToken,
    ) -> AsyncAdapterResult<'_, Vec<(String, AdapterResult<RelationSchemaPair>)>> {
        todo!("PostgresAdapter::list_relations_schemas_by_patterns")
    }

    fn freshness_inner(
        &self,
        _relations: &[Arc<dyn BaseRelation>],
        _token: CancellationToken,
    ) -> AsyncAdapterResult<'_, BTreeMap<String, MetadataFreshness>> {
        todo!("PostgresAdapter::freshness")
    }

    fn create_schemas_if_not_exists(
        &self,
        state: &State<'_, '_>,
        catalog_schemas: Vec<(String, String, String)>,
    ) -> AdapterResult<Vec<(String, String, String, AdapterResult<()>)>> {
        create_schemas_if_not_exists(&self.adapter, self, state, catalog_schemas)
    }

    fn list_relations_in_parallel_inner(
        &self,
        _db_schemas: &[CatalogAndSchema],
        _token: CancellationToken,
    ) -> AsyncAdapterResult<'_, BTreeMap<CatalogAndSchema, AdapterResult<RelationVec>>> {
        // FIXME: Implement cache hydration
        let future = async move { Ok(BTreeMap::new()) };
        Box::pin(future)

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Skip source freshness for Postgres sources until supported (exclude them from freshness selection)
  2. Implement freshness_inner by querying source tables' max update timestamps (e.g. a configured freshness column via SELECT max(...))
  3. Upgrade/pin to a dbt-adapter release where Postgres freshness is implemented
  4. Fail fast: validate at DAG parse time that selected sources' adapters support freshness, raising a clear error instead of a panic

Example fix

// before
todo!("PostgresAdapter::freshness")
// after
async move {
    let mut out = BTreeMap::new();
    for rel in relations {
        out.insert(rel.unique_id().to_string(), query_max_loaded_at(conn, rel).await?);
    }
    Ok(out)
}
Defensive patterns

Strategy: validation

Validate before calling

// skip freshness if the adapter does not implement it
if !adapter.capabilities().freshness {
    return Ok(FreshnessReport::skipped("Postgres freshness not implemented"));
}

Type guard

fn freshness_supported(a: &dyn Adapter) -> bool { a.capabilities().freshness }

Try / catch

match adapter.freshness(relations, token).await {
    Ok(map) => map,
    Err(_) => BTreeMap::new(), // degrade to empty freshness instead of failing the run
}

Prevention

When it happens

Trigger: Calling the freshness operation on a PostgresAdapter (fan-in from `freshness_inner` at crates/dbt-adapter/src/metadata/postgres/mod.rs:174) with one or more `Arc<dyn BaseRelation>` sources; the stub panics before any SQL runs.

Common situations: Running `dbt source freshness` against Postgres sources while the adapter's freshness support is stubbed; the run fails with a panic rather than a freshness report, regardless of table metadata availability.

Related errors


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