Skip to content

Commit

Permalink
BUG-59, changes to update README on how to add model level hooks (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
entechlog authored Apr 3, 2023
1 parent 41d079f commit 3330a73
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ vars:
- "{{ dbt_snow_mask.apply_masking_policy('snapshots') }}"
```

- If you prefer to add this directly to a dbt model, see below command for an correct example

```yaml
{{ config(post_hook = "{{ dbt_snow_mask.apply_masking_policy('models') }}") }}
```

# How to remove masking policy ?

- Remove the masking policy applied by this package by running below commands
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ models:
pre-hook:
- "{{ dbt_snow_mask.create_masking_policy('models')}}"
post-hook:
- "{{ dbt_snow_mask.apply_masking_policy('models') }}"
# - "{{ dbt_snow_mask.apply_masking_policy('models') }}"
# - "{{ dbt_snow_mask.unapply_masking_policy('models') }}"

snapshots:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% macro create_masking_policy_mp_ip(node_database,node_schema) %}

CREATE MASKING POLICY IF NOT EXISTS {{node_database}}.{{node_schema}}.mp_ip AS (val string)
RETURNS string ->
CASE WHEN CURRENT_ROLE() IN ('SYSADMIN') THEN val
WHEN CURRENT_ROLE() IN ('DEVELOPER') THEN SPLIT(val,'.')[3]::VARCHAR
ELSE '**********'
END

{% endmacro %}
2 changes: 2 additions & 0 deletions integration_tests/models/staging/pii/stg_contacts.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{ config(post_hook = "{{ dbt_snow_mask.apply_masking_policy('models') }}") }}

WITH contacts AS (
SELECT
contact_id,
Expand Down
3 changes: 3 additions & 0 deletions integration_tests/models/staging/pii/stg_contacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ models:
masking_policy: mp_conditional_contacts_pii
mp_conditional_columns:
- last_name

- name: last_name
description: ""
- name: email
Expand All @@ -23,6 +24,8 @@ models:

- name: ip_address
description: ""
meta:
masking_policy: mp_ip

- name: ssn
description: ""
Expand Down

0 comments on commit 3330a73

Please sign in to comment.