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

Support for Snowflake Secure Views #1730

Closed
Carolus-Holman opened this issue Sep 10, 2019 · 2 comments · Fixed by #1743
Closed

Support for Snowflake Secure Views #1730

Carolus-Holman opened this issue Sep 10, 2019 · 2 comments · Fixed by #1743
Labels
enhancement New feature or request good_first_issue Straightforward + self-contained changes, good for new contributors! snowflake

Comments

@Carolus-Holman
Copy link
Contributor

Adding support for Secure View in Snowflake

When using the Materialize feature where setting the type of materialization, adding secure-view to the {{ config(materialized='secure-view') }} would be beneficial.

Current Work-around

Currently the solution for Snowflake secure views is running post-hook events to set the targeted views as secure, example: alter view sv_mySecureTest set secure;
This works, and each view that needs to be secured will need to be added to the post-hook event.

Affects only Snowflake

This feature is specific to the Snowflake Cloud Data warehouse.
https://docs.snowflake.net/manuals/user-guide/views-secure.html

This will help DBT Snowflake Developer / Non Developers

When creating a secure view in Snowflake, a developer can use 2 syntax commands

  1. CREATE OR REPLACE SECURE VIEW...
  2. Alter view <view_name> Set Secure

The first method will allow non-dbt user to render the DDL with the secure declaration as part of the DDL, the second statement is added to the end of the generated DDL however it may be ignored by developers unfamiliar with Snowflake Syntax, causing possible security issues, allowing unauthorized access to the View DDL by Read-Only roles in Snowflake.

@Carolus-Holman Carolus-Holman added enhancement New feature or request triage labels Sep 10, 2019
@drewbanin drewbanin added this to the Louisa May Alcott milestone Sep 10, 2019
@drewbanin drewbanin added the good_first_issue Straightforward + self-contained changes, good for new contributors! label Sep 10, 2019
@drewbanin
Copy link
Contributor

Thanks @SolariPicasso! This would be a great feature to add to dbt.

You can check out the code that dbt uses to create views on Snowflake here.

I think one good approach for implementing this might be to add a config, like secure: true|false. We do something similar on Redshift to support "late bound views".

A config like secure would work like:

{{ config(materialized='view', secure=true) }}

We can also add secure as an AdapterSpecificConfig which will allow users to supply the secure: config in their dbt_project.yml file.

If this is something you're interested in contributing a PR for, I'd be happy to help!

@Carolus-Holman
Copy link
Contributor Author

@drewbanin I am interested in contributing, however my Python knowledge is close to Zero, I have forked the branch, loaded the project, added some code to enable the secure view, however I can't seem to get the .15 build to work. I have read through the docs on the coding environment, and I am struggling to use the build correctly. Are there any pointers for getting DBT running using VSCODE and Windows. Thanks. Code Below:
Adapters.sql:
{% macro snowflake__create_view_as(relation, sql) -%} create or replace {% if secure -%} secure {%- endif %} view {{ relation }} as ( {{ sql }} ); {% endmacro %}
IMPL.py
AdapterSpecificConfigs = frozenset( {"transient", "cluster_by", "automatic_clustering","secure"} )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good_first_issue Straightforward + self-contained changes, good for new contributors! snowflake
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants