Repository navigation
Conversation
sd-db
added a commit
that referenced
this pull request
Oct 26, 2026
Co-authored-by: Isaac <no-reply@databricks.com>
saishreeeee
approved these changes
Oct 27, 2026
Unity Catalog can't shallow-clone a table with a row filter or column mask, so dbt clone failed on governed tables. Clone now checks the deferred table's policies in its catalog's information_schema and, when it has any, builds the view over it that materialized views and streaming tables already use. Under clone, validate_view_model rejects mask and row-filter config only for view models. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
With use_describe_as_json_for_relation_metadata on and a compute that supports DESCRIBE TABLE EXTENDED AS JSON, clone reads the deferred table's row filter and column masks from it, as get_relation_config does. Otherwise it keeps the information_schema query. Co-authored-by: Isaac <no-reply@databricks.com>
sd-db
force-pushed
the
fix/clone-governed-tables-as-view
branch
from
October 28, 2026 06:52
ba9e03f to
9579c43
Compare
Co-authored-by: Isaac <no-reply@databricks.com>
### 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 39a8c96. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
dbt clonefails for any Unity Catalog table with a row filter or column mask, because Databricks refuses to shallow-clone it:Column masks fail the same way with
COLUMN_MASKS_TABLE_CLONE_SOURCE_NOT_SUPPORTED. These are often the most sensitive tables, so CI jobs that clone production either fail or have to--excludethem.Before shallow-cloning a Unity Catalog table, clone now checks the deferred table's catalog
information_schemafor a row filter or column mask. If it finds one, clone takes the view path it already uses for materialized views and streaming tables: a view whose SQL isselect * from <deferred table>. The check reads the deferred table's actual policies, not the branch's config, so policies applied outside dbt count too. Hive metastore tables skip the check and shallow-clone as before.Under
clone,validate_view_modelnow rejects mask and row-filter config only for view models. Before, materialized views and streaming tables (#1744) were the only exceptions. A clone never applies the current config's policies: a shallow clone doesn't, and the view relies on the deferred object's policies.Policies apply to whoever queries the view. A temporary service principal had
SELECTon the cloned view and no grant on production. Production had acurrent_user()row filter, acurrent_user()mask and anis_account_group_member()mask. Through the view, the principal got its own filtered and masked rows (1 of 3, both columns***), the same result it got reading production directly once granted access. The owner saw all 3 rows unmasked. The principal and its schemas were deleted afterwards. As with any clone, anyone granted the target schema can read production through the view without a production grant, but only the rows and values production's policies allow them.Lookup: one extra query per cloned Unity Catalog table. With
use_describe_as_json_for_relation_metadataon and a compute that supports it, clone reads the policies fromDESCRIBE TABLE EXTENDED ... AS JSON(about 0.5 seconds on a SQL warehouse), asget_relation_configalready does. Otherwise it queries the catalog'sinformation_schema(about 0.6 to 0.8 seconds). The check is Jinja-only and adds no@availablemethod.Tests:
tests/functional/adapter/dbt_clone/. Each clones a governed production table and asserts that the target is aVIEWwhose rows are filtered or masked by production's policy. With the fix reverted, all three fail.TestCloneRowFilteredTable: a row filter set through the model config.TestCloneRowFilterAppliedOutsideDbt: a row filter added withALTER TABLEand absent from the config.TestCloneColumnMaskedTable: a column mask, built withuse_materialization_v2because V1 doesn't apply column masks at create.TestCloneRowFilterAppliedOutsideDbtDescribeAsJsonandTestCloneColumnMaskedTableDescribeAsJson: the same cases withuse_describe_as_json_for_relation_metadataon. With the information_schema fallback broken on purpose, both still passed and the information_schema-path class failed, so the DESCRIBE path ran.information_schemawhen the flag or capability is missing, andvalidate_view_modelunder clone fortableandincrementalmodels.Checklist
CHANGELOG.mdand added information about my change to the "dbt-databricks next" section.dbt-databricks-pr-readyproject skill for this PR and addressed its merge-readiness feedbackThis pull request and its description were written by Isaac.