Consider a masking policy applied to a column in Snowflake. What happens when a user without the required role queries that column?
Think about what masking means: hiding or changing data for unauthorized users.
A masking policy replaces the original data with masked values for users who do not have the required privileges. It does not block the query or return NULLs but shows obfuscated data.
Which of the following SQL statements correctly creates a masking policy in Snowflake that masks a column's value to '****' for unauthorized users?
Look for correct use of 'IN' operator and arrow '->' syntax.
The correct syntax uses 'AS (val STRING) RETURNS STRING ->' followed by the CASE expression. The role check uses 'IN' with parentheses for a list.
In an environment with multiple user roles, what is the best practice for applying masking policies to protect sensitive columns?
Think about simplicity and maintainability in role management.
Using a single masking policy with role checks simplifies management and ensures consistent masking behavior. Multiple policies on the same column are not supported. Views do not enforce masking policies directly, and relying only on access control misses the benefit of dynamic masking.
If a masking policy's CASE expression checks for a role that does not exist in Snowflake, what is the effect when the policy is applied?
Consider how role checks are evaluated at runtime.
Snowflake does not validate role names inside masking policies at creation. If a role does not exist, the check returns false, so users never match that role and data is masked for all.
Given this masking policy snippet:CASE WHEN CURRENT_ROLE() IN ('ADMIN') THEN val WHEN CURRENT_ROLE() IN ('AUDITOR') THEN 'REDACTED' ELSE NULL END
What will a user with the 'AUDITOR' role see when querying the masked column?
Think about how CASE statements evaluate conditions in order.
The CASE statement checks conditions top to bottom. Since the user is not 'ADMIN', the first condition fails. The second condition matches 'AUDITOR', so the user sees 'REDACTED'.