Skip to content

fix: warn when documented columns are missing from the relation in persist_docs#1563

Open
r-jais wants to merge 1 commit into
databricks:mainfrom
r-jais:fix/persist-docs-warn-missing-columns
Open

fix: warn when documented columns are missing from the relation in persist_docs#1563
r-jais wants to merge 1 commit into
databricks:mainfrom
r-jais:fix/persist-docs-warn-missing-columns

Conversation

@r-jais

@r-jais r-jais commented Jun 30, 2026

Copy link
Copy Markdown

Resolves #

Description

When persist_docs.columns is enabled, DatabricksAdapter.get_persist_doc_columns only iterates the columns that actually exist in the materialized relation. As a result, any column documented in a model's schema.yml that is not present in the relation (typo, renamed column, stale docs) is silently skipped — no comment is applied and no feedback is given to the user.

This PR adds a warning that names those columns. The filtering behavior is unchanged (the missing columns are still skipped so the ALTER never errors); we just surface them via warn_or_error, so it respects --warn-error like other adapter warnings.

This ports the behavior added upstream in dbt-adapters — dbt-labs/dbt-adapters#1684 (closes dbt-labs/dbt-adapters#1690). Because dbt-databricks overrides persist_docs with its own native get_persist_doc_columns, the upstream macro change does not reach this adapter, so the warning is added here directly.

Example warning:

The following columns are specified in the schema but are not present in the database and will be skipped: col2

Checklist

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-databricks next" section.

…_docs

When persist_docs.columns is enabled, columns documented in a model's
schema.yml but absent from the materialized relation were silently
skipped by get_persist_doc_columns. Emit a warning naming those columns
so users can catch typos and stale documentation. The columns are still
filtered out (no behavior change to the comments that get applied).

Ports the behavior added upstream in dbt-adapters#1684 (issue #1690).
@r-jais r-jais requested review from jprakash-db and sd-db as code owners June 30, 2026 09:12
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  dbt/adapters/databricks
  impl.py
Project Total  

This report was generated by python-coverage-comment-action

@r-jais r-jais changed the title Warn when documented columns are missing from the relation in persist_docs fix: warn when documented columns are missing from the relation in persist_docs Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CT-1024] [Bug] Nonexistent column in yml file causes "can't execute an empty query"

1 participant