Data Governance in Snowflake: Row-Level Security, Masking Policies, and Access Controls

Celestinfo Software Solutions Pvt. Ltd. • Nov 13, 2025

Last updated: October 2026

Quick answer: Snowflake's governance model centers on RBAC with role hierarchies, row access policies for row-level security, dynamic data masking policies for column-level protection, secure views for hiding query logic, and object tagging for automated classification. Start with a clean role hierarchy (functional roles separate from data access roles), add row access policies and masking where compliance requires it, and use ACCESS_HISTORY for auditing. Both masking and row access policies can look up a mapping table, which keeps access rules in data. Row access policies add a predicate to every query, so test with production-scale data before rolling out.

Introduction

Snowflake ships with a solid set of governance features, but most teams don't use them effectively. They'll create a handful of roles, slap a masking policy on the SSN column, and call it governed. Then 6 months later, an auditor asks who accessed customer PII last quarter and nobody can answer the question. This guide covers the practical implementation of Snowflake's governance features, concentrating on the parts that matter for real compliance requirements, with the syntax and gotchas you'll hit along the way.

Snowflake's RBAC Model: Building a Role Hierarchy That Works

Snowflake uses role-based access control as its foundation. Every privilege, such as SELECT on a table, USAGE on a warehouse or CREATE TABLE in a schema, is granted to a role, and roles get granted to users (or other roles). The mistake most teams make is creating one role per person or one role per team. Neither scales.

The pattern that works: separate functional roles from data access roles. Functional roles define what someone can do (run queries, create views, manage pipelines). Data access roles define what data someone can see.

-- Functional roles
CREATE ROLE analyst;
CREATE ROLE data_engineer;
CREATE ROLE data_admin;

-- Data access roles
CREATE ROLE pii_reader;
CREATE ROLE finance_data;
CREATE ROLE marketing_data;

-- Compose: an analyst who needs finance data
GRANT ROLE analyst TO USER jane;
GRANT ROLE finance_data TO USER jane;

-- Role hierarchy: data_admin inherits from data_engineer
GRANT ROLE data_engineer TO ROLE data_admin;

This composable approach means you don't need to create a finance_analyst AND a marketing_analyst AND a finance_engineer role. You mix and match. When a new department comes along, you create one new data access role instead of N new combined roles.

Row-Level Security with Row Access Policies

Row access policies let you filter which rows a user sees based on their role or identity. The policy is a SQL expression that returns a boolean - if it returns TRUE for a row, the user sees it. If FALSE, the row is invisible.

-- Mapping table: which role may see which department
CREATE TABLE IF NOT EXISTS governance.department_access (
  role_name     VARCHAR,
  department_id VARCHAR
);

-- Row access policy for multi-tenant data. The argument is named dept_id so
-- it cannot be confused with the mapping table's department_id column.
CREATE OR REPLACE ROW ACCESS POLICY department_filter
  AS (dept_id VARCHAR) RETURNS BOOLEAN ->
    IS_ROLE_IN_SESSION('DATA_ADMIN')
    OR IS_ROLE_IN_SESSION('ALL_DEPARTMENTS')
    OR EXISTS (
      SELECT 1
      FROM governance.department_access m
      WHERE m.role_name = CURRENT_ROLE()
        AND m.department_id = dept_id
    );

-- Apply it to the table
ALTER TABLE sales.orders
  ADD ROW ACCESS POLICY department_filter ON (department_id);

The policy above lets DATA_ADMIN and anyone holding ALL_DEPARTMENTS see everything, and everyone else sees only the departments mapped to their current role in governance.department_access. This is the multi-tenant pattern, where each department sees only its own data from the same table. Keeping the mapping in a table means that granting a department is an INSERT, not a policy change.

Performance gotcha: Row access policies add a predicate to every query against the protected table. Snowflake evaluates the policy condition for every row. On large tables the overhead depends on how complex the policy is, and a policy that looks up a mapping table adds that lookup to every query. If your policy column aligns with the table's clustering key, the overhead is minimal because Snowflake can prune micro-partitions. If it doesn't, you're scanning more data. Test with representative workloads before deploying to production.

Does this need to survive an audit? Role hierarchies, masking policies and row access rules are quick to draw and hard to keep correct once several teams are changing them. We implement the model in your account and leave behind the tests that prove it still holds next quarter.

