Created
June 27, 2025 17:11
-
-
Save 2tony2/4cc21697907e57336ef307c721504a80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Create a masking policy for email addresses | |
| CREATE OR REPLACE MASKING POLICY email_mask AS (val string) | |
| RETURNS string -> | |
| CASE | |
| WHEN CURRENT_ROLE() IN ('ANALYST') THEN val | |
| ELSE REGEXP_REPLACE(val, '.+\@', '*****@') | |
| END; | |
| -- Create a tag for PII data | |
| CREATE TAG pii_email_data; | |
| -- Assign the masking policy to the tag | |
| ALTER TAG pii_email_data SET MASKING POLICY email_mask; | |
| -- Now tag any email column - automatic protection | |
| ALTER TABLE customers MODIFY COLUMN email_address SET TAG pii_email_data = 'sensitive'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment