Skip to content

fix: warn on missing persist_docs columns for view/materialized_view/streaming_table create - #1615

Open
r-jais wants to merge 17 commits into
databricks:mainfrom
r-jais:fix/persist-docs-warn-missing-create-paths
Open

fix: warn on missing persist_docs columns for view/materialized_view/streaming_table create#1615
r-jais wants to merge 17 commits into
databricks:mainfrom
r-jais:fix/persist-docs-warn-missing-create-paths

Conversation

@r-jais

@r-jais r-jais commented Jul 28, 2026

Copy link
Copy Markdown

Description

resolves #1399

Follow-up to #1563. That PR added the "warn when a documented column is absent from the relation" check as a post-build validation (validate_persist_doc_columns, mirroring the shared validate_doc_columns behavior every other adapter uses) and wired it into the table and incremental materializations.

This PR completes the create-time coverage by calling the same gated, post-build validation on the materializations #1563 didn't touch:

  • view create (V1 + V2) — dbt/include/databricks/macros/materializations/view.sql
  • materialized view create/replace/refresh — .../materialized_view.sql
  • streaming table create/replace/refresh — .../streaming_table.sql

Each is a single validate_persist_doc_columns(target_relation, model) call after the relation is built. The macro is gated on config.persist_column_docs() and applies no comments, so it never fires when column persistence is off and stays safe under --warn-error (per the caution in #1563 about not warning unconditionally in parse_columns_and_constraints). Previously these paths iterated only the query's output columns (get_persist_docs_column_list) or built inline comments via parse_columns_and_constraints, so a YAML-only documented column was silently dropped.

Stacking

This PR is stacked on #1563 and currently shows its commits too. It targets main; once #1563 merges, this diff reduces to just the view/materialized-view/streaming-table changes. Review/merge #1563 first.

Tests

Functional (tests/functional/adapter/persist_docs/test_persist_docs.py): create-time missing-column warning for view, materialized view, and streaming table (each: documented column absent from the relation → warns exactly once, gated on persist_docs.columns). New fixtures in tests/functional/adapter/persist_docs/fixtures.py. The core validate_persist_doc_columns logic is unit-tested in #1563.

Checklist

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

sd-db added 2 commits June 23, 2026 09:51
### Description

Removes internal logging-event classes that have had **no call sites**
since the cursor-management (databricks#910/databricks#912) and pipeline (databricks#849) refactors.
They are dead code: zero consumers across source and tests, no
`events/__init__.py` re-export, and no dynamic/string references. Git
history confirms they were once used and their consumers were later
deleted (orphaned, not never-wired).

Removed:
- `events/credential_events.py` — whole module (`CredentialLoadError`,
`CredentialSaveError`, `CredentialShardEvent`)
- `events/pipeline_events.py` — whole module (`PipelineEvent`,
`PipelineRefresh`, `PipelineRefreshError`)
- `events/connection_events.py` — `ConnectionReset`, `ConnectionReuse`,
`ConnectionIdleClose`, `ConnectionCreated`

Kept (still live or still a needed base): `ConnectionEvent`,
`ConnectionCreateError`, the `ConnectionWrapperEvent` base,
`ConnectionCreate`, and all of `events/base.py` /
`events/other_events.py` / `logging.py`.

Targeting `1.13.latest` rather than a patch: although these were never
public API, they sit at importable paths, so the removal is scoped to
the next minor as a safety margin.

Full unit suite passes (1081 passed, 6 skipped); ruff/ruff-format/mypy
clean.

### Checklist

- [x] I have run this code in development and it appears to resolve the
stated issue
- [x] This PR includes tests, or tests are not required/relevant for
this PR
- [x] I have updated the `CHANGELOG.md` and added information about my
change to the "dbt-databricks next" section.
@r-jais
r-jais requested review from jprakash-db and sd-db as code owners July 28, 2026 06:49
r-jais and others added 15 commits August 5, 2026 19:45
…_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).
The persist_docs missing-column warning only covered the V1 path
(get_persist_doc_columns). The V2 (relation-config) path diffs column
comments through ColumnCommentsConfig.get_diff, where a column documented
in schema.yml but absent from the relation was still emitted into the
diff (targeting a nonexistent column on the ALTER) with no feedback.

Warn about those columns and skip them, matching the V1 behavior and the
same warning message. Addresses review feedback on databricks#1563.
Add three functional tests exercising the missing-column warning end to end:
- V1 comment path warns and still comments present columns
- V2 alter path (get_diff) warns on a subsequent run
- --warn-error escalates the warning to a run failure
A table rebuild re-applies comments inline and never hits ColumnCommentsConfig.get_diff;
the v2 changeset/alter path is only reached on a subsequent incremental run. Verified all
three functional tests pass against a live UC SQL warehouse.
The v1 and v2 warning sites are mutually exclusive per model run, so a single run warns
exactly once. Lock that in as a regression guard against future double-warning if the
warning is added to additional helpers.
V1 incremental subsequent runs hit both get_diff and get_persist_doc_columns;
dedupe via a shared thread-local helper, and cover columns-only + the double-warn path.
@sd-db

sd-db commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Can we rebase on the latest code for #1563 ?

@sd-db sd-db added the pending on pr-author Indicates waiting on the pr author to resolve a question/comment label Aug 7, 2026
@sd-db sd-db self-assigned this Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending on pr-author Indicates waiting on the pr author to resolve a question/comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Materialization v2 with update_via_alter for nonexistent columns

2 participants