Customers on an Enterprise or Growth plan can access Data Pipeline as an add-on package. See our pricing page for more details.
Design
Mixpanel stages exported data in a GCS bucket before loading it into your Snowflake warehouse. You need to set up a role, storage integration, and user in your Snowflake account before creating a pipeline.Set Export Permissions
Step 1: Create a Role and Grant Permissions
Create a role (MIXPANEL_EXPORT_ROLE as an example) and grant access on your database, schema, warehouse to the role. Replace <database name>, <schema name>, <warehouse name> with actual names.
Step 2: Create a Storage Integration
Mixpanel stages exported data in a GCS bucket (gcs://mixpanel-export-pipelines-<project-id>) before loading it into your warehouse. This bucket is created and managed by Mixpanel - you do not need to create it yourself. To allow Mixpanel to load data from this bucket into your Snowflake warehouse, create a GCS storage integration and grant it to the role. Replace <project-id> with your Mixpanel project ID.
Step 3: Authenticate the User
Create a user with a password and grant the role to the user. If you already have a user, change the fields and grant the role._raw. For example, for signup event, you will have a signup_raw table and a signup view. Please see Schema for general information about the schemas in Schematized Export Pipelines.
Partitioning
The data in the raw tables is clustered based ontime column but in project’s timezone. To be exact, we use CLUSTER BY (TO_DATE(CONVERT_TIMEZONE('UTC','<TIMEZONE>', TO_TIMESTAMP(DATA:time::NUMBER))) where TIMEZONE is the Mixpanel project’s timezone.
Queries
Mixpanel recommends you place all events into a single table to make querying easier. To get more information about the table schemas, please see Schema. A query is a request for data results. You can perform actions on the data, such as combine data from different tables; add, change, or delete table data; and perform calculations. Snowflake supports a VARIANT type that can store JSON objects and arrays. Mixpanel exposes array and object top-level properties as VARIANT columns in the view. Here is an example of how you can query the raw table when using one table for all the events:Getting the number of events in each day
You will need this if you suspect the export process is not exporting all the events you want. As time column in the tables is in UTC timezone, you first need to convert that to your Mixpanel project timezone, and then, get the number of events for each day. The following query will do that for you.PROJECT_TIMEZONE and DB_NAME should be replaced by your Mixpanel project timezone and your snowflake database name. You can adjust the query for multi-schema by putting the right table name in the query.
Querying the identity mapping table
When using the ID mappings table, you should use the resolveddistinct_id in place of the non-resolved distinct_id whenever present. If there is no resolved distinct_id, you can then use the distinct_id from the existing people or events table.
Below is an example SQL query that references the ID mapping table to count number of events in a specific date range for each unique user in San Francisco