Provider-run analyses¶
Übersicht¶
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:
Bei einer grundlegenden, vom Anbieter durchgeführten Analyse verknüpfen der Verbraucher und der Anbieter ihre Daten mit dem Clean Room. Die Quelldaten sind als private Ansichten in dem Konto, in dem sich die Daten befinden, mit dem Clean Room verknüpft.
Wenn der Anbieter eine Analyse durchführt, werden die Daten des Anbieters mit der Clean Room-App im Konto des Verbrauchers geteilt. Die Analyse wird im Konto des Verbrauchers ausgeführt.
Die verschlüsselten Ergebnisse werden temporär in die Verbraucher-DB im Verbraucherkonto geschrieben.
Als Nächstes werden die verschlüsselten Ergebnisse in einen Analyseergebnis-Backshare im Anbieterkonto (auch Governance-Backshare genannt) kopiert und entschlüsselt. Da die Analyse im Verbraucherkonto ausgeführt wird, wird die Analyse den Verbrauchenden in Rechnung gestellt.
Weitere Informationen dazu finden Sie unter Snowflake Data Clean Rooms: Installierte Objekte.
Templates that support provider-run analyses¶
The following templates support provider-run analyses:
Audience Overlap & Segmentation
SQL Query (UI only)
Benutzerdefinierte Vorlagen (nur 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.
Wenn ein Anbieter einen Clean Room unter Verwendung der API erstellt und ausführt, kann der Anbieter explizit eine Warehouse-Größe und einen Warehouse-Typ aus einer Menge von zulässigen Werten auswählen, die vom Verbraucher angegeben wurden.
Allgemeine Hinweise¶
Anbieter können Ergebnisse für ihr eigenes Konto aktivieren, indem sie die UI oder API verwenden, oder für Drittanbieter-Anwender, wenn sie die UI verwenden. Informationen darüber, wie Sie die Aktivierung durchführen und die Ergebnisse anzeigen können, finden Sie unter 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.
Beachten Sie, dass die Durchführung vom Anbieter ausgeführter Cloud-übergreifender Abfragen einige Zeit in Anspruch nehmen kann, da die Quelldaten des Anbieters vom Anbieter zum Verbraucher repliziert werden müssen und die Ergebnisse vom Verbraucher zum Anbieter abgefragt werden müssen, und zwar über alle Cloudregionen hinweg.
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.
Diese Einstellung kann nicht mehr geändert werden, nachdem ein Clean Room erstellt wurde. Wenn Sie die Berechtigung für ein bestimmtes Konto zum Ausführen von Abfragen in einem veröffentlichten Clean Room ändern möchten, müssen Sie den Clean Room löschen und einen neuen erstellen.
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.
Wenn Verbrauchende dem Clean Room beitreten, werden sie vor dem Beitritt gewarnt, dass die vom Anbieter durchgeführte Analyse für diesen Clean Room aktiviert ist.
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.
Wichtig:
Anbieter müssen etwa 10 Minuten warten, nachdem der Verbraucher den Clean Room installiert hat, bevor sie eine Analyse ausführen können. Die Verzögerung entsteht für zusätzliche Hintergrundkonfigurationen, die für vom Anbieter durchgeführte Analysen erforderlich sind.
Den Verbrauchenden werden alle Analysen in diesem Clean Room in Rechnung gestellt, unabhängig davon, ob sie vom Anbieter oder von Verbrauchenden ausgeführt wurden.
Provider-run analyses in the API¶
Here is how to enable provider-run analysis in a new clean room using the clean rooms API:
Anbieter
Creates and configures the clean room and data and policies in the standard way.
Adds consumers in the standard way.
Aktiviert vom Anbieter ausgeführte Analysen für bestimmte Verbraucherkonten im Clean Room, indem
provider.enable_provider_run_analysisaufgerufen wird.Wichtig:
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.
Verbraucher
Installs the clean room and links in data in the standard way.
Legt alle Verknüpfungs- und Spaltenrichtlinien fest, die für die Daten benötigt werden.
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).Bemerkung
Wenn der Anbieter eine Vorlage ändert, nachdem sie von Verbrauchenden genehmigt wurde, müssen die Verbrauchenden die Vorlage erneut genehmigen. Bis zur erneuten Genehmigung der Vorlage wird die alte zwischengespeicherte Version der genehmigten Vorlage vom Anbieter ausgeführt.
(Optional) Ein Verbraucher kann den Warehouse-Typ oder die Größen begrenzen, die für vom Anbieter durchgeführte Analysen verfügbar sind, Siehe Restricting warehouse size and type limits.
Tells the provider that they have installed the clean room and approved provider-run analyses.
Anbieter
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.
Ruft
provider.view_warehouse_sizes_for_templateauf, um zu ermitteln, ob der Verbraucher den Typ und die Größe des für die Analyse verwendeten Warehouses eingeschränkt hat. Wenn der Verbraucher die Warehouse-Größen für vom Anbieter durchgeführte Analysen eingeschränkt hat, muss der Anbieter zulässige Werte fürwarehouse_typeundwarehouse_sizein der Analyseanfrage im nächsten Schritt angeben. Wenn der Verbraucher keine Warehouse-Grenzen angegeben hat, sind diese Felder in der Analyseanforderung optional. Weitere Informationen dazu finden Sie unter 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¶
Da dem Verbraucher die vom Anbieter durchgeführten Analysen in Rechnung gestellt werden, kann der Verbraucher bestimmen, welche Größen und Typen von Warehouses der Anbieter verwenden kann, um eine Analyse in seinem Konto auszuführen. Hier erfahren Sie, wie Verbraucher eine Beschränkung der Warehouse-Größe und des -Typ festlegen und wie ein Anbieter die Größe und den Typ eines Warehouses auswählt, wenn er eine Analyse durchführt:
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']} });
Der Anbieter ruft auf
provider.view_warehouse_sizes_for_templateauf, um zu sehen, welche Warehouse-Größen und -Typen für vom Anbieter durchgeführte Analysen für diese Vorlage zulässig sind.CALL samooha_by_snowflake_local_db.provider.view_warehouse_sizes_for_template( $cleanroom_name, 'template_1', $consumer_account_loc );
Der Anbieter gibt eine Warehouse-Größe und einen Warehouse-Typ an, die für seine Analyseausführungsanfrage verwendet werden sollen.
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. ) );
Tipp
Die folgenden Prozeduren regeln, welche Seite eine Analyse im Clean Room durchführen kann:
Von Verbrauchenden durchgeführte Analyse (standardmäßig erlaubt): Änderungen werden sofort übernommen.
provider.enable_consumer_run_analysis
provider.disable_consumer_run_analysis
Von Anbieter durchgeführte Analyse (standardmäßig deaktiviert): Änderungen erfordern eine Neuinstallation durch die Verbrauchenden.
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.
Installieren Sie das Notizbuch sowohl in Ihren Anbieter- als auch in Ihren Verbraucherkonten.
Um ein Notizbuch hochzuladen, gehen Sie wie folgt vor:
Sign in to Snowsight.
In the navigation menu, select Projects » Notebooks.
Wählen Sie + Notebook » Import .ipynb file aus.
Wählen Sie die heruntergeladene .ipynb-Datei aus.
Benennen Sie die Datei wie gewünscht, und wählen Sie eine Datenbank und ein Schema.
Behalten Sie das Standard-Warehouse
APP_WHbei.Wählen Sie Create aus.
To create the clean room, open the notebook in the provider account and complete the provider portion.
Öffnen Sie das Notebook im Verbraucherkonto und füllen Sie den Verbraucherteil aus, um den Clean Room zu installieren und zu konfigurieren und die Vorlage auszuführen.
Führen Sie die Anbieter- und Verbraucheraktionen wie angegeben und in der im Notebook angezeigten Reihenfolge aus.