Vom Anbieter durchgeführte Analyse

Overview

Die Standardkonfiguration des Clean Room ermöglicht es nur dem Verbraucher, eine Analyse im Clean Room durchzuführen. Der Anbieter kann jedoch die Erlaubnis des Verbrauchers einholen, Vorlagen mit Verbraucherdaten in einem bestimmten Clean Room auszuführen. Die vom Anbieter durchgeführte Analyse kann entweder über die Clean Room UI oder über Code aktiviert und ausgeführt werden.

The following diagram shows the data flow and the main components in a basic provider-run analysis:

Basic data flow direction in a provider-run analysis
  1. In a basic provider-run analysis, the consumer and provider both link their data into the clean room. Source data is linked into the clean room as private views in the account where the data lives.

  2. When the provider runs an analysis, the provider’s data is shared with the clean room app in the consumer’s account. The analysis runs on the consumer’s account.

  3. The encrypted results are temporarily written to the consumer DB in the consumer’s account.

  4. The encrypted results are copied to the analysis results back share on the provider’s account (also called the governance back share) and decrypted. Because the analysis runs on the consumer’s account, the consumer is billed for the analysis.

For more information, see 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));
Copy

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 your analysis.

When a provider creates and runs a clean room using the API, the provider can explicitly choose a warehouse size using the API. The consumer can limit the size and type of warehouses available to the provider when running a given template.

General notes

  • Providers can activate results to their own account using the UI or the API, or to third-party providers if using the UI. For information about how to enable activation and view results, see Implementierung der Aktivierung in Ihrem Clean Room.

  • Wenn sich der Verbraucher und der Anbieter in unterschiedlichen Cloud-Regionen befinden, müssen Sie die Cloud-übergreifende automatische Ausführung in beiden Konten und für beide Clean Rooms aktivieren.

    Note that provider-run cross-cloud queries can take some time to run because provider source data must be replicated from the provider to the consumer, and query results from the consumer to the provider, all across cloud regions.

  • 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)), you must explicitly specify an alias for the column name 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.
    
    Copy

Provider-run analyses in the UI

Here is how to enable provider-run analysis in a new clean room using the clean rooms UI:

  1. 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.

  2. 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.

  3. The consumer joins and configures the clean room as is 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 is only occurs 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.

  4. After the join step completes, the clean room is available for both provider run analyses and consumer run analyses.

    Important:

    • Providers must wait about 10 minutes after the consumer installs the clean room before they can run an analysis. The delay is for additional background configuration required for provider-run analyses.

    • 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:

  1. Anbieter

    1. Erstellen und konfigurieren Sie Ihren Clean Room und Ihre Daten und Richtlinien auf die übliche Weise.

    2. Fügen Sie Verbraucher auf die übliche Weise hinzu.

    3. Enable provider-run analysis for specific consumer accounts in the clean room by calling provider.enable_provider_run_analysis.

      Important:

    • You must call provider.enable_provider_run_analysis after 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, then create a new clean room with the desired permissions.

    1. Veröffentlichen Sie den Clean Room.

    2. Teilen Sie Ihren Verbrauchern mit, dass der Clean Room zur Verfügung steht, den Namen des Clean Room und die Vorlagen, die Sie im Clean Room ausführen möchten.

  2. Verbraucher

    1. Installieren Sie den Clean Room und verknüpfen Sie Ihre Daten auf die herkömmliche Art.

    2. Set any join and column policies needed on your data.

    3. Erlauben Sie Anbieteranalysen für bestimmte Vorlagen im Clean Room, indem Sie entweder consumer.enable_templates_for_provider_run (für mehrere Vorlagen) oder consumer.approve_template (für eine Vorlage) aufrufen.

      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.

    4. (Optional) Provider-run analyses are billed to the consumer. A consumer can limit the warehouse type or sizes available for provider-run analyses: see Restricting warehouse size and type limits.

    5. Teilen Sie dem Anbieter mit, dass Sie den Clean Room installiert und die vom Anbieter durchgeführten Analysen genehmigt haben.

  3. Anbieter

    1. Nachdem der Verbraucher den Clean Room installiert hat, müssen Sie Ihren Analysen den Zugriff auf Verbraucherdaten ermöglichen, indem Sie die Datenfreigabe zwischen Verbraucher- und Anbieterkonto aktivieren. Der Prozess hierfür hängt davon ab, ob sich Anbieter und Verbraucher in derselben Cloudregion oder in verschiedenen Cloudregionen befinden:

      • If the provider and consumer are in the same cloud region, the provider calls provider.mount_request_logs_for_all_consumers once. If a new consumer account installs the clean room later and you want to use their data in this template, you 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.

    2. Call provider.view_warehouse_sizes_for_template to see if the consumer has limited the type and size of warehouse used for the analysis. If the consumer has limited your warehouse selection, you must provide supported warehouse_type and warehouse_size values in your analysis request in the next step. If the consumer has not specified warehouse limits, those fields are optional in your request. For more information, see Restricting warehouse size and type limits.

    3. Run the analysis by calling provider.submit_analysis_request with the template name, the table names, and the template arguments. If the consumer has specified limits on warehouse sizes or types, you must also specify the warehouse size and type in your request.

      • Save the request ID returned by provider.submit_analysis_request; the ID is needed to check the status and results of the analysis.

    4. Check the status of the analysis by calling provider.check_analysis_status. When status is reported as COMPLETED, call provider.get_analysis_result to get the analysis results.

Restricting warehouse size and type limits

Here is how a consumer sets a warehouse size and type limitation, and how a provider chooses a warehouse size and type when running an analysis:

  1. Verbrauchende rufen consumer.set_provider_run_configuration auf und geben an, welche Warehouse-Größen und -Typen ein Anbieter für eine bestimmte Vorlage verwenden kann.

    CALL samooha_by_snowflake_local_db.consumer.set_provider_run_configuration(
      $cleanroom_name,
      {
        $template_name: {
          'warehouse_type': 'STANDARD',
          'warehouse_size': ['MEDIUM', 'LARGE']}
      });
    
    Copy
  2. Der Anbieter ruft auf provider.view_warehouse_sizes_for_template auf, 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_name,
      $consumer_account_loc
    );
    
    Copy
  3. The provider specifies which supported warehouse size and type to use in their analysis run request.

    CALL samooha_by_snowflake_local_db.provider.submit_analysis_request(
      $cleanroom_name,
      $consumer_locator_id,
      $template_name,
      ['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.
      )
    );
    
    Copy

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.

  1. Laden Sie das Beispiel-Notebook herunter.

  2. Installieren Sie das Notizbuch sowohl in Ihren Anbieter- als auch in Ihren Verbraucherkonten.

    Um ein Notizbuch hochzuladen, gehen Sie wie folgt vor:

    1. Wählen Sie im Navigationsmenü die Option Projects » Notebooks aus.

    2. Wählen Sie + Notebook » Import .ipynb file aus.

    3. Wählen Sie die heruntergeladene .ipynb-Datei aus.

    4. Benennen Sie die Datei wie gewünscht, und wählen Sie eine Datenbank und ein Schema.

    5. Behalten Sie das Standard-Warehouse APP_WH bei.

    6. Wählen Sie Create aus.

    7. Öffnen Sie das Notebook im Anbieterkonto und füllen Sie den Anbieterteil aus, um den Clean Room zu erstellen.

    8. Ö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.

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