Tutorial: Create and run a clean room using the clean rooms UI and a single account¶
Introduction¶
This tutorial leads you through the basic steps to create and use a clean room using the clean rooms UI. Clean rooms enable users to share data with a collaborator while maintaining the privacy of the data by tightly controlling what can be done with it.
What you’ll learn¶
In this tutorial, you will learn how to use the clean rooms UI by doing the following actions:
Add a collaborator to your clean room environment. In this tutorial, you will add yourself as a collaborator.
Create a clean room, including how to add data, specify join policies, define which type of analysis a collaborator can run on the data, and share the clean room with a collaborator.
Install a clean room, add data, and define how this data is joined with the collaborator’s data.
Run an analysis.
Activate the results of the analysis.
About clean room collaborators¶
Clean room collaborators are either providers or consumers:
A provider is the account that creates and configures the clean room. In a typical clean room, the provider adds all the SQL templates that the consumer can run in the clean room. The provider adds data, sets usage restrictions on it, and invites consumers, who can join the clean room to run the templates.
A consumer is the account invited to participate in the clean room. The consumer adds their own data and runs the templates on the clean room data, according to the limitations set by the provider.
In this tutorial, you act as both the provider and the consumer in the clean room. In a real world clean room, the provider and consumer would use separate accounts.
Prerequisites¶
You must have access to a Snowflake environment with the Snowflake Data Clean Rooms UI installed. You must either install the environments yourself, or ask an administrator to grant you access to the clean rooms UI in a Snowflake account.
This tutorial uses a sample table named DEMO_CUSTOMERS_2. Either search Snowsight for the table SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS_2, or run the following SQL command in your Snowflake account to confirm that you have this table installed:
SHOW TABLES LIKE 'CUSTOMERS_2' IN SCHEMA SAMOOHA_SAMPLE_DATABASE.DEMO;
If the response has no rows, then you, or someone with ACCOUNTADMIN role, must run the following command to install the sample table:
USE ROLE ACCOUNTADMIN; EXECUTE IMMEDIATE FROM @SAMOOHA_BY_SNOWFLAKE.APP_SCHEMA.MOUNT_CODE_STAGE/dcr_loader.sql;
Note
This tutorial uses a single account for both the provider and consumer in the clean room. This type of clean room, an internal testing clean room, is for testing purposes only, and can’t later be used in production or shared with other accounts. Internal testing clean rooms support most, but not all clean room features. If you would like to try using clean rooms two separate Snowflake accounts, try the two-account tutorial.
Sign in to the clean rooms UI¶
Sign in to the clean rooms UI. Provide your Snowflake account credentials for an account where you can act as a clean rooms provider. A provider has permission to create a clean room.
Consumer: Install and configure the clean room¶
In this step, you switch from acting as the provider, who creates and shares a clean room, to acting as the consumer, who installs and runs the clean room. Because this is an internal testing clean room, you will use the same Snowflake account for the provider and consumer.
As a consumer, you will do the following actions:
Install the clean room that was shared with you by the provider.
Add data to the clean room so that it can be joined with the provider’s data.
Add a join policy to define how the consumer’s data and the provider’s data are related.
Define the columns that analysts can use to create segments, filter results, and enrich activation data.
Install the clean room as a consumer¶
Installation in the UI involves joining, configuring, and then installing the clean room.
To configure the clean room:
In the left navigation, select Clean Rooms.
Select the Invited tab.
Find the
Tutorial
tile, and select Join.If the clean room isn’t in your Invited tab, select Refresh. If it’s still not there, confirm that the clean room has an Edit button in the Created tab. If there is no edit button, you didn’t create the clean room as a provider.
Add consumer data to the clean room¶
To add data to the clean room:
In the Datasource section, select
Snowflake
.From the Tables drop-down list, select and then save SAMOOHA_SAMPLE_DATABASE.DEMO.CUSTOMERS_2.
If this table is not in your list, see the Prerequisites section in the tutorial introduction to learn how to install it.
Select Next.
Define a join policy¶
Next, specify which consumer columns are joinable in an analysis or query in this clean room:
In the Specify Join Policies pane, in the Join Policies section, choose columns from your data (labeled My Columns) and equivalent columns from the provider’s table (labeled Collaborator Columns).
Ensure that the columns from the consumer’s table (My Columns) and the columns from the provider’s table (Collaborator Columns) match in content (the column names don’t need to match).
For example, the consumer’s
HASHED_EMAIL
column should be joined with the provider’sHASHED_EMAIL
column. All joined columns must match in the analysis that you select.Select Next to navigate to the Configure Analysis & Query pane.
Define the segmentation and activation columns¶
When you select segmentation and activation columns during the clean room installation process, you define which columns are available to users running an analysis in the clean room. Analysts can create segments based only on these columns. When you send activation data back to the provider, analysts can’t enrich the results of the analysis with data unless the data comes from one of these columns.
To define the segmentation and activation columns:
Select and then save the DEMO.CUSTOMERS_2 table from the Tables drop-down list.
From the Segmentation & Activation Columns drop-down list, select and then save the following columns:
INCOME_BRACKET
REGION_CODE
STATUS
Select Finish to install the clean room.
Installation takes a few minutes to complete.
Select Refresh every few minutes to check for changes.
When the tile label changes from Processing to a Run button, the clean room is installed and you can run an analysis.
Consumer: Run an analysis¶
In this step, you run an audience overlap and segmentation analysis in the clean room. You must first select the data to use in the analysis.
To configure and run an analysis:
In the Joined tab, find the clean room tile and then select Run.
Select Audience Overlap & Segmentation » Proceed.
In My Tables, select CUSTOMERS.
In Collaborator’s Tables, select CUSTOMERS.
In Required Parameters » My Join Columns, define the following joins:
From the drop-down list, select and then save
HASHED_EMAIL
.Select + Join Column, then select
HASHED_FIRST_NAME
andHASHED_LAST_NAME
.Select + Join Column, then select
HASHED_PHONE
.
When you run an analysis in the clean room, results include records where any of the following items are true:
The consumer’s
HASHED_EMAIL
matches the provider’sHASHED_EMAIL
.The consumer’s
HASHED_FIRST_NAME
matches the provider’sHASHED_FIRST_NAME
and the consumer’sHASHED_LAST_NAME
matches the provider’sHASHED_LAST_NAME
.The consumer’s
HASHED_PHONE
matches the provider’sHASHED_PHONE
.
In the User Segmentation section, perform the following steps:
From the My Columns drop-down list, select
INCOME_BRACKET
.From the Collaborator Columns drop-down list, select
AGE_BAND
.
The results of the analysis are grouped into these segments.
In the Filters section, use the drop-down lists to specify
CUSTOMERS.STATUS = GOLD
.This limits analysis results to results where
STATUS = GOLD
.Select Run.
You can optionally choose a different warehouse size to run the analysis by changing the Warehouse drop-down selection.
In the Analyses & Queries page, when the status of your analysis is Completed:
Select the analysis to see your results.
Scroll to the Results section of the page. You can toggle the results to see either overlap or non-overlap rates.
To see the segmentation groups of your analysis, select Download, and then open the comma-delimited file.
Continue to the next step to activate (send) enriched results to the consumer’s Snowflake account.
Consumer: Activate the results to the consumer account¶
In this step, you activate the results of your analysis by pushing them to the consumer’s Snowflake account. These results are enriched with data from the consumer and provider tables.
To activate the results of the analysis:
In the Results section for the analysis, select Activate.
In the Activation Hub section, select the name of your account.
This section lists accounts and services where you can activate data to. The list can include third-party activation connectors that send data to services outside of Snowflake.
In the Segment Name field, enter
My test segment
, or another unique name for this result set.Copy and save the segment name that you provide here.
From the ID Columns drop-down list, select
HASHED_EMAIL
.From the Attribute Columns drop-down list, select Select All.
When you look at the results of the analysis, the matched records will be enriched with data from both consumer and provider tables.
The available columns are the same as the segmentation and activation columns that you selected as the consumer when you installed the clean room.
Select Push Data.
Congratulations! You have now installed and configured a clean room in a consumer account, run an analysis, and pushed the results to the consumer account for activation.
View the activated data¶
In the previous step you activated to the consumer’s Snowsight account. Here is how to view the activated data by using either the Snowflake web application or code:
Sign in to Snowsight with the same account where you ran the clean room. Use the Snowflake UI, not the clean rooms UI.
In the left navigation, select Catalog » Database Explorer.
Search for
SAMOOHA_BY_SNOWFLAKE_LOCAL_DB
.Navigate to PUBLIC » Tables » CONSUMER_DIRECT_ACTIVATION_SUMMARY.
Select Data Preview to view the activation data.
If you don’t see data there, confirm that you are using the same Snowflake account that you used to activate your data.
Sign in to Snowsight with the same account where you ran the clean room. Use the Snowflake UI, not the clean rooms UI.
Open Projects » Worksheets.
Select + » SQL Worksheet.
to list the activation data that was pushed to the consumer’s clean room environment, paste and run the following statement into the new worksheet. Substitute the segment name that you entered when you ran the activation in the clean rooms UI.
SELECT * FROM SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.PUBLIC.CONSUMER_DIRECT_ACTIVATION_SUMMARY WHERE segment = '<your segment name>';
If you don’t see data, confirm that you are using the same Snowflake account that you used to activate your data, and that you are using the segment name that you specified when you activated the results.
Clean up¶
You can delete the clean room and activation data that you created for this tutorial to clean up your production environment.
Delete the activation data¶
To delete the activation data from the provider’s Snowflake account:
Sign in to Snowsight for the provider account. Sign in to the Snowflake UI, not the clean rooms UI.
Open Projects » Worksheets.
Select + » SQL Worksheet.
In the new worksheet, paste and run the following statement to delete the activation data created for this tutorial. Substitute your custom segment name in the location indicated:
DELETE FROM SAMOOHA_BY_SNOWFLAKE_LOCAL_DB.PUBLIC.CONSUMER_DIRECT_ACTIVATION_SUMMARY WHERE segment = '<your segment name>';
Delete the clean room¶
Deleting a clean room in the provider account removes it from both the provider account and the consumer account.
To delete a clean room:
Learn more¶
Congratulations! You have now used the clean rooms UI to create and share a clean room as a provider. You have also acted as a consumer who is using the clean room to analyze data within a privacy-preserving environment.
For more information about Snowflake data clean rooms, see the following resources:
For general information, see Overview of Snowflake Data Clean Rooms.
For more information about the clean rooms UI, see Clean rooms UI overview.
For information about using the developer APIs to work with a Snowflake Data Clean Room programmatically, see Snowflake Data Clean Rooms developer’s guide.