Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADAP-1254: Add row access policy and table_tag config for snowflake #901

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

b-per
Copy link
Contributor

@b-per b-per commented Mar 12, 2025

resolves #697

If approved, I am happy to add docs for it as well.

Problem

Today, it is not possible to set table tags or row access policies as part of CTAS statements. We can do it with post-hooks but there is a delay between the moment the object is created and the moment the tag or policy gets assigned, making potentially the object not available for some time.

Having those parameters as config allows making it part of the transaction.

Solution

Add 2 new parameters for Snowflake tables/views/incremental models:

  • row_access_policy
  • table_tag

Checklist

  • I have read the contributing guide and understand what's expected of me
  • 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
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@b-per b-per requested a review from a team as a code owner March 12, 2025 14:14
@cla-bot cla-bot bot added the cla:yes The PR author has signed the CLA label Mar 12, 2025
@cla-bot cla-bot bot temporarily deployed to dbt-snowflake March 12, 2025 14:15 Inactive
@b-per b-per temporarily deployed to dbt-snowflake March 18, 2025 18:01 — with GitHub Actions Inactive
@b-per
Copy link
Contributor Author

b-per commented Mar 18, 2025

I will add support for Snowflake DT as well

@b-per b-per temporarily deployed to dbt-snowflake March 19, 2025 12:44 — with GitHub Actions Inactive
@b-per
Copy link
Contributor Author

b-per commented Mar 19, 2025

I am not sure why mypy fails in the pre-commit

Run pre-commit run --show-diff-on-failure --color=always --all-files
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
check for case conflicts.................................................Passed
Check for dbt-core usage in an adapter...................................Passed
black....................................................................Passed
flake8...................................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

dbt-snowflake/src/dbt/adapters/snowflake/relation_configs/dynamic_table.py:[105](https://github.com/dbt-labs/dbt-adapters/actions/runs/13946816131/job/39035875312?pr=901#step:4:110): error:
Item "None" of "Optional[MaterializationConfig]" has no attribute "extra" 
[union-attr]
                "row_access_policy": relation_config.config.extra.get("row...
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
dbt-snowflake/src/dbt/adapters/snowflake/relation_configs/dynamic_table.py:[106](https://github.com/dbt-labs/dbt-adapters/actions/runs/13946816131/job/39035875312?pr=901#step:4:111): error:
Item "None" of "Optional[MaterializationConfig]" has no attribute "extra" 
[union-attr]
                "table_tag": relation_config.config.extra.get("table_tag")...
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 2 errors in 1 file (checked 303 source files)

I ran the pre-commit hook locally and there was no error.

Even a pre-commit run --files src/dbt/adapters/snowflake/relation_configs/dynamic_table.py is all green for me locally.

@mikealfare mikealfare changed the title Add row access policy and table_tag config for snowflake ADAP-1224: Add row access policy and table_tag config for snowflake Mar 19, 2025
@mikealfare mikealfare changed the title ADAP-1224: Add row access policy and table_tag config for snowflake ADAP-1254: Add row access policy and table_tag config for snowflake Mar 19, 2025
@mikealfare mikealfare self-assigned this Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes The PR author has signed the CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add the ability to create tables and views with a row access policy.
2 participants