Comments (7)
Hi, I found this looking for a more elegant solution, but in case it helps, I'm solving this by adding both create masking policy if not exists
and then, if I have to edit it, adding a alter masking policy if exists
{% macro create_masking_policy_mp_mask_pii(node_database,node_schema) %}
CREATE MASKING POLICY IF NOT EXISTS {{node_database}}.{{node_schema}}.mp_mask_pii AS (val string)
RETURNS string -> IFF(CURRENT_ROLE() IN ('ROLE1'), val, '**********' );
ALTER MASKING POLICY IF EXISTS {{node_database}}.{{node_schema}}.mp_mask_pii SET BODY ->
IFF(CURRENT_ROLE() IN ('ROLE1', 'ROLE2'), val, '**********' )
{% endmacro %}
First time you run the macro in a new environment, it will run both, the create and alter, following runs, it will run only the alter as it is already created.
from dbt-snow-mask.
Just got aware of the fact that this is ak known limitation. Nevertheless, I think that handling this as an open issue is probably a good idea,so we can discuss ideas here...
from dbt-snow-mask.
I ran into this as well and had to choose between the IF EXISTS clause or the OR REPLACE clause. Maybe a separate Update procedure that unapplies, drops, then creates?
from dbt-snow-mask.
- @eugenekim-orrum Sorry that you faced this issue.
- I am managing with REPLACE clause now but thinking to enhance unapply macro.
- Do you have a list of actions which needs to happen and the scenarios on which this policy update would happen ?
- Tagging @robscriva as well here to discuss ideas and options
from dbt-snow-mask.
I'm coming to the party late so maybe things have changed in Snowflake since previous comments. Snowflake has an ALTER MASKING POLICY command which allows you to change the masking policy without having to go through the "unapplied, deleted, created (or CREATE OR REPLACE...) and applied again" process.
I'm still new to dbt, but I was able to build a macro that checks for the existence of the masking policy and does a CREATE or ALTER, depending on the result of the check.
Perhaps something like that could be added to the package.
from dbt-snow-mask.
Hello @mjahammel, I am open for suggestions and enhancements to the package. Do you mind sharing the source code for your macro, perhaps we can check and work together to see if this enhancement can be implemented ?
from dbt-snow-mask.
@entechlog , I will create a pull request with the new macro and an implementation of it.
from dbt-snow-mask.
Related Issues (20)
- Improvement: include sourcename or modelname in posthook to minimise overhead on run model tasks HOT 2
- Masking policy is not applied HOT 8
- apply policy to all models HOT 6
- Apply masking policy with FORCE keyword HOT 5
- Ability to update existing masking functions HOT 2
- Improvement: Allow for default dbt schema name generation HOT 2
- Improvement/bug: alert or warn when a masking policy specified does not exist
- dbt snow mask versioning HOT 2
- Feature Request: Make log optional
- Hyperlink to dbt's meta documetation HOT 1
- Post-hook executed as a pre-hook HOT 2
- Feature Request: Conditional Masking Policy HOT 3
- Applying policy on tables
- Masking policy does not apply for models or snapshots HOT 4
- Conditional Masking Policy does not need `{{masked_column}}` in its body
- Insufficient privilege to create a masking policy
- Unapply policies should handle if the materialization exists or not
- on-run-start with 'models' parameter failed HOT 1
- Abillity to use macro on dynamic talbe
- Ability to pass in node and custom_schema_name HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbt-snow-mask.