Skip to content

Decide to Unset Masking Policies

dbt-tags supports a macro to help us to perform Unset Masking Policy operation (1) from the Object Tags easily for a clean up purpose. Please note that we shouldn't run it (1) prior to Set Masking Policy operation (2) because we always run (2) with Force.

unapply_mps_from_tags (source)

Usage

dbt run-operation unapply_mps_from_tags [\
  --args '{ns: "database.schema", debug: true}']

See doc in yml

How does it work?

For example, you'd like to Unset Masking Policy from the tags that were created in the schema named analytics.demo.

Let's run the command below:

dbt run-opertion unapply_mps_from_tags \
  --vars '{ns: "analytics.demo"}'
  • It scans all the Object Tags that were created in analytics.demo schema. Behind the scene script is:

    show tags in schema analytics.demo;
    select  "database_name" || '.' || "schema_name" || '.' || "name" as tag_name
    from    table(result_scan(last_query_id()))
    where   "database_name" || '.' || "schema_name" ilike 'analytics.demo';
    
  • If exists any tags:

  • Checks if masking policy has multiple data types

    • Unset masking policy from tag with
  • Done!