Skip to content

fix: let dbt clone handle materialized views and streaming tables with row filters or column masks - #1744

Open
sd-db wants to merge 7 commits into
fix/1349-clone-view-contractfrom
fix/clone-view-skip-mask-filter-checks
Open

sd-db wants to merge 7 commits into
fix/1349-clone-view-contractfrom
fix/clone-view-skip-mask-filter-checks

Conversation

@sd-db

@sd-db sd-db commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #1742.

Description

dbt clone fails for a materialized view with a row_filter, and for a streaming table with a row_filter or column_mask. This happens even when nothing changed since the deferred state:

Compilation Error in model ... Row filters are not supported for views.

Clone can't shallow-clone an MV or ST, so it builds a view over the deferred object (select * from <prod MV/ST>) through the view materialization. validate_view_model then rejects the model's own mask or filter config, because views can't carry those policies. The cloned view doesn't need them: the deferred MV or ST enforces its own policies when the view reads from it.

Under clone, validate_view_model now skips the mask and row-filter rejection for materialized_view and streaming_table models. Plain view models still reject masks and row filters under clone, so a policy declared on a view is never silently dropped. The contract skip from #1742 is unchanged.

The cloned view reflects the production object's policies, not the branch's config. That includes the case where the branch changed the model's materialization. docs/flow/view_flow.md documents this.

Tables with masks or row filters still fail, because Databricks refuses to shallow-clone them (ROW_LEVEL_SECURITY_TABLE_CLONE_SOURCE_NOT_SUPPORTED / COLUMN_MASKS_TABLE_CLONE_SOURCE_NOT_SUPPORTED). They're out of scope here: falling back to a view for those needs separate verification of how policies apply to other users reading the view.

Tests:

  • New functional tests in tests/functional/adapter/dbt_clone/: TestCloneRowFilteredMaterializedView, TestCloneRowFilteredStreamingTable and TestCloneColumnMaskedStreamingTable. Each builds the governed object, clones it, and asserts that the target is a VIEW whose rows are filtered or masked by the production object's policy. With the fix reverted, all three fail with the errors above.
  • The macro test now covers run/view, clone/view, clone/materialized view and clone/streaming table.
  • Ran the clone suite, TestUpdateViewViaAlterValidation, both TestViewConstraintsColumnsEqual classes and the row-filter and column-mask suites on the UC SQL warehouse: 45 passed, 2 skipped. All macro unit tests pass (347).

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.
  • [Optional] I have run the dbt-databricks-pr-ready project skill for this PR and addressed its merge-readiness feedback

This pull request and its description were written by Isaac.

sd-db added a commit that referenced this pull request Oct 25, 2026
Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

sd-db added a commit to sd-db/dbt-core that referenced this pull request Oct 28, 2026
…g tables with row filters or column masks

Port of databricks/dbt-databricks#1744. dbt clone builds a view over a deferred materialized view or streaming table, and that object keeps enforcing its own row filter and column masks. Under clone, validate_view_model now skips the mask and row-filter rejection for materialized_view and streaming_table models. Plain views still reject both.

Co-authored-by: Isaac <no-reply@databricks.com>
@sd-db
sd-db added this pull request to stack #1751 October 28, 2026 06:11
sd-db and others added 3 commits October 28, 2026 11:54
Clone cannot shallow-clone a materialized view or streaming table, so it
creates a view over the deferred object. validate_view_model rejected the
model's row_filter/column_mask config there because views can't carry
policies, so clone failed even when nothing changed. Under clone, skip that
rejection for MV/ST models; the deferred object enforces its own policies.
Plain view models still reject masks and row filters under clone.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@sd-db
sd-db force-pushed the fix/clone-view-skip-mask-filter-checks branch from 15ad66e to 9f0bc9c Compare October 28, 2026 06:50
Co-authored-by: Isaac <no-reply@databricks.com>
sd-db added a commit that referenced this pull request Oct 28, 2026
Co-authored-by: Isaac <no-reply@databricks.com>
sd-db and others added 3 commits October 28, 2026 20:55
### Description

`TestViewLifecycleIgnoresMaterializationFlag` and
`TestViewLifecycleMaterializationFlagOn` ran `dbt --warn-error run`, so
any warning failed them, including warnings unrelated to the view
lifecycle. On the lowest-direct dependency floor, dbt-core 1.11.2
reports `view_update_via_alter` as an unrecognized config key
(`CustomKeyInConfigDeprecation`), and some auth paths emit warnings too.
The `--warn-error` was only defense in depth, so this PR removes it. All
server-state assertions (column comments and grants) stay.

This PR also moves the 1.13.0 release date in `CHANGELOG.md` to Oct 29,
2026.

Supersedes #1754.

Verified locally against a SQL warehouse (`databricks_uc_sql_endpoint`),
`tests/functional/adapter/views/test_views.py`:

- dbt-core 1.11.2 (lowest-direct lock): 29 passed, 7 skipped
- dbt-core 1.12.6 (`uv.lock`): 29 passed, 7 skipped

### 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
- [ ] I have updated the `CHANGELOG.md` and added information about my
change to the "dbt-databricks next" section. (test-only, no changelog
entry)

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
This reverts commit 5ff4c36.

Co-authored-by: Isaac <no-reply@databricks.com>

This branch has not been deployed

No deployments
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.

2 participants