Snowflake Data Clean Room:使用者 API 参考指南¶
This page describes procedures used by clean rooms API consumers to manage their clean rooms. For coding setup instructions, see 编码设置.
管理角色访问权限¶
grant_run_on_cleanrooms_to_role¶
- 架构:
CONSUMER
描述: 授予指定角色在指定 Clean Room 上运行过程子集的权限。Clean Room 必须 安装 在此账户中,而非由此账户 创建。(也就是说,仅限于您是使用者的 Clean Room。)
To grant limited use to your clean rooms, grant users the specified role rather than SAMOOHA_APP_ROLE. For more information about role access, see 授予有限的 API 访问权限.
以下过程可使用此处指定的角色运行:
consumer.view_added_templates
consumer.view_added_template_chains
consumer.get_arguments_from_template
consumer.view_column_policy
consumer.view_consumer_datasets
consumer.view_join_policy
consumer.view_provider_column_policy
consumer.view_provider_datasets
consumer.view_provider_join_policy
consumer.view_remaining_privacy_budget
consumer.run_analysis
consumer.view_provider_activation_policy
consumer.view_activation_policy
consumer.run_activation
实参:
cleanroom_names (Array of strings) - Names of all the clean rooms on which to grant limited access to the specified role.
run_role_name
- (String) Name of a role that has limited permissions on the specified clean rooms. You must create the role before calling this procedure.
返回: (字符串) - 成功消息。
示例:
CREATE ROLE MARKETING_ANALYST_ROLE;
CALL samooha_by_snowflake_local_db.consumer.grant_run_on_cleanrooms_to_role(
['overlap_cleanroom', 'market_share_cleanroom'],
'MARKETING_ANALYST_ROLE'
);
revoke_run_on_cleanrooms_from_role¶
- 架构:
CONSUMER
描述: 撤销指定角色在指定 Clean Room 上的权限。如果用户有权访问未撤销的角色,或者拥有 SAMOOHA_APP_ROLE,则他们仍然可以在指定 Clean Room 中运行 Clean Room 过程。
实参:
cleanroom_names (Array of strings) - Names of one or more clean rooms in this account.
run_role_name
- (String) Name of role that should no longer have limited permissions on the specified clean rooms in this account.
返回: (字符串) - 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.revoke_run_on_cleanrooms_from_role(
['overlap_cleanroom', 'market_share_cleanroom'],
'TEMP_USERS_ROLE'
);
安装 Clean Room¶
Clean Room 的安装或卸载过程。
install_cleanroom¶
- 架构:
CONSUMER
描述: 安装(联接)指定提供商创建的 Clean Room。多次调用此命令时,每次都会清理现有的 Clean Room;如果您在第二次安装完成前中断安装,则 Clean Room 将损坏,您需要完成此过程 Clean Room 才可用。
实参:
cleanroom_name (String) - Name of the clean room to install.
provider_account_locator
- (String) Account locator of the provider who created this clean room.
返回: (字符串) 成功消息。
错误处理:
If you get an error saying that "Cross-Cloud Auto-Fulfillment is not enabled for this account", it means that the provider is in another cloud hosting region. You must enable Cross-Cloud Auto-Fulfillment as described in 在 Snowflake Data Clean Rooms 中管理 Cross-Cloud Auto-Fulfillment.
示例:
CALL samooha_by_snowflake_local_db.consumer.install_cleanroom(
$cleanroom_name,
$provider_locator);
is_enabled¶
- 架构:
CONSUMER
描述: Clean Room 安装后可能会有短暂的延迟,然后才能投入使用。您可以调用此过程来确认 Clean Room 在安装后是否可以使用。
实参:
cleanroom_name (String) - Name of clean room to check the status of.
返回: (布尔值) 指定的 Clean Room 是否已安装并可供使用。
示例:
CALL samooha_by_snowflake_local_db.consumer.is_enabled($cleanroom_name);
uninstall_cleanroom¶
- 架构:
CONSUMER
Description: Uninstalls the clean room on the consumer account. This removes all databases associated with the clean room, including
the shared clean room database. The clean room can always be installed again by calling consumer.install_cleanroom
.
实参:
cleanroom_name (String) - Name of clean room to uninstall.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.uninstall_cleanroom($cleanroom_name);
跨云协作¶
Install a clean room created on another cloud region. Learn more.
enable_laf_on_account¶
- 架构:
LIBRARY
描述: 在当前账户上启用 Cross-Cloud Auto-Fulfillment。需要 ACCOUNTADMIN 角色。
重要
You must first enable Cross-Cloud Auto-Fulfillment for your account by calling SYSTEM$ENABLE_GLOBAL_DATA_SHARING_FOR_ACCOUNT.
Learn more about auto-fulfillment and managing auto-fulfillment privileges.
实参: 无
返回: (字符串) 成功消息。
示例:
USE ROLE ACCOUNTADMIN;
CALL samooha_by_snowflake_local_db.library.enable_laf_on_account();
disable_laf_on_account¶
- 架构:
LIBRARY
描述: 在当前账户上禁用 Cross-Cloud Auto-Fulfillment。需要 ACCOUNTADMIN 角色。
重要
You must call SYSTEM$ENABLE_GLOBAL_DATA_SHARING_FOR_ACCOUNT before calling this procedure.
Learn more about auto-fulfillment and managing auto-fulfillment privileges.
实参: 无
返回: (字符串) 成功消息。
示例:
USE ROLE ACCOUNTADMIN;
CALL samooha_by_snowflake_local_db.library.disable_laf_on_account();
is_laf_enabled_for_cleanroom¶
- 架构:
CONSUMER
Description: Describes whether or not cross-cloud auto-fulfillment has been enabled for this clean room. Cross-cloud auto-fulfillment must be configured by an account administrator.
实参:
cleanroom_name (String) - Name of the clean room.
返回: 该 Clean Room 是否启用了 Cross-Cloud Auto-Fulfillment。
示例:
CALL samooha_by_snowflake_local_db.consumer.is_laf_enabled_for_cleanroom($cleanroom_name);
request_laf_cleanroom¶
- 架构:
CONSUMER
Description: Sets up prerequisites for installing a clean room created on another cloud region. Calling consumer.install_cleanroom
before calling this procedure fails. This procedure returns the current status each time you call. Call periodically until
the status is FULFILLED, then call consumer.install_cleanroom
. It can take up to 10 minutes until the status is FULFILLED.
实参:
cleanroom_name (String) - The name of the cross-region clean room that will be installed.
provider_locator
- (String) Account locator of the provider that created this clean room.
返回: (字符串) 请求的状态消息。继续调用,直至状态变为 FULFILLED。
示例:
CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.consumer.request_laf_cleanroom(
$cleanroom_name,$provider_locator);
Provider-run analysis¶
For more information about provider-run analysis, see Provider-run analysis.
is_provider_run_enabled¶
- 架构:
LIBRARY
Description: Checks if this clean room allows provider-run analyses. The consumer must still grant explicit permission by
calling consumer.enable_templates_for_provider_run
before providers can run an analysis in this clean room.
实参:
cleanroom_name (String) - Clean room name.
返回: (字符串) 描述 Clean Room 是否支持提供商运行分析。
示例:
CALL samooha_by_snowflake_local_db.library.is_provider_run_enabled($cleanroom_name)
approve_template¶
- 架构:
CONSUMER
描述: 批准给定 Clean Room 中提供商运行分析的单一模板。Clean Room 提供商通常会事先与您沟通,请求允许在 Clean Room 中运行特定模板。在批准模板进行提供商运行分析之前,请务必在模板上设置联接和列策略:
如果 Clean Room 没有 使用者联接策略,则提供商可以联接所有使用者列。
如果 Clean Room 没有 使用者列策略,则提供商可以投影所有使用者列。
如果 Clean Room 带有 不包括此已批准模板 的使用者列策略,则提供商在使用此模板时无法投影任何使用者列。
实参:
cleanroom_name (String) - Name of the clean room with the template to approve.
template_name
- (String) Name of the template that the provider can run, in the specified clean room.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.approve_template(
$cleanroom_name,
$template_name);
set_provider_run_configuration¶
- 架构:
CONSUMER
Description: Applies settings to a template that control how a provider can run a specified template in the clean room. If the consumer
does not provide a configuration for a template, then default values are applied. A provider cannot run a template until a consumer approves
the template for provider-run analyses by calling consumer.approve_template
.
实参:
cleanroom_name (String) - Name of the clean room. If the template is not present in this clean room, the procedure throws an error. The template doesn't need to be approved for provider-run analysis yet, but the provider won't be able to run the template until the consumer approves it.
template_configuration
- (Object) An object that provides limits on how a provider can run a specific template in this clean room. Provider-run analyses are run in the consumer's account, and billed to the consumer, so the consumer can set limitations on what warehouses can be used for a given template.The configuration object has this form:{ <template_name>: { "warehouse_type": <warehouse_type>, "warehouse_size": <warehouse_size> } }
您必须提供以下所有值:
template_name
- The object key is the template name. The configuration is applied to this template. This template must be present in the clean room.warehouse_type
(String) - Which warehouse type the provider can use to run this template. Allowed values:ALL - (Default) Allow any warehouse type.
STANDARD - 仅允许标准仓库。
SNOWPARK-OPTIMIZED - Allow only a Snowpark-optimized warehouse. XLARGE or X-LARGE) is supported.
ALL - (Default) Any warehouse size allowed.
Any size defined for WAREHOUSE_SIZE, or their synonyms (for example, either XLARGE or X-LARGE) is supported.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.set_provider_run_configuration(
$cleanroom_name,
{
"some_template": {
"warehouse_type": "STANDARD",
"warehouse_size": ["MEDIUM", "LARGE"]
}
}
);
enable_templates_for_provider_run¶
- 架构:
CONSUMER
Description: Grants permission to the provider to run an analysis in the requested clean room. This is called after the provider calls
provider.enable_provider_run_analysis
to enable provider-run analysis on a clean room. consumer.enable_templates_for_provider_run
grants
the provider permission to run the specified templates in the specified clean room as many times as they want.
Providers run enabled templates in the consumer's account, and it is billed to the consumer. If you want to limit the warehouse type or
sizes allowed to a provider when running a given template, call set_provider_run_configuration
,
实参:
cleanroom_name (String) - The name of the clean room where the provider can run analyses.
template_names
- (Array of strings) An array of names of one or more templates in the clean room that the provider can run.enable_differential_privacy
- (Boolean) If TRUE, enable differential privacy for all templates listed intemplate_names
. Differential privacy can be enabled for these templates only if differential privacy is enabled for the clean room itself. You can check differential privacy status for a clean room by callingconsumer.is_dp_enabled
. You can customize the privacy settings by callingconsumer.set_privacy_settings
. Learn more.template_configuration
- (Object, optional) An optional object to specify additional settings for each template intemplate_names
. This object contains key-value pairs, where the key is the template name (fromtemplate_names
) and the value is an object that sets limitations on how the provider can use this template. If you do not provide a template configuration, 'ALL' is the default for all properties for all templates intemplate_names
. If you do provide a template configuration, you must provide a configuration for every template listed intemplate_names
, and define all properties for that template's configuration. You can also set the permissible values for a template by callingconsumer.set_provider_run_configuration
.The following properties are supported:
warehouse_type
(String) - A permitted warehouse type that the provider can use with this template. Allowed values:ALL - 允许任何仓库类型。
STANDARD - 仅允许标准仓库。
SNOWPARK-OPTIMIZED - 仅允许 Snowpark 优化型仓库。
warehouse_size
(Array of strings) - One or more permitted warehouse sizes that can be used with this warehouse type and template. Allowed values are those defined for WAREHOUSE_SIZE or their synonyms (for example, either XLARGE or X-LARGE). Specify 'ALL' to allow any warehouse size.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.enable_templates_for_provider_run(
$cleanroom_name,
['prod_overlap_analysis'],
FALSE);
多提供商分析¶
These procedures enable multi-provider analysis.
备注
The current multi-provider flow will be deprecated soon. Clean rooms is working on a new multi-provider flow to replace the current multi-provider procedures.
prepare_multiprovider_flow¶
- 架构:
CONSUMER
Description: Sends a request to run a multi-provider query to the providers of the specified clean rooms. This procedure doesn't
actually run the request; it simply asks the provider for permission to run this request in the future by calling consumer.execute_multiprovider_flow
.
If a provider grants approval, the consumer can then run the query by calling consumer.execute_multiprovider_flow
as often as they want
(depending on any configured differential privacy settings). To re-run a previously approved query after calling
prepare_multiprovider_flow
with new values, the consumer must call prepare_multiprovider_flow
with the exact previous query, but they
don't need to wait for provider approval before running consumer.execute_multiprovider_flow
.
该请求的有效期为四小时;之后,该请求将从队列中删除。
实参:
cleanroom_names (Array of strings) - Array of clean room names in the consumer's account. These clean rooms must be installed.
template_name
- (String) Name of the template to run in each of the clean rooms listed incleanroom_names
. This can be a Snowflake-provided template that is added by the clean room provider, or a custom template that you previously submitted to the clean room by callingconsumer.create_template_request
. In either case, the template must already be present in a clean room for the request to be submitted to the clean room provider.arguments
- (Object) An object with the following fields, used to populate the template:source_table
(String array) - An array of table names that are used to populate thesource_table
array available to the template. The syntax for each table name iscleanroom_name.db.schema.table
. Each provider sees only their own clean room tables listed in the request.my_table
(String array) - An array of table names of your own data that are used to populate themy_table
array available to the template. Use the same syntax passed to theconsumer_tables
argument ofconsumer.run_analysis
.任何其他模板变量 – 将模板的任何必填值作为键/值对传递。
Returns: (String) Request ID to pass in to consumer.execute_multiprovider_flow
.
示例:
CALL samooha_by_snowflake_local_db.consumer.prepare_multiprovider_flow(
[$cleanroom_name_1, $cleanroom_name_2],
'prod_aggregate_data',
object_construct(
'source_table', [
CONCAT($cleanroom_name_1, '.SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS'),
CONCAT($cleanroom_name_2, '.SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS')
],
'my_table', ['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS']),
'hem_col', ['p1.HASHED_EMAIL', 'p2.HASHED_EMAIL'],
'dimensions', ['p1.STATUS', 'p2.STATUS'],
'consumer_join_col', 'HASHED_EMAIL'
)
);
execute_multiprovider_flow¶
- 架构:
CONSUMER
Description: Runs the most recent query submitted by the consumer to consumer.prepare_multiprovider_flow
. The procedure runs the
query in each specified clean room where the query was approved by the provider and returns the union of all query results. Running this procedure is the only way to tell whether a provider has approved a query.
实参:
cleanroom_names (Array of strings) - Array of clean room names where the prepared query should be run. This array must match the full list of clean rooms in the query request.
request_id
- (String, optional) Request ID returned byprepare_multiprovider_flow
.
返回: (表) 所有批准的 Clean Room 结果汇总。如果提供商从未批准过来自该使用者的查询,则查询将失败。但是,如果提供商批准了此使用者的不同查询,但未批准最新的查询,则该过程将返回一个空的结果集。
示例:
CALL samooha_by_snowflake_local_db.consumer.execute_multiprovider_flow(
[$cleanroom1, $cleanroom2],
$request_id);
注册和取消注册数据¶
Use the following procedures to register and unregister databases, schemas, and objects. Tables and views must be registered before they can be linked into the clean room. If you register a database or schema, all of the objects in that database or schema are registered. For more information about registering data, see 注册数据.
register_db¶
- 架构:
CONSUMER
Description: Register a database in an account to be able to link any objects from that database into a clean room in that account.
For more fine-grained control you can call register_schema
, register_managed_access_schema
, or register_object
instead. Objects added
to the database after it has been registered might not be linkable, in which case you should re-register the database (or register the
object itself).
您必须具有数据库的 MANAGE GRANTS 权限才能运行此过程。
实参:
db_name
- (String) Name of database to register in this account.
返回: (字符串) 成功消息。
示例:
USE ROLE <ROLE_WITH_MANAGE_GRANTS>;
CALL samooha_by_snowflake_local_db.consumer.register_db('SAMOOHA_SAMPLE_DATABASE');
register_schema¶
- 架构:
LIBRARY
Description: Register a schema in an account to be able to link any objects from that schema into a clean room in that account.
For more fine-grained control you can call register_object
instead. Objects added to the schema after it has been registered might not be linkable, in which case you should re-register the schema (or register the object itself).
If you want to register a managed access schema (that is, a schema created with the WITH MANAGED ACCESS parameter), use library.register_managed_access_schema
instead.
实参:
schema_names
- (Array of strings) Array of fully qualified schemas to register.
返回: (字符串) 成功消息。
示例:
USE ROLE <ROLE_WITH_MANAGE_GRANTS>;
CALL samooha_by_snowflake_local_db.library.register_schema(
['SAMOOHA_SAMPLE_DATABASE.DEMO']
);
register_managed_access_schema¶
- 架构:
LIBRARY
Description: Register a managed access schema in an account to be able to link any objects from that schema into a clean room in that
account. For more fine-grained control you can call register_object
instead. Objects added to the schema after it has been registered
might not be linkable, in which case you should re-register the schema (or register the object itself).
实参:
schema_names
- (Array of strings) Array of fully qualified managed schemas to register.
返回: (字符串) 成功消息。
示例:
USE ROLE <ROLE_WITH_MANAGE_GRANTS>;
CALL samooha_by_snowflake_local_db.library.register_managed_access_schema(
['SAMOOHA_SAMPLE_DATABASE.DEMO']
);
register_objects¶
- 架构:
LIBRARY
Description: Grants the clean room access to tables and views of all types, making them available to be linked into the clean room by
calling consumer.link_datasets
. You can register broader groups of objects by calling library.register_schema
,
library.register_managed_access_schema
, or consumer.register_db
. You must have MANAGE GRANTS privileges on the database to run this procedure.
实参:
object_names
- (Array) Array of fully qualified object names. These objects can then be linked into the clean room.
返回: (字符串) 成功消息。
示例
要注册表和视图:
USE ROLE <ROLE_WITH_MANAGE_GRANTS>;
CALL samooha_by_snowflake_local_db.library.register_objects(
[
'SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS',
'SAMOOHA_SAMPLE_DATABASE.INFORMATION_SCHEMA.FIELDS'
]
);
enable_external_tables_on_account¶
- 架构:
LIBRARY
Description: Enable Iceberg or external tables to be used in all clean rooms in this account. Must be called by an ACCOUNTADMIN in
both the provider and consumer accounts to allow Iceberg or external tables to be linked by either account. To
limit this ability to specific clean rooms in this account, call enable_external_tables_for_cleanroom
instead.
实参: 无
返回: (字符串) 成功消息。
示例:
USE ROLE ACCOUNTADMIN;
CALL samooha_by_snowflake_local_db.library.enable_external_tables_on_account();
enable_external_tables_for_cleanroom¶
- 架构:
CONSUMER
Description: Enable Iceberg or external tables to be linked into in the specified clean room in this account by the consumer. To allow
Iceberg and external tables for all clean rooms in this account, call enable_external_tables_on_account
instead.
实参:
cleanroom_name (String) - The name of the clean room into which the provider can link Iceberg tables or external tables.
返回: (字符串) 成功消息。如果成功,它将触发安全扫描,并提供安全扫描成功后生成的补丁编号。
示例:
CALL samooha_by_snowflake_local_db.provider.enable_external_tables_for_cleanroom(
$cleanroom_name);
unregister_db¶
- 架构:
LIBRARY
Description: Removes the database-level grants given to the SAMOOHA_APP_ROLE role and Snowflake Data Clean Room native application. Any data in this database that is linked into a clean room will no longer be accessible in this account. You must have MANAGE GRANTS privileges on the database to run this procedure.
实参:
db_name
- (String) Name of the database to unregister.
返回: (字符串) 成功消息。
示例:
USE ROLE <ROLE_WITH_MANAGE_GRANTS>;
CALL samooha_by_snowflake_local_db.library.unregister_db('SAMOOHA_SAMPLE_DATABASE');
unregister_schema¶
- 架构:
LIBRARY
描述:取消注册一个或多个架构,防止用户将其表和视图链接到 Clean Room。
If you want to unregister a managed access schema (that is, a schema created with the WITH MANAGED ACCESS parameter), use library.unregister_managed_access_schema
instead. You must have MANAGE GRANTS privileges on the database to run this procedure.
实参:
schema_names
- (Array of strings) Fully qualified names of schemas to unregister.
返回: (字符串) 成功消息。
示例:
USE ROLE <ROLE_WITH_MANAGE_GRANTS>;
CALL samooha_by_snowflake_local_db.library.unregister_schema(
['SAMOOHA_SAMPLE_DATABASE.PUBLIC', 'MY_DB.MY_SCH']
);
unregister_managed_access_schema¶
- 架构:
LIBRARY
描述:取消注册一个托管访问架构,以防止用户将其表和视图链接到 Clean Room。
实参:
schema_names
- (Array of strings) Fully qualified names of schemas to unregister.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.unregister_managed_access_schema(
['SAMOOHA_SAMPLE_DATABASE.DEMO']
);
unregister_objects¶
- 架构:
LIBRARY
描述: 撤销 Clean Room 对所有类型的表和视图的访问权限。此账户管理的所有 Clean Room 中的任何用户将无法再使用这些对象。
实参:
object_names
- (Array) Array of fully qualified object names to revoke access to.
返回: (字符串) 成功消息。
示例
要取消注册表和视图:
USE ROLE <ROLE_WITH_MANAGE_GRANTS>;
CALL samooha_by_snowflake_local_db.library.unregister_objects(
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS','MY_DB.MY_SCH.MY_VIEW']
);
链接和取消链接数据集¶
注册数据集后,您可以将该数据集的表或视图链接到特定的 Clean Room。您还可以从特定 Clean Room 取消链接表或视图,以从 Clean Room 删除对该数据的访问权限。
link_datasets¶
- 架构:
CONSUMER
描述: 将表或视图链接到 Clean Room,根据您指定的任何联接和列策略,使该 Clean Room 内的模板可以访问该表。
实参:
cleanroom_name (String) - Name of the clean room to link data into.
full_tables
- (Array of strings) List of fully qualified table or view names to expose to the clean room. These objects must first be registered (made available to the clean room environment) with the appropriate registration method.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.link_datasets(
$cleanroom_name,
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS', 'MY_DB.MY_SCH.EXPOSURES']
);
unlink_datasets¶
- 架构:
CONSUMER
描述: 移除所有用户对指定 Clean Room 中指定表或视图的访问权限。这仅适用于您已链接到 Clean Room 的数据。
实参:
cleanroom_name (String) - Name of the clean room for which access should be removed.
tables_list
- (Array of strings) List of fully qualified table or view names for which access should be blocked.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.unlink_datasets(
$cleanroom_name,
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS', 'MYDB.MYSCH.EXPOSURES']);
view_consumer_datasets¶
- 架构:
CONSUMER
描述: 查看任何使用者链接到指定 Clean Room 的所有表和视图。
实参:
cleanroom_name (String) - Name of the clean room.
返回: 链接到指定 Clean Room 的对象表,以及每个对象的 Clean Room 内部视图名称。
示例:
CALL samooha_by_snowflake_local_db.consumer.view_consumer_datasets($cleanroom_name);
管理和查看策略¶
Manage policies on your data in a clean room that you have installed.
set_join_policy¶
- 架构:
CONSUMER
描述: 指定在使用提供商运行分析时,允许提供商在 Clean Room 内运行模板时对哪些列执行联接。列策略是 仅替换,因此如果再次调用该函数,先前设置的列策略将被当前策略完全替换。如果您没有为数据指定联接策略,则所有列均可联接。
带通配符的查询可能会规避联接政策,因此在设计分析模板时要谨慎行事。
实参:
cleanroom_name (String) - Name of the clean room where the join policy is applied.
table_col_names
- (String array) Fully qualified names of columns that can be joined, in the formatdatabase name.schema name:column name
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.set_join_policy(
$cleanroom_name,
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS:HASHED_EMAIL', 'MYDB.MYSCH.EXPOSURES:HASHED_EMAIL']
);
view_join_policy¶
- 架构:
CONSUMER
描述: 概述用户可以在 clean room 内安全地联接哪些列,由使用者在使用者数据集上设置。
实参:
cleanroom_name (String)
返回: 联接策略(表)
示例:
CALL samooha_by_snowflake_local_db.consumer.view_join_policy($cleanroom_name);
view_provider_join_policy¶
- 架构:
CONSUMER
描述:概述用户可以在 Clean Room 内安全地联接哪些列,由提供商在提供商数据集上设置。
实参:
cleanroom_name (String)
Returns: (Table) The join policy.
示例:
CALL samooha_by_snowflake_local_db.consumer.view_provider_join_policy($cleanroom_name);
set_column_policy¶
- 架构:
CONSUMER
描述: 定义哪些列可以投影使用者数据。列策略适用于 Clean Room 中的模板。列策略是 仅替换,因此如果再次调用该函数,先前设置的列策略将被当前策略完全替换。如果您没有指定列策略,则所有列均可投影。
不要对身份列或电子邮件等敏感列设置列政策,因为您通常不希望投影此类数据。
使用这些检查可能无法找出含有通配符的查询,因此,设计分析模板时应慎重。
实参:
cleanroom_name (String) - Name of the clean room where the column policy is applied.
analysis_table_cols
- (String array) Fully qualified names of columns that can be projected, in the formatdatabase name.schema name:column name
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.set_column_policy(
$cleanroom_name,
['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'
]
);
view_column_policy¶
- 架构:
CONSUMER
Description: Show all consumer column policies in the specified clean room. To see any column policies set by the provider, call
consumer.view_provider_column_policy
.
实参:
cleanroom_name (String) - Name of the clean room to describe.
返回: (表) 有关 Clean Room 中所有使用者列策略的信息。
示例:
CALL samooha_by_snowflake_local_db.consumer.view_column_policy($cleanroom_name);
view_provider_column_policy¶
- 架构:
CONSUMER
描述: 查看提供商已应用于 Clean Room 的所有列策略。
实参:
cleanroom_name (String)
返回: 列策略(表)
示例:
CALL samooha_by_snowflake_local_db.consumer.view_provider_column_policy($cleanroom_name);
模板¶
通过以下过程,用户可以使用 Clean Room 中的模板。
view_template_definition¶
- 架构:
CONSUMER
Description: View the raw JinjaSQL of the specified template. If a template was obscured by applying the is_obfuscated
argument, you can't see the template source code.
实参:
cleanroom_name (String) - Name of the clean room that holds the template.
template_name
- (String) Name of the template to view.
返回: (字符串) 模板定义。
示例:
CALL samooha_by_snowflake_local_db.consumer.view_template_definition(
$cleanroom_name,
'prod_overlap_analysis');
get_arguments_from_template¶
- 架构:
CONSUMER
Description: Get a list of arguments used by the template. You can pass values for these argument into the template when you call
consumer.run_analysis
.
实参:
cleanroom_name (String) - Name of the clean room that has the template.
template_name
- (String) Name of the template to return arguments for.
返回: (表) 实参列表和规范。
示例:
CALL samooha_by_snowflake_local_db.consumer.get_arguments_from_template(
$cleanroom_name,
'prod_overlap_analysis');
模板链¶
The following procedures allow users to work with template chains in the clean room.
view_added_template_chains¶
- 架构:
CONSUMER
描述:列出指定 Clean Room 中定义的所有模板链。
实参:
cleanroom_name (String) - Name of the clean room to list template chains for.
返回: (表) 有关指定 Clean Room 中所有模板链的信息。
示例:
CALL samooha_by_snowflake_local_db.consumer.view_added_template_chains(
$cleanroom_name);
view_template_chain_definition¶
- 架构:
CONSUMER
描述:返回指定模板链的属性。
实参:
cleanroom_name (String) - Name of the clean room with the template chain to describe.
template_chain_name
- (String) Name of the template chain to describe.
返回: (字符串) 指定模板链的定义。
示例:
CALL samooha_by_snowflake_local_db.consumer.view_template_chain_definition(
$cleanroom_name,
'insights_chain');
运行分析¶
以下过程根据指定的模板运行分析或激活。
run_analysis¶
- 架构:
CONSUMER
描述:使用模板或模板链运行分析并返回结果表。
重要
If differential privacy is enabled, the query can fail if you have reached your budget limit for this template.
If a template was obscured by applying the
is_obfuscated
argument, you must use Snowflake Enterprise Edition or higher to be able to run the template.
实参:
cleanroom_name (String) - Name of the clean room in which to run the analysis.
template_name
- (String) Name of the template or template chain to run in the clean room. This template must have been added to the clean room by the provider or consumer.consumer_tables
- (Array of strings) Array of fully qualified consumer table names. These are assigned to themy_table
template variable. These tables must already be linked into the clean room. See available tables by callingconsumer.view_consumer_datasets
.provider_tables
- (Array of strings) Array of fully qualified provider table names. These are assigned to thesource_table
template variable. These tables must have been linked into the clean room. See available tables by callingconsumer.view_provider_datasets
.analysis_arguments
- (Object) An object with key-value pairs passed to the template. The template can access the variable by key name. If you pass in{'age': 20}
, the template accesses the value as{{age}}
. Pass in an empty object if no values are required. To see which values are required, examine the template in question by callingconsumer.view_template_definition
. Examine the template to determine whether you need to fully qualify any column names used. If the table is aliased asp
orc
in the template, use lowercasep
andc
table aliases for column names.此对象有一个可选的保留值:
epsilon
(Float, optional) - Specifies the epsilon value for differential privacy (link removed), if differential privacy is enabled for this clean room. Default is 0.1.
use_cache
- (Boolean, optional) Whether or not to use cached results for the same query. Default is FALSE.
返回: (表) 查询结果。
示例:
CALL samooha_by_snowflake_local_db.consumer.run_analysis(
$cleanroom_name,
'prod_overlap_analysis',
['DB1.MYDATA.CONVERSIONS'], -- Consumer tables
['MYDB.MYSCH.EXPOSURES'], -- Provider tables
object_construct(
'max_age', 30
)
);
激活¶
The following procedures manage activation, or the saving of results to a consumer's or provider's Snowflake account. You can't activate data to third-party accounts by using the API.
view_external_activation_history¶
- 架构:
LIBRARY
描述: 查看当前账户的激活请求历史记录。
实参: 无
返回: 包含激活请求的详细信息和状态的表。
示例:
CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.LIBRARY.view_external_activation_history();
set_activation_policy¶
- 架构:
CONSUMER
描述: 定义哪些列可以在激活模板中使用。这可以确保只有使用者批准的列可以与激活模板一起使用。如果没有定义激活策略,那么数据的任何列都不能被激活。设置激活策略将覆盖您账户的任何现有激活策略。
实参:
cleanroom_name (String) - Name of the cleanroom in which to set the activation policy.
columns
- (Array) Name of columns of your own data that can be activated, in the formattemplate name:database name.schema name.table name:column_name
.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.set_activation_policy(
$cleanroom_name,
[
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE_NAME.DEMO.CUSTOMERS:HASHED_EMAIL',
'prod_overlap_analysis:SAMOOHA_SAMPLE_DATABASE_NAME.DEMO.CUSTOMERS:REGION_CODE' ]);
approve_provider_activation_consent¶
- 架构:
CONSUMER
描述: 批准提供商的请求以允许提供商激活,即将结果推送到提供商的 Snowflake 账户的能力。
实参:
cleanroom_name (String) - Name of the clean room where the provider is requesting to run a template.
activation_template_name
- (String) Name of the activation template that the provider wants to run.
Returns: (String) Success message. This procedure fails if the provider has not called provider.request_provider_activation_consent
in this clean room with the specified template.
示例:
CALL samooha_by_snowflake_local_db.consumer.approve_provider_activation_consent(
$cleanroom_name,
'activation_my_template');
run_activation¶
- 架构:
CONSUMER
Description: Runs a template that pushes results back to the consumer's or provider's Snowflake account. The
consumer_direct_activation
argument determines whether this is a consumer or provider activation.
实参:
cleanroom_name (String) - Name of the clean room in which to run the activation.
segment_name
- (String) Arbitrary string used to label rows that are generated by this activation run. Each activation run adds new rows to an existing results table. Provide a unique string in this field each time you call this procedure to be able to filter results to a specific run.template_name
- (String) Name of the activation template to call.consumer_tables
- (Array of strings) Array of fully qualified consumer table names to pass to the template.provider_tables
- (Array of strings) Array of fully qualified provider table names to pass to the template.activation_arguments
- (Object) Key-value set of arguments to pass to the template.consumer_direct_activation
- (Boolean, optional) TRUE to push results back to the consumer account, FALSE to send results to the provider. Default is FALSE.
返回: (字符串) 成功消息。
示例:
-- Run a consumer activation, as specified by the final TRUE argument.
SET segment_name = 'my_activation_segment';
CALL samooha_by_snowflake_local_db.consumer.run_activation(
$cleanroom_name,
$segment_name,
$template_name,
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS'],
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS'],
object_construct(
'c_join_col', 'c.hashed_email',
'p_join_col', 'p.hashed_email'
),
TRUE);
dcr_health.provider_run_provider_activation_history¶
描述: 返回指定 Clean Room 的提供商激活请求历史记录。显示了由提供商和使用者发起的提供商激活请求。此过程提供了额外的信息,以帮助调试提供商激活方面的问题。
实参:
cleanroom_name (String) - Name of the clean room in which the activation was requested. You must be a provider or consumer in this clean room.
返回: (表) – 激活请求列表,其中包含有关每个请求的信息,包括模板和分段名称、状态、使用者账户定位器以及请求返回的任何错误消息。
示例:
CALL samooha_by_snowflake_local_db.dcr_health.provider_run_provider_activation_history(
$cleanroom_name);
使用者自定义模板¶
The following APIs allow you to add consumer-defined templates to a clean room. For more information, see consumer-written templates.
create_template_request¶
- 架构:
CONSUMER
Description: Sends a request to the provider of a clean room, asking them to approve a custom template so it can be added to the clean room. See 使用者编写的自定义模板.
实参:
cleanroom_name (String) - Name of the clean room where the template is added.
template_name
- (String) Name of the template to add. Must be all lowercase letters, numbers, spaces, or underscores. Activation template names must start with "activation".template_definition
- (String) The JinjaSQL template. Learn the template syntax.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.create_template_request(
$cleanroom_name,
$template_name,
$$
SELECT
identifier({{ dimensions[0] | column_policy }})
FROM
identifier({{ my_table[0] }}) c
INNER JOIN
identifier({{ source_table[0] }}) p
ON
c.identifier({{ consumer_id }}) = identifier({{ provider_id | join_policy }})
{% if where_clause %} where {{ where_clause | sqlsafe | join_and_column_policy }} {% endif %};
$$);
get_sql_jinja¶
- 架构:
CONSUMER
Description: Evaluates a JinjaSQL template to a SQL statement. This procedure is used when developing custom templates, to see how the template is rendered after processing with a given set of parameters.
This procedure can process only standard JinjaSQL (https://github.com/sripathikrishnan/jinjasql) statements; it can't process clean room
extensions to JinjaSQL such as join_policy
or column_policy
.
实参:
template_string
- (String) The JinjaSQL code to process. Only standard JinjaSQL is supported.arguments
- (Object) An object where field names correspond to variables that are used in the template.
**返回:**(字符串)* 提交的模板生成的 SQL 语句,其中包含提供的变量值。
示例:
CALL samooha_by_snowflake_local_db.consumer.get_sql_jinja(
$$
SELECT COUNT(*), IDENTIFIER({{ group_by_col }})
FROM IDENTIFIER({{ my_table | sqlsafe }})
INNER JOIN IDENTIFIER({{ source_table | sqlsafe }})
ON IDENTIFIER({{ consumer_join_col }}) = IDENTIFIER({{ provider_join_col }})
GROUP BY IDENTIFIER({{ group_by_col }});
$$,
object_construct(
'group_by_col', 'city',
'consumer_join_col', 'hashed_email',
'provider_join_col', 'hashed_email',
'my_table', 'mydb.mysch.t1',
'source_table', 'mydb.mysch.t2'));
响应:
SELECT COUNT(*), IDENTIFIER('city')
FROM IDENTIFIER(mydb.mysch.t1)
INNER JOIN IDENTIFIER(mydb.mysch.t2)
ON IDENTIFIER('hashed_email') = IDENTIFIER('hashed_email')
GROUP BY IDENTIFIER('city');
generate_python_request_template¶
- 架构:
CONSUMER
Description: Generates a consumer clean room template that includes custom Python code. The generated template includes your Python code
and a placeholder for your JinjaSQL template. Pass your final template to consumer.create_template_request
.
For more information about consumer-defined templates, see 使用者编写的自定义模板.
实参:
function_name
- (String) The function name that is used by a template to call your function.arguments
- (Array of String pairs) An array of arguments required by functionfunction_name
. Each element is a space-delimited pair that gives the argument name and its Snowflake SQL data type. For example:['size INT', 'start_date DATE']
.packages
- (Array of strings) Array of package names required for your Python code. If none, specify an empty array. See the full list of supported packages. (https://repo.anaconda.com/pkgs/snowflake/) Example:['pandas','numpy']
.imports
- Not supported: Do not userettype
- (String) The Snowflake SQL return type of your function. Examples: INTEGER, VARCHAR.handler
- (String) The name of the main handler function in your Python code. Typically this is'main'
.code
- (String) Your Python code implementation. If you include an import and your designated handler is defined in an import, this can be an empty string.
Returns: (String) Returns your Python UDF with a placeholder for your JinjaSQL template. You must escape any nested $$
or
single-quote marks '
correctly before passing your template string into consumer.create_template_request
. Read
使用者提交的代码.
示例:
使用一个简单的 Python 示例调用辅助函数:
CALL SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.CONSUMER.GENERATE_PYTHON_REQUEST_TEMPLATE(
'my_func', -- SQL should use this name to call your function.
['data VARIANT', 'index INTEGER'], -- Arguments and types for the function.
['pandas', 'numpy'], -- Standard libraries used.
[], -- Reserved.
'INTEGER', -- SQL return type.
'main', -- Standard main handler.
$$
import pandas as pd
import numpy as np
def main(data, index):
df = pd.DataFrame(data) # you can do something with df but this is just an example
return np.random.randint(1, 100)
$$
);
The following example shows the generated code. Replace <INSERT SQL TEMPLATE HERE>
with your template JinjaSQL code.
BEGIN
-- First define the Python UDF
CREATE OR REPLACE FUNCTION CLEANROOM.my_func(data VARIANT, index INTEGER)
RETURNS INTEGER
LANGUAGE PYTHON
RUNTIME_VERSION = 3.10
PACKAGES = ('pandas', 'numpy')
HANDLER = 'main'
AS $$
import pandas as pd
import numpy as np
def main(data, index):
df = pd.DataFrame(data) # you can do something with df but this is just an example
return np.random.randint(1, 100)
$$;
-- Then define and run the SQL query
LET SQL_TEXT varchar := $$<INSERT SQL TEMPLATE HERE>$$;
-- Run the query and return the result
LET RES resultset := (EXECUTE IMMEDIATE :SQL_TEXT);
RETURN TABLE(RES);
END;
list_template_requests¶
- 架构:
CONSUMER
描述:显示使用者向 Clean Room 添加模板的所有请求。
实参:
cleanroom_name (String) - The clean room to list template requests for.
返回: 包含以下列的表:
request_id
- ID of the request, generated by the clean rooms system.provider_identifier
- Provider's account locator.template_name
- Template name that the consumer provided in the request.template_definition
- Source code of the template that the consumer asked to add to the clean room.request_status
- Status of the request: PENDING, APPROVED, or REJECTED.reason
- If the request status is REJECTED, the provider should give a reason for the rejection here.
示例:
CALL samooha_by_snowflake_local_db.consumer.list_template_requests($cleanroom_name);
Clean Room 元数据 getter 方法¶
以下方法显示了 clean room 的相关属性:
describe_cleanroom¶
- 架构:
CONSUMER
Description: Provides a summary of key information about the specified clean room, including templates, datasets, and policies.
If a template was obscured by applying the is_obfuscated
argument, you must use Snowflake
Enterprise Edition or higher to be able to see the template name.
实参:
cleanroom_name (String) - Name of the clean room to describe.
返回: (字符串) Clean Room 的描述。
示例:
CALL samooha_by_snowflake_local_db.consumer.describe_cleanroom($cleanroom_name);
view_provider_datasets¶
- 架构:
CONSUMER
描述: 列出提供商添加到 Clean Room 的所有数据集。
实参:
cleanroom_name (String) - Name of the clean room.
返回: (表) 提供商添加的数据集表。在查询中使用此处返回的表名。
示例:
CALL samooha_by_snowflake_local_db.consumer.view_provider_datasets($cleanroom_name);
view_added_templates¶
- 架构:
CONSUMER
Description: Lists all templates in the clean room. If a template was obscured by
applying the is_obfuscated
argument, you must use Snowflake Enterprise Edition or higher to be able to view the template.
实参:
cleanroom_name (String) - Name of the clean room.
返回: 此 Clean Room 中的模板列表以及每个模板的源代码(除非模板被提供商隐藏了)。
示例:
CALL samooha_by_snowflake_local_db.consumer.view_added_templates($cleanroom_name);
is_consumer_run_enabled¶
- 架构:
LIBRARY
描述: 检查是否为指定的 Clean Room 启用了使用者运行的分析。默认情况下处于启用状态,但 Clean Room 提供商可以将其禁用。
实参:
cleanroom_name (String) - Name of the clean room.
返回: (字符串) 此 Clean Room 是否允许使用者运行分析。
示例:
CALL samooha_by_snowflake_local_db.library.is_consumer_run_enabled($cleanroom_name);
view_cleanrooms¶
- 架构:
CONSUMER
Description: Lists all clean rooms that are joined (installed) or that are joinable by this account. To see only installed clean rooms,
run consumer.view_installed_cleanrooms
. To see clean rooms created by this account, call provider.view_cleanrooms
.
实参: 无
返回: (表) 此账户已安装或邀请的所有 Clean Room。
示例:
CALL samooha_by_snowflake_local_db.consumer.view_cleanrooms();
view_installed_cleanrooms¶
- 架构:
CONSUMER
Description: Lists all clean rooms that are installed (joined) in this account. To see both joined and unjoined clean rooms, call
consumer.view_cleanrooms
. To see all clean rooms created by this account, call provider.view_cleanrooms
.
实参: 无
示例:
CALL samooha_by_snowflake_local_db.consumer.view_installed_cleanrooms();
差分隐私¶
These procedures control differential privacy in the clean room. You can also specify differential privacy at the template level when you call consumer.enable_templates_for_provider_run
.
is_dp_enabled¶
- 架构:
CONSUMER
描述: 检查是否已在 Clean Room 中启用了差分隐私。必须安装 Clean Room 才能检查此值。
实参:
cleanroom_name (String)
返回: (布尔) Clean Room 是否已启用差分隐私。
示例:
CALL samooha_by_snowflake_local_db.consumer.is_dp_enabled($cleanroom_name);
view_remaining_privacy_budget¶
- 架构:
CONSUMER
Description: Views the privacy budget remaining that can be used to make queries from the clean room. After the budget is exhausted, further calls to run_analysis
aren't allowed until the budget is reset. The budget resets daily.
实参:
cleanroom_name (String) Name of the clean room. The clean room must be installed for this procedure to succeed.
返回: (浮点) 剩余的隐私预算。
示例:
CALL samooha_by_snowflake_local_db.consumer.view_remaining_privacy_budget($cleanroom_name);
set_privacy_settings¶
- 架构:
CONSUMER
Description: Sets privacy settings for provider-run analyses (including activation) that use custom templates. This procedure overwrites all previously set values. Each time you call this method it erases all previous configuration settings.
实参:
cleanroom_name (String) - Name of the clean room where these settings should be applied.
privacy_settings
- (String) A string JSON object that specifies privacy settings when custom templates are run by a provider. Here is the syntax of the object:'{ "null" : <template_config> }'
template_config
is an object with differential privacy and aggregation settings. See可用的隐私设置 to see what fields you can provide in this object.
示例:
-- Apply differential privacy for provider-run analysis using all custom templates.
CALL samooha_by_snowflake_local_db.consumer.set_privacy_settings(
$cleanroom_name,
PARSE_JSON('{
"null":{ "differential": 1, "epsilon": 0.1, "privacy_budget": 3 }
}')
);
返回: (字符串) 成功消息。
Snowpark Container Service 过程¶
Read more about using Snowpark Container Services in your clean rooms.
start_or_update_service¶
- 架构:
CONSUMER
Description: Creates and starts the latest version of Snowpark Container Services that is defined by the provider in this clean room.
Any time the provider calls provider.load_service_into_cleanroom
to create or update a container, the consumer must call
consumer.start_or_update_service
to update the service.
在调用此过程之前,使用者必须先定义并启动该池。
实参:
cleanroom_name (String) - Name of the clean room where the container should be loaded.
compute_pool_name
- (String) The name of a compute pool that is defined by the consumer in this clean room. The pool must already be created, and the clean room must have privileges to access to the pool.service_options
- (Object, optional) An object specifying parameters for this service. The following properties are supported:query_warehouse
- (String, optional) Name of the warehouse to use for this service. Doesn't need to be the same warehouse as the one running the clean room.min_instances
- (Integer, optional) Minimum number of instances to use for this service.max_instances
- (Integer, optional) Minimum number of instances to use for this service.
**返回:**(表)加载结果(如果成功)。如果不成功,则会引发错误。
示例:
CALL samooha_by_snowflake_local_db.consumer.start_or_update_service(
$cleanroom_name,
'dcr_lal_pool',
object_construct(
'query_warehouse', 'app_wh',
'min_instances', '1',
'max_instances', '1'
));
环境管理¶
使用以下方法来协助通用 Clean Room 功能。
set_cleanroom_ui_accessibility¶
- 架构:
CONSUMER
描述:为当前账户中的使用者显示或隐藏 Clean Room UI 中的 Clean Room。
实参:
cleanroom_name (String) - The name of the clean room.
visibility_status
- (String) One of the following case-sensitive values:HIDDEN – 对当前使用者账户中的所有用户隐藏 Clean Room UI 中的指定 Clean Room。Clean Room 仍可使用 API 调用访问。
EDITABLE – 让 Clean Room 在 Clean Room UI 中可见。
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.set_cleanroom_ui_accessibility(
$cleanroom_name,
'HIDDEN');
manage_datastats_task_on_account¶
- 架构:
CONSUMER
描述: 启用或禁用计算 Clean Room 统计数据的后台任务。该任务默认运行,但您可以将其禁用以降低成本。
重要
To manage this task, all collaborators must call the appropriate provider
or consumer
version of this
procedure with the same value.
实参:
enable
- (Boolean) TRUE to enable the task, FALSE to disable the task.
返回: (字符串) 成功消息。
示例:
-- Disable the task in this account.
CALL samooha_by_snowflake_local_db.consumer.manage_datastats_task_on_account(FALSE);
enable_local_db_auto_upgrades¶
- 架构:
LIBRARY
Description: Enables the task that automatically upgrades the Snowflake Data Clean Rooms environment when new procedures or
functionality is released (The task is samooha_by_snowflake_local_db.admin.expected_version_task
.) Call this procedure to automate
upgrades, rather than calling library.apply_patch
with each new release.
Although you might reduce cost by disabling this task, we recommend that you leave it running to ensure that you have the latest version of the clean rooms environment on your system.
实参: 无
返回: (字符串) 成功或失败消息。
示例:
CALL samooha_by_snowflake_local_db.library.enable_local_db_auto_upgrades();
disable_local_db_auto_upgrades¶
- 架构:
LIBRARY
Description: Disables the task that automatically upgrades the Snowflake
Data Clean Rooms environment when new versions are released. If you disable auto upgrades, you must call
library.apply_patch
with each new release.
实参: 无
返回: (字符串) 成功或失败消息。
示例:
CALL samooha_by_snowflake_local_db.library.disable_local_db_auto_upgrades();
apply_patch¶
- 架构:
LIBRARY
Description: Updates your clean rooms environment, enabling new features and fixes in your environment. Call this when a new version of the clean rooms environment has been released. (This typically occurs weekly; see clean rooms entries in 最近的功能更新.) This procedure updates SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.
You can automate patch updates by calling library.enable_local_db_auto_upgrades
. We recommend enabling auto-updates.
实参: 无
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.apply_patch();
patch_cleanroom¶
- 架构:
CONSUMER
描述: 将指定的 Clean Room 更新到最新版本,从而为该 Clean Room 启用新功能和修复。通常,只有在 Snowflake 支持部门要求您调用此任务时,您才会进行调用。
The provider should call library.patch_cleanroom
before the consumer calls library.patch_cleanroom
; otherwise, there is no patch to
apply.
实参:
cleanroom_name (String) - Name of the clean room to patch.
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.consumer.patch_cleanroom($cleanroom_name);
dcr_health.dcr_tasks_health_check¶
描述: 显示有关正在运行或最近停止的 Clean Room 任务的信息。
实参: 无
返回: (表) 有关 Clean Room 任务的信息,包括计划、仓库名称和仓库规模。
示例:
CALL samooha_by_snowflake_local_db.dcr_health.dcr_tasks_health_check();
已弃用的过程¶
下列过程已弃用,在此处列出仅为保障列表完整性。如果指明了替换过程,请使用较新的过程。
register_table_or_view -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.register_objects.
描述: 注册所有类型的表和视图。
Arguments: object_names (Array), is_view (boolean), is_iceberg (boolean), is_external (boolean), is_under_managed_access_schema (boolean)
返回: (字符串) 成功消息。
示例
要注册表:
CALL samooha_by_snowflake_local_db.library.register_table_or_view(
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS'],
false,
false,
false,
false);
要注册 Iceberg 表:
CALL samooha_by_snowflake_local_db.library.register_table_or_view(
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS'],
false,
true,
false,
false);
register_table -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.register_objects.
Description: Similar to register_db
, but operates at a table level. An array or string representing the fully qualified table name can be passed in, and grant selects to the SAMOOHA_APP_ROLE role are made, enabling the user to link the table into the clean room.
If you want to register tables in a managed access schema (that is, a schema created with the WITH MANAGED ACCESS parameter), use library.register_managed_access_table
instead.
Arguments: table_name (Array)
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.register_table(['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS']);
register_managed_access_table -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.register_objects.
Description: Similar to register_table
, but registers tables in a schema that was created with the WITH MANAGED ACCESS parameter. An array or string representing the fully qualified table name can be passed in, and grant selects to the SAMOOHA_APP_ROLE role are made, enabling the user to link the table into the clean room.
Arguments: table_name (Array)
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.register_managed_access_table(['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS']);
register_view -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.register_objects.
Description: Similar to register_db
, but operates at a view level. An array or string representing the fully qualified view name can be passed in, and grant selects to the SAMOOHA_APP_ROLE role are made, enabling the user to link the view into the clean room.
If you want to register views in a managed access schema (that is, a schema created with the WITH MANAGED ACCESS parameter), use library.register_managed_access_view
instead.
Arguments: view_name (Array)
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.register_view(['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS']);
register_managed_access_view -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.register_objects.
Description: Similar to register_view
, but registers views in a schema that was created with the WITH MANAGED ACCESS parameter. An array or string representing the fully qualified view name can be passed in, and grant selects to the SAMOOHA_APP_ROLE role are made, enabling the user to link the view into the clean room.
Arguments: view_name (Array)
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.register_managed_access_view(['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS']);
unregister_table_or_view -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.unregister_objects.
描述: 取消注册所有类型的表和视图。
Arguments: object_names (Array), is_view (boolean), is_iceberg (boolean), is_external (boolean), is_under_managed_access_schema (boolean)
输出: (字符串) 成功消息。
示例
要取消注册表:
CALL samooha_by_snowflake_local_db.library.unregister_table_or_view(
['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS'],
false,
false,
false,
false);
unregister_table -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.unregister_objects
Description: Similar to unregister_db
, but operates at a table level. An array or string representing the fully qualified table name can be passed in to unregister the tables. Users can't link unregistered tables into a clean room.
If you want to unregister tables in a managed access schema (that is, a schema created with the WITH MANAGED ACCESS parameter), use library.unregister_managed_access_table
instead.
Arguments: table_name (Array)
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.unregister_table(['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS']);
unregister_managed_access_table -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.unregister_objects
Description: Similar to unregister_table
, but unregisters tables in a managed access schema (that is, a schema created with the WITH MANAGED ACCESS parameter).
Arguments: table_name (Array)
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.unregister_managed_access_table(['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS']);
unregister_view -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.unregister_objects
Description: Similar to unregister_db
, but operates at a view level. An array or string representing the fully qualified view name can be passed in to unregister the views. Users can't link unregistered views into a clean room.
If you want to unregister views in a managed access schema (that is, a schema created with the WITH MANAGED ACCESS parameter), use library.unregister_managed_access_view
instead.
Arguments: view_name (Array)
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.unregister_view(['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS']);
unregister_managed_access_view -- Deprecated¶
- 架构:
LIBRARY
注意
This procedure is now deprecated. Please use library.unregister_objects
Description: Similar to unregister_view
, but unregisters views in a managed access schema (that is, a schema created with the WITH MANAGED ACCESS parameter).
Arguments: view_name (Array)
返回: (字符串) 成功消息。
示例:
CALL samooha_by_snowflake_local_db.library.unregister_managed_access_view(['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS']);