What you will be able to do
- Write a row access policy, including one that uses a mapping table, and predict its performance cost and evaluation order
- Use a projection policy so a column can be filtered on but never returned
- Explain what an aggregation policy requires of queries and where its protection stops
- Choose between the clean rooms UI and the developer APIs for a clean room task
- Identify which Snowflake policies still apply when external engines read Iceberg tables through Horizon Catalog
1.Row access policies filter rows
Masking hides values inside a column. A row access policy decides whether a row appears at all. It is a schema-level object that returns BOOLEAN. When a policy is attached, Snowflake treats the table as a dynamic secure view: it binds the columns named in the ALTER TABLE or ALTER VIEW statement to the policy's parameters and returns only rows where the policy evaluates to TRUE. One policy can protect many tables and views.
CREATE OR REPLACE ROW ACCESS POLICY rap_it
AS (empl_id varchar) RETURNS BOOLEAN ->
'it_admin' = current_role()
;Real policies usually look up a mapping table. Say sales managers map to regions: Alice to WW, Bob to NA, Simon to EU. A subquery against that table lets Alice see every region and Bob only NA. Snowflake evaluates the policy with the policy owner's role, so the people querying the table never need access to the mapping table. Keep the mapping table in the same database as the protected table. This matters most when the policy calls IS_DATABASE_ROLE_IN_SESSION.
Mapping tables cost performance, and the policy's arguments cost scanning. Snowflake scans every column bound to the policy, even when the query does not reference it, so fewer arguments perform better. A plain CASE expression is faster than a lookup. Where you do need a lookup, replace the mapping-table reference with a memoizable function.
Row access policies apply to SELECT and to the rows that UPDATE, DELETE and MERGE select. They do not stop INSERT, and they do not stop updates or deletes on rows the caller can already see. When a table and a view on it each have a policy, the table's policy runs first and then each view's policy, in order along the view chain. Use ALTER ROW ACCESS POLICY to change the expression; the policy stays attached and the rows stay protected while you edit it.
Checkpoint 1 of 7· Fill the gap
This row access policy lets only it_admin see rows. Which return type completes the signature?
CREATE OR REPLACE ROW ACCESS POLICY rap_it
AS (empl_id varchar) RETURNS ? ->
'it_admin' = current_role()
;A row access policy returns BOOLEAN, and Snowflake returns only the rows where it evaluates to TRUE. Unlike a masking policy, its output type does not have to match the input column's type.
Source: docs.snowflake.comCheckpoint 2 of 7· Check yourself
A row access policy on a SALES table uses a subquery against a REGION_MANAGERS mapping table. The analysts who query SALES have no privileges on REGION_MANAGERS. What happens when an analyst queries SALES?
Snowflake evaluates the row access policy expression with the policy owner's role. People who query the table never need access to the mapping table.
“Snowflake evaluates the policy expression by using the role of the policy owner, not the role of the operator who executed the query.”Source: docs.snowflake.com
Sources1
2.Projection policies: filter on a column without returning it
A projection policy decides whether a column may appear in a query's final output. A column with one is called projection-constrained. When projection is denied, the column is not returned and cannot be inserted into another table. It also cannot be passed as an argument to an external function or stored procedure. Analysts can still filter and join on it, which leaves them more room to work with the column than a masked or tokenized value would.
The two controls work differently. A masking policy replaces the value: a masked column still comes back in SELECT *, filled with '****' or NULL. A projection policy keeps the column out** of the output altogether. Choose projection when a column must never be returned to a role, even as a placeholder.
CREATE OR REPLACE PROJECTION POLICY mypolicy AS () RETURNS PROJECTION_CONSTRAINT -> CASE WHEN CURRENT_ROLE() = 'ANALYST' THEN PROJECTION_CONSTRAINT(ALLOW => true) ELSE PROJECTION_CONSTRAINT(ALLOW => false, ENFORCEMENT => 'NULLIFY') END;Every projection policy has the signature AS () RETURNS PROJECTION_CONSTRAINT, and the body must return PROJECTION_CONSTRAINT(...), never NULL. A column can have one projection policy at a time. Projection policies cannot be tag-based. They also cannot go on a virtual column or the VALUE column of an external table, so put a view in front and set the policy on the view's columns. A projection-constrained column can also carry a masking policy, and its table can carry a row access policy.
Projection does not hide who is in the data. Anyone can filter to a single individual. Joining the protected column to an unprotected table on that column lets them project the matching value from the unprotected side. Use projection policies with partners you already trust. If a column must not leak at all, leave it out of the data or use differential privacy.
Checkpoint 3 of 7· Check yourself
Your governance team labels every PII column with a PII tag. A partner role must still be able to filter and join on those columns but must never get them back in a query result. Which plan works?
Projection policies cannot be tag-based, so each one has to be assigned directly to a column. A row access policy removes whole rows, so the partner role could no longer filter or join on them.
“A projection policy cannot be applied to: A tag assigned to a table or column (that is, a tag-based projection policy).”Source: docs.snowflake.com
Checkpoint 4 of 7· Exam question
A governance team wants a national_id column to never appear in any query result for analyst roles, including inside WHERE clauses or SELECT * output, rather than showing a masked placeholder value. Which control fits this requirement?
Correct answer: A — Apply a projection policy to the column, since projection policies block a column from being returned in query output for roles the policy denies.
- A. Projection policies are designed to stop a column from being projected at all for restricted roles, so the column simply does not appear in the output rather than showing a substitute value, matching the requirement exactly.
- B. A masking policy still lets the column be projected; it only substitutes NULL or another value in place of the real one, so the column would still appear in output rather than being absent as required.
- C. Row access policies filter which rows are visible based on a boolean expression, but they do not control whether a particular column can be projected, so this would not hide the column itself.
- D. Revoking table-level SELECT would block the analyst role from the whole table rather than only this one column, which is broader than the stated requirement to hide a single column.
Sources2
3.Aggregation policies: answers only in aggregate
An aggregation policy goes on a table or view, not a column. It forces queries against that table or view to aggregate data instead of returning individual records. Like a projection policy, it has a fixed signature, and its body returns one of two functions. AGGREGATION_CONSTRAINT sets the aggregation rules a query must follow. NO_AGGREGATION_CONSTRAINT lifts them, typically for a trusted role named in a CASE branch.
CREATE [ OR REPLACE ] AGGREGATION POLICY <name> AS () RETURNS AGGREGATION_CONSTRAINT -> <body> [ COMMENT = '<string_literal>' ];Aggregation limits what one query can return, not what many queries can piece together. With enough well-chosen queries, a determined user can work out an individual row's value. Use aggregation policies, like projection policies, with partners and customers you already trust, and review the access history of your listings for misuse.
Checkpoint 5 of 7· Match them up
Match each Snowflake policy to where it is set and what it controls.
Tap a term, then the definition that fits it.
Masking and projection policies work on a single column: masking replaces the value, while projection keeps the column out of the output. Row access and aggregation policies work on a whole table or view: one filters rows, the other forces answers in aggregate.
“A projection policy is a first-class, schema-level object that defines whether a column can be projected in the output of a SQL query result.”Source: docs.snowflake.com
Sources3
4.Snowflake Data Clean Rooms: UI and developer APIs
A Snowflake Data Clean Room lets a provider and a consumer analyse their data together under rules each side controls. A consumer can set column and join policies on its own data and set differential privacy settings for queries the provider runs. With the provider's permission, it can load a Python script into the clean room. If every provider involved agrees, it can query across its own data and data from several clean rooms.
You manage clean rooms in two ways: the no-code clean rooms UI in a browser, and the developer API. The two do not offer the same features. One clean room can use both: create it in the UI and manage it through the API, or the other way round.
| Task | Where it is done |
|---|---|
| Setting the clean room logo, name and description, and the list of activation or identity connectors | UI only |
| Managing administrator, provider and consumer accounts | UI only |
| Scheduling repeated runs of a template, and using identity providers | UI only |
| Creating custom provider or consumer templates, and template chains | API only |
| Multi-provider analysis | API only |
| Consumer-level access control (restrict_table_options_to_consumers, restrict_template_options_to_consumers) | API only |
Templates are where the two diverge most. In the UI, you run the templates you are given. Writing a custom template, or chaining templates together, needs the API.
Checkpoint 6 of 7· Check yourself
In a clean room, a consumer lets a provider run analyses on the consumer's customer data. The consumer must make sure the provider cannot recover any individual's value from one sensitive column, even with many carefully built queries. Which control gives that guarantee?
Projection and aggregation policies limit what a single query returns. Deliberate filters, joins or repeated queries can still expose individual values, and SHA2 hashes can be joined on. To prevent leakage completely, leave the column out of the data or use differential privacy. In a clean room, the consumer can apply differential privacy to the queries the provider runs.
“if you need to prevent leakage about a specific column or entity, you should omit the column entirely from your data, or employ differential privacy.”Source: docs.snowflake.com
Sources4
5.Policies that follow Iceberg tables to external engines
Horizon Catalog makes Snowflake-managed Iceberg tables available to other engines, as covered in Horizon Catalog and catalog federation. This section covers what happens to your policies when those engines read the tables. Snowflake still enforces row-level and column-level protection on Iceberg tables queried from engines such as Apache Spark, PyIceberg and Trino, so Snowflake's rules apply whichever engine runs the query.
Enforcement works in two ways. The Snowflake Connector for Spark sends queries through Snowflake over JDBC. It pushes down more work and supports every read and write on protected tables. The Iceberg REST Catalog Scan Plan API works with any engine on Iceberg SDK 1.11 or later: Snowflake shares a temporary, already-filtered dataset with the engine.
Only four policy types are enforced this way: masking policies, row access policies, and the tag-based versions of each. Projection and aggregation policies are not enforced through this path. Don't rely on them to protect an Iceberg table that external engines read.
Checkpoint 7 of 7· Check yourself
Spark jobs at a partner will read a Snowflake-managed Iceberg table through Horizon Catalog. The table's customer_ssn column must stay protected when the partner reads it. Which control still applies when Spark runs the query?
Through Horizon Catalog, Snowflake enforces only masking policies, row access policies and their tag-based versions on Iceberg tables that external engines read. Projection and aggregation policies are not enforced on this path. Policies are not bypassed either, because Snowflake enforces them whichever engine runs the query.
“Snowflake supports enforcing dynamic data masking policies on Apache Iceberg tables that you query from Apache Spark™ through Snowflake Horizon Catalog.”Source: docs.snowflake.com
Sources5
Sources
(6)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“store the mapping table in the same database as the protected table”
↩︎ Row access policies filter rows“Row access policies do not currently prevent rows from being inserted, or prevent visible rows from being updated or deleted.”
↩︎ Row access policies filter rows“The row access policy that is applicable to the table is always executed first.”
↩︎ Row access policies filter rows“policies with fewer arguments will generally perform better than policies with many arguments”
↩︎ Row access policies filter rows“replace the mapping table reference with a memoizable function”
↩︎ Row access policies filter rows“Snowflake evaluates the policy expression by using the role of the policy owner, not the role of the operator who executed the query.”
↩︎ Exam trap 1“Snowflake evaluates the policy expression by using the role of the policy owner, not the role of the operator who executed the query.”
↩︎ Checkpoint - 2.
“Cannot be an argument for an external function or stored procedure.”
↩︎ Projection policies: filter on a column without returning it“A projection policy does not prevent the targeting of an individual.”
↩︎ Projection policies: filter on a column without returning it“A column can only have one projection policy assigned to it at any given time.”
↩︎ Projection policies: filter on a column without returning it“anyone else will see only NULL values for that column or any column that derives from that column”
↩︎ Projection policies: filter on a column without returning it“A projection policy cannot be applied to: A tag assigned to a table or column”
↩︎ Exam trap 2“columns that are hidden by projection policies can still be used in inner queries or in WHERE clauses”
↩︎ Prediction“A projection policy cannot be applied to: A tag assigned to a table or column (that is, a tag-based projection policy).”
↩︎ Checkpoint“A projection policy is a first-class, schema-level object that defines whether a column can be projected in the output of a SQL query result.”
↩︎ Checkpoint“if you need to prevent leakage about a specific column or entity, you should omit the column entirely from your data, or employ differential privacy.”
↩︎ Checkpoint - 3.
“The body of an aggregation policy uses two functions to define the constraints of the policy: NO_AGGREGATION_CONSTRAINT and AGGREGATION_CONSTRAINT.”
↩︎ Aggregation policies: answers only in aggregate“With enough query attempts, a malicious actor could potentially work around the aggregation requirements to ascertain a value from an individual row.”
↩︎ Aggregation policies: answers only in aggregate - 4.
“Snowflake Data Clean Rooms provide both a no-code browser-based application (the clean rooms UI) and an API to create and manage clean rooms.”
↩︎ Snowflake Data Clean Rooms: UI and developer APIs“you can create a clean room using the clean rooms UI and then use or manage it in the API”
↩︎ Snowflake Data Clean Rooms: UI and developer APIs“Set differential privacy settings for provider-run queries”
↩︎ Snowflake Data Clean Rooms: UI and developer APIs - 5.
“Snowflake supports enforcing row-level and column-level data protection policies on Iceberg tables queried from external engines such as Apache Spark™, PyIceberg, and Trino.”
↩︎ Policies that follow Iceberg tables to external engines“Enforces policies by sharing a temporary, policy-filtered dataset with the external engine.”
↩︎ Policies that follow Iceberg tables to external engines“All other policy types in Snowflake aren’t supported.”
↩︎ Exam trap 3
Also cited
“Snowflake supports enforcing dynamic data masking policies on Apache Iceberg tables that you query from Apache Spark™ through Snowflake Horizon Catalog.”
↩︎ Checkpoint