Skip to content

Commit 711acbd

Browse files
committed
updates
1 parent 73628a5 commit 711acbd

File tree

3 files changed

+117
-5
lines changed

3 files changed

+117
-5
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
## Disclaimer 1
2+
THE FUNCTIONS BELOW ARE PROVIDED BY THE TRADE DESK, INC. ("TTD") "AS IS" AND "WITH ALL FAULTS." TTD SHALL HAVE NO OBLIGATION TO UPDATE THE SNOWFLAKE FUNCTIONS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS, TTD, OR TTD'S AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION SUSTAINED BY YOU OR ANY THIRD PARTY) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THESE FUNCTIONS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3+
4+
## Disclaimer 2
5+
- Instructions and functions provided are *examples only*, and not a complete implementation.
6+
- Remember to consider the privacy aspects of what is being implemented, including checking Legal/Compliance requirements about user consent and use of DII.
7+
8+
9+
10+
## Begin Workflow
11+
--When testing this workflow for the first time, use Drop Table queries. Otherwise, ignore.
12+
13+
```sql
14+
15+
16+
--When testing this workflow for the first time, use Drop Table queries. Otherwise, ignore.
17+
18+
Drop Table UID_Test_Audience_March2025
19+
20+
21+
22+
23+
24+
--Create a new table to store Email addresses
25+
Create Table UID_Test_Audience_March2025 ( ID INTEGER, EMAIL varchar(128))
26+
27+
-- Retrieve emails (or hashed emails) from your CDP or CRM platform
28+
INSERT INTO UID_Test_Audience_March2025
29+
VALUES
30+
(1,'dummy1@demo.com'),
31+
(2,'dummy2@demo.com'),
32+
(3,'dummy3@demo.com'),
33+
(4,'dummy4@demo.com'),
34+
(5,'dummy5@demo.com'),
35+
(6,'dummy6@demo.com'),
36+
(7,'dummy7@demo.com'),
37+
(8,'dummy8@demo.com'),
38+
(9,'dummy9@demo.com'),
39+
(10,'dummy10@demo.com')
40+
41+
--Query Table to confirm the emails are in your table
42+
select * from UID_Test_Audience_March2025
43+
44+
-- new share name: UID2_INTEG_UID_SH
45+
46+
47+
--Ignore for demo purposes.
48+
Drop Table UID_Test_Audience_March2025_withUID
49+
50+
51+
52+
53+
--Create new empty table with emails, and 2 more columns to collect UID and Bucket ID. This step is in here to illustrate the progression of adding in UIDs and BucketIds
54+
Create Table UID_Test_Audience_March2025_withUID ( ID INTEGER, EMAIL varchar(128), UID2 text, Bucket_ID text)
55+
56+
57+
--Retrieve UID and bucket ID and insert into a new table, leveraging the functions from the integration guide to map your emails to UID2s
58+
Insert into UID_Test_Audience_March2025_withUID
59+
select a.ID, a.EMAIL, m.UID, m.BUCKET_ID from UID_Test_Audience_March2025 a LEFT JOIN(
60+
select ID, t.* from UID_Test_Audience_March2025, lateral UID2_INTEG_UID_SH.UID.FN_T_IDENTITY_MAP(EMAIL, 'email') t) m
61+
on a.ID=m.ID;
62+
63+
64+
65+
66+
--Confirm the values that now exist in your new table -- now you have mapped emails and can use your UID2s!
67+
select * from UID_Test_Audience_March2025_withUID
68+
69+
70+
71+
--ignore for demo
72+
Drop Table UID_Test_Audience_March2025_withUID_withRetrieved
73+
74+
75+
--testing--
76+
77+
Create Table UID_Test_Audience_March2025_withUID_withRetrieved ( ID INTEGER, EMAIL varchar(128), UID2 text, Bucket_ID text, Last_Retrieved_date TIMESTAMP_NTZ)
78+
79+
80+
--Create a new table with Last updated timestamp: this inserts the Current Timestamp - This has 5 columns
81+
Insert into UID_Test_Audience_March2025_withUID_withRetrieved
82+
select a.ID, a.EMAIL, m.UID, m.BUCKET_ID, CURRENT_TIMESTAMP from UID_Test_Audience_March2025 a LEFT JOIN(
83+
select ID, t.* from UID_Test_Audience_March2025, lateral UID2_INTEG_UID_SH.UID.FN_T_IDENTITY_MAP(EMAIL, 'email') t) m
84+
on a.ID=m.ID;
85+
86+
87+
--Confirm the values in your new table
88+
select * from UID_Test_Audience_March2025_withUID_withRetrieved
89+
90+
91+
--Check last salt bucket rotataion for your UID2
92+
select a.*, b.LAST_SALT_UPDATE_UTC
93+
from UID_Test_Audience_March2025_withUID a LEFT OUTER JOIN UID2_INTEG_UID_SH.UID.SALT_BUCKETS b
94+
on a.BUCKET_ID=b.BUCKET_ID
95+
96+
97+
98+
99+
--This last query compares last retrieved date to last salt bucket Id rotation to show you the UID2 that need to be regenerated
100+
--A good way to remember this is: Whenever UID2 retrieved date is OLDER than last bucket Id rotation, then UID2 needs to be regenerated
101+
select a.*, b.LAST_SALT_UPDATE_UTC
102+
from UID_Test_Audience_March2025_withUID_withRetrieved a LEFT OUTER JOIN UID2_INTEG_UID_SH.UID.SALT_BUCKETS b
103+
on a.BUCKET_ID=b.BUCKET_ID
104+
where a.Last_Retrieved_date < b.LAST_SALT_UPDATE_UTC or a.UID2 IS NULL;
105+
106+
107+
108+
109+
---to see results of the query when the uid2 does not need to be generated, change where clause to: where a.Last_Retrieved_date < b.LAST_SALT_UPDATE_UTC or a.UID2 IS NOT NULL; -- this just shows you full results to populate the columns
110+
--where you should see that last_retrieved is NEWER than last_salt_update
111+
112+
1.98 KB
Binary file not shown.

docs/guides/integration-snowflake.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ The following list summarizes the integration steps for UID2 mapping in Snowflak
7474
- Your Snowflake account number
7575
- The region
7676

77-
1. Your UID2 contact will arrange for your Snowflake account to be provisioned with access to the UID2 mapping share.
77+
1. Your UID2 contact arranges for your Snowflake account to be provisioned with access to the UID2 mapping share.
7878

79-
You can also download suggested workflow scripts to get started with basic mapping and salt bucket rotation concepts. [**GWH_KM__01 Do you know where I can get these scripts from? Not sure yet if we can offer them as a downloadable asset, but, first step is to get them.**]
79+
You can also download [an example file](images/UID2_INTEG_UID_SH.zip) with a suggested workflow with Snowflake functions.
8080

8181
:::note
8282
If you did any initial testing (see [Testing in the Integration Environment](#testing-in-the-integration-environment)), be sure to update the functions to reflect the production UID2 share, along with your own relevant table names.
@@ -88,10 +88,10 @@ If you'd like to test the mapping shares before signing a UID2 POC, you can ask
8888

8989
In this scenario, the following steps occur:
9090

91-
1. Your UID2 contact provisions the share listing in the Snowflake Private Marketplace. [**GWH_KM__02 is there some other step, such as, the contact lets the advertiser know? Otherwise how will they know?**]
92-
2. You can then request access to the Private Marketplace listing.
91+
1. Your UID2 contact coordinates provisioning of the share listing in the Snowflake Private Marketplace, and lets you know when provisioning is complete so that you can access the listing.
92+
2. You go to the Private Marketplace listing and request access to the UID2 share.
9393

94-
3. Your UID2 contact provisions the integ shares to your account. [**GWH_KM__03 Is it share rather than shares now that we have a combined listing? Or, is it still shares? Not sure.**]
94+
3. Your UID2 contact provisions the integ share to your account. [**GWH_KM__03 Is it share rather than shares now that we have a combined listing? Or, is it still shares? Not sure.**]
9595

9696
## Workflow Diagram
9797

0 commit comments

Comments
 (0)