Clean Room 테이블 정책 이해¶
Clean rooms can implement data policies to control how data can be used by collaborators. These are in addition to any Snowflake table policies set on the underlying tables linked into the clean room.
Each collaborator in a clean room can set policies on their own data. Your policies are enforced only in requests from other users; your policies are not enforced against your own requests. For example, if your join policy allows joins against only column A, other users are restricted to joining on column A, but you can run joins against any of your columns.
Clean Room 정책은 Clean Room API 또는 UI 를 사용하여 설정할 수 있습니다.
To implement policy checks, the following must be true:
The data owner must set a policy in their clean room. You can set policies using either the API or the UI. Each policy type is set separately. Clean room natively implements column policies, row policies, and activation policies. Clean room policies are not additive: When you set a clean room policy, all previous values are deleted.
-- Sets a join policy on column HASHED_EMAIL. CALL samooha_by_snowflake_local_db.provider.set_join_policy( 'my_provider_cleanroom', ['my_db.my_sch.T1:HASHED_EMAIL']); -- Replaces the previous join policy. Now the only column in the join policy is AGE_BND. CALL samooha_by_snowflake_local_db.provider.set_join_policy( 'my_provider_cleanroom', ['my_db.my_sch.T1:AGE_BAND']);
The template must check the policy in the appropriate place in the template. A clean room policy is checked only if it has the appropriate policy filter applied to the column in the template. If you set a clean room policy to protect your data, you should examine the template to confirm that the template is enforcing your policies as you expect. The following template checks whether col1 is allowed by the data owner’s column policy:
SELECT IDENTIFIER( {{ col1 | column_policy }} ) FROM {{ source_table[0] }} AS c;
The following template does not check whether
col1has a clean room policy:SELECT IDENTIFIER( {{ col1 }}) FROM {{ source_table[0] }} AS c;
Clean rooms supports a different template filter for each policy type. However, the semantics of the filter are not checked, only whether the column is in the policy for that filter type. For example, in the following snippet, the join policy is checked for
col1, even though the column is not being joined against. Ifcol1is in the data owner’s join policy, the query can succeed; ifcol1is not in the data owner’s join policy, the query will be blocked.SELECT IDENTIFIER( {{ col1 | join_policy }}) FROM {{ source_table[0] }} AS c;
참고
Column policy checks are carried out when the template JinjaSQL is parsed. Queries with wildcards might not be caught using these checks, and discretion should be used when designing an analysis template. If some columns should really never be queried, consider creating a view of your source table that eliminates these sensitive columns, and link in that view instead.
Snowflake policies in clean rooms¶
When you link tables into a clean room, any Snowflake table policies on the source tables are enforced in the linked tables in the clean
room, but these policies aren’t necessarily reported by the clean room API or UI. For instance, a
Snowflake join policy continues to be enforced in the clean room, but that join policy is not visible
by calling consumer.view_provider_join_policy or consumer.view_join_policy. Therefore, you should either remove policies from the
underlying linked tables, create equivalent clean room policies (when they exist), or communicate the existence of these policies clearly
to your collaborators so that their queries don’t fail or behave unexpectedly (“why can’t I join on this column?”).
Any changes to Snowflake policies in the source tables are automatically propagated to the linked views in the clean room.
Snowflake 개인정보 처리방침 에 따라 보호된 테이블에서 뷰를 만들 수 없으므로 개인정보 처리방침이 있는 테이블에 연결할 수 없습니다.
조인 정책¶
Set a join policy to indicate which columns in your data can be joined on by any template in the clean room. (Snowflake join policies, in contrast, specify which columns must be joined on.) Join policies apply to all templates in the clean room.
A column cannot be in both a join policy and a column policy, but a column can be in both a join policy and an activation policy.
조인 정책 구현하기¶
Clean room join policies are enforced against a column if the template applies the join_policy or join_and_column_policy
filter to the column.
If a template checks a join policy for a column, and the clean room has no join policies set, or the column is not in the join policy, the query will be blocked.
The following code shows how to set join policies as a provider or a consumer. Remember that policies are only enforced against queries run by another account.
-- Set join policies on two columns in a clean room where you are a provider.
CALL samooha_by_snowflake_local_db.provider.set_join_policy(
'my_provider_cleanroom',
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:HASHED_EMAIL', 'MYDB.MYSCH.EXPOSURES:HASHED_EMAIL']);
-- Set join policies on two columns in a clean room where you are a consumer.
CALL samooha_by_snowflake_local_db.consumer.set_join_policy(
'my_consumer_cleanroom',
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:HASHED_EMAIL', 'MYDB.MYSCH.EXPOSURES:HASHED_EMAIL']);
다음 프로시저는 코드에서 조인 정책을 보거나 관리하는 데 사용됩니다.
consumer.set_join_policyconsumer.view_provider_join_policyconsumer.view_join_policyprovider.view_join_policyprovider.set_join_policy
열 정책¶
Set a column policy to indicate which of your columns can be projected in analysis results from a specific template. Column policies are applied to specific templates in a specific clean room.
열은 조인 및 열 정책에 모두 포함될 수 없습니다. 열은 활성화 및 열 정책에 모두 포함될 수 있습니다.
열 정책 구현하기¶
Clean room column policies are enforced against a column only if the template uses the column_policy or join_and_column_policy
filter.
If a clean room checks a column policy for a column, and the column is not in the column policy, or the clean room has no column policies, the query will be blocked.
The following code shows how to set column policies for three columns when accessed by the prod_overlap_analysis template. The example
shows how to set the policy both as a provider and a consumer. Remember that policies are only enforced against queries
run by another account.
-- Set column policy on prod_overlap_analysis template in a clean room where
-- you are a provider.
call samooha_by_snowflake_local_db.provider.set_column_policy(
'my_provider_cleanroom',
['prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:STATUS',
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:AGE_BAND',
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:DAYS_ACTIVE']);
-- Set column policy on prod_overlap_analysis template in a clean room where
-- you are a consumer.
call samooha_by_snowflake_local_db.consumer.set_column_policy(
'my_consumer_cleanroom',
['prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:STATUS',
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:AGE_BAND',
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:DAYS_ACTIVE']);
다음 프로시저는 코드에서 열 정책을 보거나 관리하는 데 사용됩니다.
consumer.set_column_policyconsumer.view_column_policyconsumer.view_provider_column_policyprovider.set_column_policyprovider.view_column_policy
활성화 정책¶
Set an activation policy to indicate which of your columns can be activated by an activation template. Activation saves query results to a table in the Snowflake account of the provider or consumer, or to a third-party activation connector.
열은 다른 정책과 마찬가지로 활성화 정책의 일부가 될 수 있습니다.
활성화 정책 구현하기¶
활성화 정책은 템플릿에서 활성화를 허용하는 경우 Clean Rooms UI 에서 설정할 수 있습니다.
Activation policies are set for a specific column in a specific template.
Activation policies are enforced against a column only if the template applies the activation_policy filter to the column.
The following code demonstrates setting an activation policy to allow the HASHED_EMAIL and REGION_CODE columns to be activated in a clean room. This policy affects all users and all activation templates in the clean room. There are equivalent procedures for providers and consumers in a clean room. Call the procedure that reflects your role in the clean room.
-- Set activation policy on prod_overlap_analysis template in a clean room where you are a provider
call samooha_by_snowflake_local_db.provider.set_activation_policy('my_cleanroom', [
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:HASHED_EMAIL',
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:REGION_CODE' ]);
-- Set activation policy on prod_overlap_analysis template in a clean room where you are a consumer
call samooha_by_snowflake_local_db.consumer.set_activation_policy('my_cleanroom', [
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE_NAME.DEMO.CUSTOMERS:HASHED_EMAIL',
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE_NAME.DEMO.CUSTOMERS:REGION_CODE' ]);
다음 프로시저는 코드에서 활성화 정책을 관리하는 데 사용됩니다.
consumer.set_activation_policyprovider.set_activation_policy
집계 정책¶
집계 정책에서는 테이블에 대한 모든 쿼리에 집계(GROUP BY, COUNT, 기타 함수)가 포함되어야 하며 결과 그룹당 최소 행 수도 지정해야 합니다. 그렇지 않으면 그룹이 결과에서 생략됩니다.
Clean Rooms에는 자체 집계 정책이 구현되어 있지 않으므로 연결된 데이터에 집계 제약 조건을 적용하려면 원본 테이블에 집계 정책 을 적용하거나 템플릿에 집계 제약 조건을 구현하십시오.
일부 Snowflake 제공 템플릿은 사용자 또는 템플릿에 대해 설정된 threshold 및 threshold_value 매개 변수를 사용합니다. 이러한 값은 Clean Rooms UI 에서 수정하거나 provider.add_consumers 또는 provider/consumer.set_privacy 를 호출하여 수정할 수 있습니다. 컨슈머용으로 설정된 경우 템플릿에서 이 값에 액세스할 수 있습니다.