Book a governance review Data engineering services

Dynamic Data Masking

Masking policies let you hide or partially reveal column values based on the querying user's role. Unlike row access policies (which filter rows), masking policies transform column values in place.

-- Full masking: non-privileged roles see '***'
CREATE OR REPLACE MASKING POLICY mask_ssn
  AS (val STRING) RETURNS STRING ->
    CASE
      WHEN IS_ROLE_IN_SESSION('PII_READER') THEN val
      ELSE '***-**-****'
    END;

-- Partial masking: show last 4 digits of phone
CREATE OR REPLACE MASKING POLICY mask_phone
  AS (val STRING) RETURNS STRING ->
    CASE
      WHEN IS_ROLE_IN_SESSION('PII_READER') THEN val
      ELSE CONCAT('***-***-', RIGHT(val, 4))
    END;

-- Apply to columns
ALTER TABLE customers.profiles
  MODIFY COLUMN ssn SET MASKING POLICY mask_ssn;
ALTER TABLE customers.profiles
  MODIFY COLUMN phone SET MASKING POLICY mask_phone;

Lookups are allowed: A masking policy can check a mapping table with a subquery. Snowflake's reference says to use EXISTS in the WHEN branch when the policy body contains a subquery, and recommends a centralised mapping table in the same database as the protected table. For simpler rules, context functions such as CURRENT_ROLE(), IS_ROLE_IN_SESSION(), INVOKER_ROLE() and IS_DATABASE_ROLE_IN_SESSION() are enough.

-- Lookup-based masking: roles listed in the mapping table see the value
CREATE OR REPLACE MASKING POLICY mask_email
  AS (val STRING) RETURNS STRING ->
    CASE
      WHEN EXISTS (
        SELECT 1 FROM governance.pii_access m
        WHERE m.role_name = CURRENT_ROLE()
      ) THEN val
      ELSE '*** masked ***'
    END;

Secure Views vs. Regular Views

Regular views in Snowflake expose the view definition to anyone with SELECT privilege. That's a problem if the view logic itself reveals something about the underlying data structure you don't want users to know. Secure views solve this in two ways: they hide the view definition, and they prevent the optimizer from pushing user predicates into the view query.

CREATE OR REPLACE SECURE VIEW analytics.customer_summary AS
SELECT
  customer_id,
  region,
  total_orders,
  lifetime_value
FROM raw.customers
WHERE is_active = TRUE;

With a regular view, the optimizer may evaluate a user's own expressions, such as a function that raises an error on particular values, before the view's filter has removed the rows the view is meant to hide, which can reveal those rows indirectly. A secure view prevents that ordering. The tradeoff is that secure views can be slower, because the optimizer has fewer options for query planning. Use secure views for anything involving sensitive data or row filtering logic, and regular views for everything else.

Object Tagging for Data Classification

Snowflake's object tagging lets you attach metadata to databases, schemas, tables, and columns. This is how you classify data (PII, PHI, financial, public) without maintaining a separate data catalog.

-- Create tag
CREATE OR REPLACE TAG governance.sensitivity
  ALLOWED_VALUES 'PII', 'PHI', 'FINANCIAL', 'INTERNAL', 'PUBLIC';

-- Apply tags
ALTER TABLE customers.profiles
  MODIFY COLUMN email SET TAG governance.sensitivity = 'PII';
ALTER TABLE customers.profiles
  MODIFY COLUMN ssn SET TAG governance.sensitivity = 'PII';

-- Test classification on one table (Enterprise Edition or higher). auto_tag applies
-- Snowflake's system tags (SNOWFLAKE.CORE.SEMANTIC_CATEGORY and PRIVACY_CATEGORY),
-- not the governance.sensitivity tag created above.
SELECT SYSTEM$CLASSIFY('customers.profiles', {'auto_tag': true});

For ongoing classification, Snowflake now classifies sensitive data automatically once you create a classification profile and set it on a database or schema with ALTER DATABASE ... SET CLASSIFICATION_PROFILE, and classification starts about an hour later. A profile applies Snowflake's system tags and, through a tag map, can also apply your own tags such as governance.sensitivity. SYSTEM$CLASSIFY remains useful for testing on a single table. Classification is a starting point, because it can miss custom identifiers and occasionally flags columns that only look sensitive, so review the results manually.

