Snowflake
Connect your Symon.AI and Snowflake accounts to export your data to your Snowflake account.
Connect your Symon.AI and Snowflake accounts to export your data to your Snowflake account. This connection allows Symon.AI to write data to Snowflake.
Set up the connector to be available for use with the Export tool. You only need to set up the connection once. After the connection is set up, Symon.AI can write updates and inserts into Snowflake.
Before you begin
Ensure that the necessary privileges are granted to the role to write to the table. If the role is omitted in the Snowflake connection, the default role of the user is used. For more information, see Configuring access control.
New table in new schema | New table in existing schema | Update existing table | |
---|---|---|---|
| Yes | Yes | Yes |
| Yes | Yes | Yes |
| No | Yes | Yes |
| Yes | Yes | Yes |
| Yes | No | No |
| No | Yes | No |
| No | No | Yes |
Snowflake file format
To load data into a Snowflake table, you need to use file format. File format is the Snowflake object that describes the format of a file. A file format object requires the following properties:
type = csv escape = \ field_optionally_enclosed_by = "
Ensure that the user has the necessary privileges to create file format:
USAGE
on warehouseUSAGE
on databaseUSAGE
on schemaCREATE FILE FORMAT
on schema
Note
You don't need to create the file format object each time, but ensure that there is one valid file format object and the role has access to it within the database used for the connection.
Create the file format in Snowflake for a
.csv
file:CREATE FILE FORMAT {database}.{schema}.{file_format_name}
TYPE = 'CSV' ESCAPE='\\' FIELD_OPTIONALLY_ENCLOSED_BY='“';
Example 1. Create a schema for Symon.AIFor example, if you wanted to create a schema for Symon.AI to use, use the following file format:
CREATE OR REPLACE FILE FORMAT VARICENT_ELT_CSV ESCAPE = '\\' FIELD_OPTIONALLY_ENCLOSED_BY = '\"';
Create and update tables
Symon.AI only supports creating and updating tables with a primary key. For duplicate rows with the same primary key value, the latest row record is used. Any rows that have been updated during an export that fails, cannot be reverted. For more information, see Snowflake primary keys.
Using OAuth authentication
If you want to use the OAuth authentication method for connecting Symon.AI to your Snowflake account, you must first create a security integration object.
Important
Only users with the ACCOUNTADMIN
role can create a security integration object. Snowflake does not allow the following roles to log in through OAuth: ACCOUNTADMIN
, SECURITYADMIN
, and ORGADMIN
. Learn more...
Open your Snowflake instance.
In Snowflake, enter the following query to create the security integration object:
CREATE OR REPLACE SECURITY INTEGRATION <name> TYPE=OAUTH OAUTH_CLIENT=CUSTOM OAUTH_REDIRECT_URI='<redirect URI>' OAUTH_CLIENT_TYPE='CONFIDENTIAL' OAUTH_REFRESH_TOKEN_VALIDITY = <1 ~ 90 days in seconds> OAUTH_ISSUE_REFRESH_TOKENS=TRUE ENABLED=TRUE;
Replace the following variables with the correct information for your instance:
Table 27. Snowflake OAuth variablesVariable
Description
Name
Enter the name of the security integration.
Redirect URI
Enter the import redirect URI of the Symon.AI application.
For NA:
https://app.symon.ai/importRedirect
For EU:
https://eu.symon.ai/importRedirect
OAUTH_REFRESH_TOKEN_VALIDITY
Enter the integer that specifies how long the refresh token is valid for in seconds. This value is used to expire the refresh token periodically.
Learn more about creating a security integration.
Caution
Re-running the query with the same security integration name will replace the existing security object. This action will rotate the existing client id and client secret. Any connections tied to the security integration object are no longer valid and the user must edit the Snowflake connection tied to the security integration with a new client id and client secret pair.
Enter the following query to get the client id and secret:
SELECT SYSTEM$SHOW_OAUTH_CLIENT_SECRETS('<security integration name in capital letters>');
This query returns values for
OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, OAUTH_CLIENT_SECRET_2
. You can use eitherOAUTH_CLIENT_SECRET
orOAUTH_CLIENT_SERCRET_2
as your client secret.Note
If the refresh token expires, you must edit the connection and reauthorize. The Client ID and Client Secret can be retrieved with the query in Step 3.
Create the connection
Create the connection between Symon.AI and Snowflake. Generate a new connection or use an existing one.
In Symon.AI, go to your pipe.
Add the Export tool.
In the Export tool configuration section, click the Connection drop-down.
From the Connection drop-down, click + New connection.
Create the new Snowflake connection for the Export tool.
On the Connect to your Data page, enter the following information:
Field
Description
Connector name
The name of the connection.
Snowflake URL
The URL to connect to Snowflake, such as
https://<variable>.snowflakecomputing.com
.Snowflake role
The role in Snowflake.
Warehouse
The name of the Snowflake warehouse your data runs out of.
Database name
The name of the Snowflake database.
Authentication method
Select either the Basic standard authentication method or OAuth authentication method
Basic standard authentication method
Enter your Snowflake username, such as
admin
and password.OAuth authentication method
Enter your OAuth Client ID and Client Secret to connect to your Snowflake connector.
Note
Prior to connecting with OAuth, set up your Snowflake environment with the Security Integration Object.
Click Next.
You are sent back to your pipe page and the Export tool configuration is opened.
In the Export tool configuration panel, enter the following information:
Field
Description
Table name
The name of the table to create or update.
Schema
The schema where the updated table belongs to, or the intended schema for new tables.
File format
The drop-down list of valid file formats where the user can choose from. This list only displays the valid formats that the role has access to.
Note
If you encounter an error, ensure that you have the file format set up correctly. For more information, see Create file format.
Key columns
The drop-down list of columns to select primary key columns from.
Click Export now.
In Symon.AI, go to your pipe.
Add the Export tool.
In the Export tool configuration, click the Connection drop-down.
Search for and select your existing Snowflake export connection.
In the Export tool configuration panel, enter the following information:
Field
Description
Table name
The name of the table to create or update.
Schema
The schema where the updated table belongs to, or the intended schema for new tables.
File format
The drop-down list of valid file formats where the user can choose from. This list only displays the valid formats that the role has access to.
Key columns
The drop-down list of columns to select primary key columns from.
Click Export now.