Provider-run analyses¶
개요¶
The default clean room configuration enables only the consumer to run an analysis in the clean room. However, the provider can request permission from the consumer to run a specific template in a specific clean room using consumer data. Provider-run analysis can be enabled and run using either the clean rooms UI or code.
The following diagram shows the data flow and main components in a basic provider-run analysis:
기본 공급자 실행 분석에서 컨슈머와 공급자는 모두 데이터를 클린룸에 연결합니다. 소스 데이터는 데이터가 있는 계정의 비공개 뷰로 클린룸에 연결됩니다.
공급자가 분석을 실행하면 공급자의 데이터가 컨슈머 계정의 클린룸 앱과 공유됩니다. 분석은 컨슈머의 계정에서 실행됩니다.
암호화된 결과는 컨슈머 계정의 컨슈머 DB에 임시로 기록됩니다.
암호화된 결과는 공급자 계정의 분석 결과 백 쉐어(거버넌스 백 쉐어라고도 함)에 복사되고 암호가 해독됩니다. 분석은 컨슈머의 계정에서 실행되므로 분석 요금이 컨슈머에게 청구됩니다.
자세한 내용은 Snowflake Data Clean Rooms: 설치된 오브젝트 섹션을 참조하십시오.
Templates that support provider-run analyses¶
The following templates support provider-run analyses:
Audience Overlap & Segmentation
SQL Query (UI only)
사용자 지정 템플릿(API 전용)
Billing and cost details¶
Provider-run analyses run in the consumer’s account, and consumers are billed for a provider-run analysis. To stop incurring costs from provider-run analyses, the consumer must uninstall the clean room.
A consumer can estimate the number of credits consumed by the provider within the last N days by executing the following query. Specify the number of previous days as a negative number.
-- Estimate the number of credits consumed in the past 5 days.
SELECT * FROM TABLE(SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.LIBRARY.PRA_CONSUMPTION_UDTF(-5));
When a provider runs an analysis in the clean rooms UI, the clean room uses auto-scaling logic based on dataset sizes to choose a warehouse for the provider’s analysis.
공급자가 API를 사용하여 클린룸을 만들고 실행하는 경우 공급자는 컨슈머가 지정한 허용 값 세트에서 웨어하우스 크기와 유형을 명시적으로 선택할 수 있습니다.
일반 노트¶
공급자는 UI 또는 API를 사용하여 자신의 계정에 결과를 활성화하거나 UI를 사용하는 경우 서드 파티 공급자에게 결과를 활성화할 수 있습니다. 활성화를 지원하고 결과를 보는 방법에 대한 자세한 내용은 Activating query results 섹션을 참조하세요.
If the consumer and provider are in different cloud regions, Cross-cloud auto-fulfillment must be enabled in both accounts and for both clean rooms.
공급자 실행 클라우드 간 쿼리는 모든 클라우드 리전에서 공급자 소스 데이터를 공급자에서 컨슈머로 복제하고 쿼리 결과를 컨슈머에서 공급자로 복제해야 하므로 실행하는 데 시간이 다소 걸릴 수 있습니다.
Any templates run by the provider require column names or aliases for all columns generated in the results. If a column is aggregated (for example,
SUM(col1)) or calls a custom function (for example,cleanroom.my_function(p.hashed_email)), the template must explicitly specify a column name alias as shown here:SELECT SUM(col1) AS TOTAL FROM my_db.my_sch.T; -- Correct SELECT SUM(col1) FROM my_db.my_sch.T; -- Error: aggregated column needs an explicit alias.
Provider-run analyses in the UI¶
Here is how to enable provider-run analysis in a new clean room when using the clean rooms UI:
The provider creates and configures a clean room, using one of the supported templates. Configure the clean room up to the Share Clean Room step.
In the Share Clean Room step of clean room configuration, the provider selects Enable run analysis & query next to their own account to enable them to run all templates in this clean room that support provider-run analysis.
클린룸이 생성된 후에는 이 설정을 변경할 수 없습니다. 게시된 클린룸에서 쿼리를 실행하기 위해 특정 계정의 권한을 변경하려면 클린룸을 삭제하고 새 클린룸을 만들어야 합니다.
The consumer joins and configures the clean room as usual for all templates in the clean room, including any templates that support provider analysis. If the consumer does not want to enable a provider to run a specific template, they can omit required details for that template.
컨슈머가 클린룸에 조인하면 조인하기 전에 해당 클린룸에 대해 공급자 실행 분석이 활성화되어 있다는 경고가 표시됩니다.
The consumer can run queries as soon as the clean room is joined, but there is a delay of up to 30 minutes before the provider can run the template. This setup delay occurs only during the initial join step; if the provider later adds other provider-run templates, the provider can run them as soon as the consumer configures their clean room for that template.
After the join step completes, the clean room is available for both provider run analyses and consumer run analyses.
중요:
공급자는 컨슈머가 클린룸을 설치한 후 약 10분을 기다려야 분석을 실행할 수 있습니다. 지연은 공급자 실행 분석에 필요한 추가 백그라운드 구성을 위한 것입니다.
공급자 또는 컨슈머가 실행하는 이 클린룸의 모든 분석에 대해 컨슈머에게 요금이 청구됩니다.
Provider-run analyses in the API¶
Here is how to enable provider-run analysis in a new clean room using the clean rooms API:
공급자
Creates and configures the clean room and data and policies in the standard way.
Adds consumers in the standard way.
``provider.enable_provider_run_analysis``를 호출하여 클린룸의 특정 컨슈머 계정에 대한 공급자 실행 분석을 활성화합니다.
중요:
The provider must call
provider.enable_provider_run_analysisafter adding consumers to a clean room, but before any consumer installs the clean room. Each consumer account must approve this request for their data to be accessible for provider-run analyses in this clean room.Any time the provider changes the provider-run analysis setting for a clean room, the clean room must be re-installed by all consumers for the change to take effect. Because it can be difficult to force all collaborators to re-install a clean room, it is more reliable for the provider to delete a published, shared clean room when changing the analysis permissions, and then create a new clean room with the desired permissions.
Publishes the clean room.
Lets the consumer know that the clean room is available, the name of the clean room, and what templates you want to run in the clean room.
컨슈머
Installs the clean room and links in data in the standard way.
데이터에 필요한 모든 :doc:`조인 및 열 정책</user-guide/cleanrooms/policies>`을 설정합니다.
Allows provider-run analysis for specific templates in the clean room by calling either
consumer.enable_templates_for_provider_run(for multiple templates) orconsumer.approve_template(for one template).참고
컨슈머가 템플릿을 승인한 후 공급자가 템플릿을 변경하는 경우 컨슈머는 템플릿을 다시 승인해야 합니다. 템플릿이 다시 승인될 때까지, 승인된 템플릿의 이전에 캐시된 버전이 공급자에 의해 실행됩니다.
(선택 사항) 컨슈머는 공급자 실행 분석에 사용할 수 있는 웨어하우스 유형 또는 크기를 제한할 수 있습니다. Restricting warehouse size and type limits 섹션을 참조하세요.
Tells the provider that they have installed the clean room and approved provider-run analyses.
공급자
After the consumer has installed the clean room, the provider enables analyses to access consumer data by enabling data sharing from the consumer to the provider account. The process for this depends on whether the provider and consumer are in the same cloud region or different cloud regions:
If the provider and consumer are in the same cloud region, the provider calls
provider.mount_request_logs_for_all_consumersonce. If a new consumer account installs the clean room later and the provider wants to use consumer data in this template, the provider must re-run this procedure to be able to access that data.If the provider and consumer are in different cloud regions, the provider and consumer must enable cross-cloud auto-fulfillment. When a provider runs an analysis across regions, the query can take some time to complete, because query data is sent from the provider’s region to the consumer’s region and back.
컨슈머가 분석에 사용되는 웨어하우스의 유형과 크기를 제한했는지 확인하려면
provider.view_warehouse_sizes_for_template``을 호출합니다. 컨슈머가 공급자 실행 분석을 위한 웨어하우스 크기를 제한하는 경우 공급자는 다음 단계의 분석 요청에서 허용된 ``warehouse_type및warehouse_size값을 지정해야 합니다. 컨슈머가 웨어하우스 제한을 지정하지 않은 경우 해당 필드는 분석 요청에서 선택 사항입니다. 자세한 내용은 Restricting warehouse size and type limits 섹션을 참조하십시오.Runs the analysis by calling
provider.submit_analysis_requestwith the template name, the table names, and the template arguments. If the consumer has specified limits on warehouse sizes or types, the provider must also specify the warehouse size and type in the analysis request.Save the request ID returned by
provider.submit_analysis_request; the ID is needed to check the status and results of the analysis.
Checks the status of the analysis by calling
provider.check_analysis_status. When status is reported asCOMPLETED, callprovider.get_analysis_resultto get the analysis results.
Restricting warehouse size and type limits¶
공급자 실행 분석에 대한 요금은 컨슈머에게 청구되므로, 컨슈머는 공급자가 자신의 계정에서 분석을 실행하는 데 사용할 수 있는 웨어하우스의 크기와 유형을 지정할 수 있습니다. 컨슈머가 웨어하우스 크기 및 유형 제한을 설정하는 방법과 공급자가 분석을 실행할 때 웨어하우스 크기 및 유형을 선택하는 방법은 다음과 같습니다.
The consumer calls
consumer.set_provider_run_configurationand specifies which warehouse sizes and types a provider can use for a specific template. In the following snippet, the consumer limits providers to using STANDARD warehouses of size MEDIUM or LARGE when runningtemplate_1:CALL samooha_by_snowflake_local_db.consumer.set_provider_run_configuration( $cleanroom_name, { 'template_1': { 'warehouse_type': 'STANDARD', 'warehouse_size': ['MEDIUM', 'LARGE']} });
공급자는 ``provider.view_warehouse_sizes_for_template``을 호출하여 해당 템플릿에 대한 공급자 실행 분석에 허용되는 웨어하우스 크기와 유형을 확인합니다.
CALL samooha_by_snowflake_local_db.provider.view_warehouse_sizes_for_template( $cleanroom_name, 'template_1', $consumer_account_loc );
공급자는 분석 실행 요청에 사용할 웨어하우스 크기와 유형을 지정합니다.
CALL samooha_by_snowflake_local_db.provider.submit_analysis_request( $cleanroom_name, $consumer_locator_id, 'template_1', ['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS'], ['SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS'], object_construct( 'dimensions', ['c.REGION_CODE'], 'measure_type', ['AVG'], 'measure_column', ['c.DAYS_ACTIVE'], 'warehouse_type', 'STANDARD', -- Any other value would cause the request to fail. 'warehouse_size', 'LARGE' -- Only MEDIUM and LARGE supported. ) );
팁
다음 프로시저는 Clean Room에서 분석을 실행할 수 있는 측을 관리합니다.
컨슈머 실행 분석 (기본적으로 허용됨): 변경 사항은 즉시 적용됩니다.
provider.enable_consumer_run_analysis
provider.disable_consumer_run_analysis
공급자 실행 분석 (기본적으로 비활성화됨): 변경 사항은 컨슈머가 다시 설치해야 합니다.
provider.enable_provider_run_analysis(requires the consumer to approve by calling consumer.enable_templates_for_provider_run)
provider.disable_provider_run_analysis
Install and run the code example¶
You can download and install a complete running example to create and run a provider-run analysis. To run this example, you need two Snowflake accounts in the same organization and cloud hosting region with the Snowflake Data Clean Room environment installed.
공급자 계정과 컨슈머 계정 모두에 노트북을 설치합니다.
노트북 업로드하려면 다음을 수행합니다.
Sign in to Snowsight.
In the navigation menu, select Projects » Notebooks.
+ Notebook » Import .ipynb file 를 선택합니다.
다운로드한 .ipynb 파일을 선택합니다.
파일 이름을 원하는 대로 지정하고 데이터베이스와 스키마를 선택합니다.
기본 웨어하우스
APP_WH를 유지합니다.Create 를 선택합니다.
To create the clean room, open the notebook in the provider account and complete the provider portion.
컨슈머 계정에서 노트북을 열고 컨슈머 부분을 완료하여 Clean Room을 설치 및 구성하고 템플릿을 실행합니다.
노트북에 표시된 순서대로 공급자 및 컨슈머 작업을 실행합니다.