Snowflake Data Clean Rooms 概述¶
This page provides an overview of how Snowflake Data Clean Rooms works. If you are a Snowflake administrator and want to install clean rooms in your account, read 安装 Snowflake Data Clean Rooms 环境.
Snowflake Data Clean Rooms 概述¶
Data Clean Room 是可配置的隔离式 Snowflake 环境,协作者可以在其中导入数据,指定可以针对该数据运行哪些查询,并配置数据保护设置,例如差分隐私以及指定可联接和可投影的行。只有受邀才能访问 Clean Room。
Clean Room 不支持获利功能。提供商需要为启用 Clean Room 所需的各种后台进程付费;运行查询的账户按照 Snowflake 标准成本计费,用于支付数据和计算使用量。有关成本的更多信息,请参阅 了解成本。
您必须得到 Clean Room 提供商的邀请才能访问 Clean Room。如果您想向更多的受众开放您的 Clean Room,则必须提供一种方式,让潜在的协作者与您联系,提供他们的 Snowflake 账户以供您邀请(或为 非 Snowflake 用户 提供电子邮件地址)。
以下是对 Snowflake Data Clean Room 工作原理的高级概述:
Clean Room 环境安装¶
The Snowflake Data Clean Room environment is installed once for an entire Snowflake account (not once per user or per clean room) by someone with ACCOUNTADMIN privileges on the Snowflake account.
管理员配置环境以指定该账户中的哪些用户可以创建 Clean Room 并运行查询、哪些用户有 API 访问权限、哪些账户可以受邀在 Clean Room 中协作、Clean Room 创建者可以导入哪些数据,以及哪些(如果有)第三方服务可用于导出在此账户中创建的任何 Clean Room 的查询结果。
如果已经为您的账户安装了 Clean Room 环境,请联系您的 Clean Room 管理员获取访问权限。如果尚未为您的账户安装 Clean Room 环境,请了解如何安装该环境。
安装和配置环境后,管理员向其他 Snowflake 用户授予 Clean Room UI 和/或 API 的使用权限。
了解详情
了解如何 安装和配置 Clean Room 环境。
默认情况下,您只能与同一 Web 托管区域的账户共享 Clean Room。管理员可以 启用与其他区域的账户共享。
备注
If you were emailed an invitation to join a clean room, you already have clean rooms installed in your Snowflake account. You can read the rest of this page to learn more about clean room usage, but you don't need to install anything, only to join the clean room.
如果您是账户管理员 且 Snowflake 账户中未安装 Clean Room 环境,请 了解如何为您的 Snowflake 账户安装 Clean Room 环境。
**如果您不是账户管理员,**询问账户管理员您的账户是否已安装 Snowflake Data Clean Rooms。如果未安装,请他们安装并授予您访问权限。如果已安装,请他们授予您访问 Clean Room 的权限。
** 如果您是开发者并需要 API 访问权限,则 ** 请求 Clean Room 管理员 为您授予 API 的访问权限。
创建 Clean Room¶
A Snowflake account administrator grants permission to users in their Snowflake account to be able to create clean rooms. The account that creates a clean room is called a provider for that clean room. Providers can configure and share clean rooms with users in other Snowflake accounts (or even non-Snowflake users). When a clean room is shared with you, you are called a consumer for that clean room.
After creating a clean room, the provider links (imports) tables or views into it, specifies what queries can be run against their data, which columns in their data can be joined or appear in the results, and what can be done with the results.
The provider then invites consumers to join the clean room, link their own tables and views, and run one of the queries specified by the provider. Consumers must be pre-approved by a clean rooms administrator before they can be invited to a clean room.
了解详情
Clean Room 可以在代码中创建,也可以使用 Clean Room UI 创建。Web 用户 和 程序员 创建 Clean Room 的权限的授予方式有所不同。
表可以从 Snowflake 账户和 AWS、Azure 和 Google 上的 非 Snowflake Iceberg 表 导入。
在将数据导入 Clean Room 之前,必须由对源数据具有管理员权限的用户进行 注册。
您可以邀请 Snowflake 和 非 Snowflake 用户 联接 Clean Room。
详细了解 Clean Room 中的提供商角色。
During development, you can use the same account for both provider and consumer roles, though with only a subset of clean room functionality.
联接 Clean Room¶
创建和配置 Clean Room 后,提供商会向其他账户中的用户发送联接 Clean Room 的邀请。这些受邀用户被称为 使用者,有时被称为 协作者。通过 Clean Room UI 受邀的使用者会收到一封联接 Clean Room 的电子邮件邀请。Snowflake 用户必须安装 Clean Room 环境才能受邀联接 Clean Room,但您可以 `邀请非 Snowflake 用户 :doc:`</user-guide/cleanrooms/managed-accounts> 联接 Clean Room。Snowflake 账户必须由 Clean Room 管理员列入许可名单,然后 Clean Room 创建者才能邀请该账户中的用户。
(在 Clean Room UI 中,“联接”和“安装”都用于描述使用者何时接受 Clean Room 邀请。这是因为 Clean Room 必须安装在使用者的 Clean Room 环境中。)
联接 Clean Room 后,使用者在该 Clean Room 中导入模板(链接)所需的任何数据,指定如何访问他们的数据,例如可以联接或投影哪些列,提供任何特定模板的筛选器或其他参数,然后运行该模板。如果需要,使用者可以指定模板的重复运行。可以在浏览器中查看结果,也可以下载结果。如果提供商启用了激活功能且使用者批准,则用户可以将结果导出到批准的位置(他们自己的 Snowflake 账户或提供商指定的第三方激活连接器)。
Data imported into a clean room cannot be queried or viewed directly by either party --- either the provider or the consumer --- but can only be accessed through a template in the clean room. A template is a SQL query installed in the clean room by the provider or consumer, and permission must be given by the other party to use it in the clean room.
各方还根据自己的数据设置访问规则,包括哪些列可以联接、投影或导出,以及哪些模板可以在 Clean Room 中运行。各方可以随时从 Clean Room 中删除其数据。
默认情况下,只有使用者可以在 Clean Room 中运行模板,但提供商可以请求使用者的许可,以便在 Clean Room 中运行指定模板。
了解详情
Clean Room 支持 差分隐私。差分隐私可以由提供商或使用者启用和配置。
Templates¶
Every clean room has one or more templates installed. A template is a JinjaSQL query that typically includes run-time parameters provided by the template runner. These parameters enable users to specify column or table names or WHERE clause filters. You cannot simply run arbitrary SQL queries in a clean room (unless a provider grants that ability); most clean room usage is limited to templates submitted by the provider or consumer and approved by the other party.
Snowflake provides a few stock templates for common use cases such as audience overlap and reach and frequency templates. You can also create custom templates to use in your clean room. Snowflake Data Clean Rooms supports any valid JinjaSQL template.
模板可以在 Clean Room UI 中运行,也可以在代码中运行。模板结果可以查看或下载,也可以共享给提供商、使用者或经批准的第三方,前提是允许在 Clean Room 中 激活。
了解详情
默认情况下,只有使用者可以在 Clean Room 中运行模板。但是,提供商可以 征得使用者的许可,以便在 Clean Room 中运行模板。
模板和 Clean Room 配置定义了可以对查询结果执行的操作。如果将查询结果导出到 Clean Room 外,则称为 激活。结果可以激活到提供商或使用者的 Snowflake 账户,也可以激活给 Snowflake 批准的第三方。
Clean Room 变体¶
如上所述,最常见的 Clean Room 是这样的,提供商导入数据并指定一个或多个可以针对数据运行的特定查询以及如何共享结果,使用者导入自己的数据并对组合数据运行允许的查询。但是,提供商可以允许标准 Clean Room 的多种变体:
允许提供商对使用者数据运行自己的查询。。默认情况下,只有使用者可以在 Clean Room 中运行查询。如果启用了 Clean Room,则提供商可以请求使用者允许在 Clean Room 中运行特定的查询。
允许将查询结果导出 (激活) 到运行查询的人员的 Snowflake 账户或 Snowflake 批准的第三方账户,例如 Meta Ads Manager 或 The Trade Desk。将数据导出到 Clean Room 外始终需要获得共享所查询数据的所有各方的批准。
允许任何一方 包含可由他们运行的查询调用的自定义 Python 代码。该代码通常在运行查询时以某种方式筛选或操作数据;它不能采取外部操作,例如保存文件、导出数据或执行其他操作。
允许查询 访问其他 Clean Room 中的数据,但需获得所有正在访问的 Clean Room 的提供商的批准。
关于提供商和使用者¶
Clean room collaborators are classified as either a provider or a consumer for a given clean room. A provider is the account that creates a clean room; a consumer is an account that is shared a clean room. You cannot invite someone in the same account where you created a clean room to act as a consumer for that clean room. All users in the same Snowflake account have the same clean room role (provider or consumer) for the same clean rooms in that account.
The provider and consumer roles apply at the Snowflake account level, not the individual user level. That is, if
you create clean room cleanroom1 using Snowflake account ABC, then share cleanroom1 with account XYZ, all ABC users with access
to cleanroom1 are providers, and all XYZ users with access to cleanroom1 are consumers.
您是提供商还是使用者,完全取决于您是否创建或共享了 Clean Room,而不是由任何 Snowflake 角色或其他权限决定。
以下是有关提供商和使用者角色的更多信息。
小技巧
有时,协作者 一词是指使用者或任何有权访问给定 Clean Room 的人。
提供商¶
提供商 被定义为创建 Clean Room 的账户。任何通过该账户访问 Clean Room 的人都被视为该 Clean Room 的提供商。
提供商执行以下 Clean Room 操作:
创建、共享和删除 Clean Room
指定谁可以作为使用者使用 Clean Room(邀请使用者)
将数据导入 Clean Room
定义哪些模板可以在 Clean Room 中运行
指定使用者是否可以在 Clean Room 中运行自定义模板
邀请使用者共享 Clean Room
指定 Clean Room 中使用哪些模板,并为 Clean Room 创建自定义模板
如果使用者同意,则对使用者数据进行查询
允许链接模板
将 Python 脚本加载到 Clean Room 中以在模板中使用
允许在使用者查询中使用来自其他指定 Clean Room 的数据来查询来自该 Clean Room 的提供商数据
为 Clean Room 或使用者启用或禁用差分隐私
管理 Clean Room 的版本控制
根据自己的数据设置列和联接策略
使用者¶
使用者 被定义为由提供商向其发出联接(安装)Clean Room 邀请的账户。
使用者执行以下 Clean Room 操作(根据 Clean Room 配置):
为他们的账户联接(安装)Clean Room
将数据导入 Clean Room
运行 Clean Room 支持的所有查询
导出 Clean Room 启用的查询结果
请求在 Clean Room 中使用自己的模板的权限
指定提供商是否可以在 Clean Room 中运行模板(默认情况下,只有使用者才能运行模板)
允许 Clean Room 提供商对使用者的数据运行查询
如果所有受影响 Clean Room 的提供商都同意,则运行涵盖来自多个 Clean Room 的数据和提供商数据的查询。
将 Python 脚本加载到 Clean Room 中(获得提供商的许可)
根据自己的数据设置列和联接策略
为提供商运行的查询设置差分隐私设置
Ways to access Snowflake Data Clean Rooms¶
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. Currently the clean rooms UI and API are not exactly equivalent in capabilities. Here is a summary of the differences:
仅限 UI 的功能 |
仅限 API 的功能 |
|---|---|
|
|
Note that you can create a clean room using the clean rooms UI and then use or manage it in the API, and vice versa.
Clean Room UI¶
可以在浏览器中管理和运行 Snowflake Data Clean Room。您可以使用 Clean Room UI,以提供商或使用者的身份创建、管理和使用 Clean Room,或者配置各种账户级别的功能,例如托管账户、第三方连接器和 UI 用户功能。
The clean rooms UI is accessed at a separate URL from Snowsight. You can find the login URL here.
Permissions and access: You must be granted access to use the clean room UI by a clean room administrator. The clean rooms UI uses your Snowflake credentials.
Try out the clean rooms UI tutorial or read more about the clean rooms UI.
API¶
Snowflake provides a number of stored procedures to create, manage, and run clean rooms. These procedures can be called through Snowsight notebooks or worksheets or any interface where you can run stored procedures in your Snowflake account. The API does not enable clean room account administration; to administer a clean room account you must use the clean rooms UI.
Permissions and access: In order to use the API you must be granted access to use the SAMOOHA_APP_ROLE by the a clean rooms administrator for your Snowflake account.
您的 Snowflake 账户中是否安装了 Clean Room 环境?¶
以下是判断您的账户中是否安装了 Clean Room UI 或 API 的方法:
To see whether Snowflake Data Clean Rooms is installed:
Sign in to Snowsight.
In the navigation menu, select Catalog » Apps » Installed Apps.
Look to see whether Snowflake Data Clean Rooms appears in your Installed Apps list.
Run
SHOW ROLES LIKE 'SAMOOHA_APP_ROLE';to see if the API is installed in your account. If the role appears, the clean rooms environment is probably installed.运行
SELECT IS_ROLE_IN_SESSION('SAMOOHA_APP_ROLE');以查看您是否有权访问 API。Run
SHOW GRANTS ON ROLE SAMOOHA_APP_ROLE;to see what roles can grant SAMOOHA_APP_ROLE, which is required to use the API.