For both methods, customers generally create separate tables/views for Aampe that are limited to only the data necessary for Aampe to function
- Unload data into Google Cloud Storage from Snowflake
- Provide direct access for Aampe user to your snowflake dataset (and tables) with event data
Unloading Data into Google Cloud Storage from Snowflake
1. Create Snowflake Integration
Integrations are named, first-class Snowflake objects that avoid the need for passing explicit cloud provider credentials such as secret keys or access tokens; instead, integration objects reference a Cloud Storage service account. We will provide you with the bucket link mentioned below.2. Obtain GCP Service Account
A GCP Service account is created by Snowflake as part of Step 1:STORAGE_GCP_SERVICE_ACCOUNT
property contains the GCP service account name. Example output:
3. Create File Formats
A parquet file format can be created in Snowflake as follows to unload snowflake data in the parquet format. Any other format like CSV or JSON also can be created. Here is an example script to create parquet format:4. Create External Stage
In Snowflake, an EXTERNAL STAGE object references data files stored in a location outside of Snowflake.5. Unload Data
From Snowflake, use the COPY command in Snowflake to unload data from a Snowflake table into a GCS bucket. To retain the column names in the output file, use theHEADER = TRUE
copy option.
6. Automate the Unloading
What we recommend is to automate the COPY command that unloads each day’s events (single partition) into the external stage by using Snowflake TASK for it to run at a schedule: https://docs.snowflake.com/en/sql-reference/sql/create-task.html An example of same would be:- https://docs.snowflake.com/en/user-guide/data-load-gcs-config.html
- https://docs.snowflake.com/en/user-guide/data-unload-prepare.html
Provide Direct Access for Aampe User to Your Snowflake Dataset (and tables) with Event Data
Our main purpose will be to create a user for Aampe which will have read access to the data warehouse and underlying tables. We will use this user (and in turn role) to fetch data into our system.Setup Steps:
- Start by using account admin to grant access in your snowflake worksheet console:
- Create a custom role to provide read access. If you already have a role that you use to define read only access you can skip this step and use that directly everywhere instead of AAMPE_ROLE:
- Create user with password authentication:
- Grant the read role to the user (if you already have a role with read access then you can use that directly):
- Grant access to the new role. You can restrict to certain db/tables as per needed. Small reminder to execute all queries if doing through UI:
- Account (e.g If your URL is https://tzviibq-hr75240.snowflakecomputing.com account will be tzviibq-hr75240)
- Data Warehouse Name
- Database Name
- Table Names (that contain events data)
- Schema Name