Access History and Auditing

Snowflake's ACCESS_HISTORY view in the ACCOUNT_USAGE schema tracks which columns were accessed by which queries. Combined with QUERY_HISTORY, this gives you a complete audit trail.

-- Who accessed the SSN column in the last 30 days?
SELECT DISTINCT
  ah.user_name,
  ah.query_id,
  ah.query_start_time
FROM snowflake.account_usage.access_history ah,
  LATERAL FLATTEN(input => ah.direct_objects_accessed) obj,
  LATERAL FLATTEN(input => obj.value:columns) col
WHERE ah.query_start_time > DATEADD('day', -30, CURRENT_TIMESTAMP())
  AND obj.value:objectName::STRING = 'MYDB.CUSTOMERS.PROFILES'
  AND col.value:columnName::STRING = 'SSN'
ORDER BY ah.query_start_time DESC;

ACCESS_HISTORY retains data for 365 days. For longer retention, export it to a separate table on a schedule. Pair this with your broader governance and cost optimization framework to track not just who accessed data, but what it cost to serve those queries.

Network Policies for IP Whitelisting

Network policies restrict which IP addresses can connect to your Snowflake account. This is a blunt but effective control, because even someone with valid credentials can't connect from an unauthorized network. Snowflake now says that all new network policies should use network rules instead of the ALLOWED_IP_LIST and BLOCKED_IP_LIST parameters, although existing IP-list policies still work.

-- Network rules hold the address ranges
CREATE NETWORK RULE governance.office_ips
  TYPE = IPV4
  MODE = INGRESS
  VALUE_LIST = ('203.0.113.0/24', '198.51.100.0/24');
CREATE NETWORK RULE governance.blocked_ips
  TYPE = IPV4
  MODE = INGRESS
  VALUE_LIST = ('203.0.113.99');

CREATE NETWORK POLICY office_only
  ALLOWED_NETWORK_RULE_LIST = ('governance.office_ips')
  BLOCKED_NETWORK_RULE_LIST = ('governance.blocked_ips');

-- Apply account-wide
ALTER ACCOUNT SET NETWORK_POLICY = office_only;
-- Or apply to specific users
ALTER USER contractor_jane SET NETWORK_POLICY = office_only;

You can apply network policies at the account level, to individual users or to security integrations. A user's policy overrides the account policy, and a policy on a security integration overrides both. For organizations using Azure PrivateLink or AWS PrivateLink, network policies work alongside private connectivity to provide defense in depth.

Putting It Together: Multi-Tenant Data Access Model

Here's how these features compose for a multi-tenant analytics platform, where each department sees only its own data, PII is masked for non-privileged users, and everything is auditable:

Key Takeaways

CelestInfo Engineering Team

Data engineering and cloud consulting. We build governance frameworks, migrate warehouses, and make data platforms that pass audits without surprises. About us

Related Articles

Burning Questions About Snowflake Data Governance

Quick answers to what teams ask us most

Yes. A masking policy body can contain a subquery against a mapping table, and Snowflake's reference says to use EXISTS in the WHEN branch for it. Snowflake recommends keeping the mapping table in the same database as the protected table. For simpler rules, context functions such as CURRENT_ROLE() or IS_ROLE_IN_SESSION() are enough.

Yes. Row access policies add a predicate to every query against the protected table, which means Snowflake evaluates the policy condition for every row. For large tables (100M+ rows), this can add measurable overhead. Always test with representative workloads and consider whether clustering keys align with the columns used in your row access policy.

Secure views hide the view definition (SQL query) from users who don't own the view, and the Snowflake query optimizer won't push predicates from user queries into the view definition. This prevents users from inferring underlying data through query plan analysis. Regular views expose the definition and allow predicate pushdown, which is faster but less secure.

Snowflake's ACCESS_HISTORY view in the ACCOUNT_USAGE schema tracks which columns were accessed by which queries. Combined with QUERY_HISTORY, you can build a complete audit trail of who queried what data, when, and how. ACCESS_HISTORY has a 365-day retention period.

Ready? Let's Talk!

Get expert insights and answers tailored to your business requirements and transformation.

Get Assistance