Search code examples
snowflake-cloud-data-platformmaskingtagging

Can snowflake masking policies be assigned to tags?


I know that masking policies can be assigned to columns, for example:

alter table if exists user_info modify column email set masking policy email_mask;

But can we assign one masking policy to a tag? So that all the columns with the tag in one table can automatically be assigned the masking policy?

Thanks.


Solution

  • The simple answer is No. Masking policies can only be attached on columns of Tables and Views.

    If you are looking to automatically assign Masking Policies to tagged columns, you can do the following:

    1. Join the COLUMNS View and TAG_REFERENCES View to generate an ALTER Statement that sets the masking policy to tagged columns that doesn't have masking policies assigned to them
    2. Put it in a Stored Procedure
    3. Schedule a Task to run the Stored Procedure regularly