Quickstart for GX Cloud and Snowflake
In this quickstart, you'll learn how to connect GX Cloud to Snowflake Data Assets.
Prerequisites
You have a GX Cloud Beta account.
You have a Snowflake account with USAGE privileges on the table, database, and schema you are validating, and you know your password.
You have a Docker instance.
Generate your user access token and copy your organization ID
You'll need your user access token and organization ID to set your environment variables. Access tokens shouldn't be committed to version control software.
In GX Cloud, click Settings > Tokens.
In the Access tokens pane, click Create user access token.
Complete the following fields:
Token name - Enter a name for the token that will help you quickly identify it.
Role - Select Admin. For more information about the available roles, click Information (?).
Click Create.
Copy and then paste the user access token into a temporary file. The token can't be retrieved after you close the dialog.
Click Close.
Copy the value in the Organization ID field into the temporary file with your user access token and then save the file.
GX recommends deleting the temporary file after you set the environment variables.
Set the environment variables and start the GX Cloud agent
Environment variables securely store your GX Cloud and Snowflake access credentials. The GX Cloud agent runs open source GX code in GX Cloud, and it allows you to securely access your data without connecting to it or interacting with it directly.
Start the Docker Engine.
Run the following code to set the
GX_CLOUD_ACCESS_TOKEN
,GX_CLOUD_ORGANIZATION_ID
, andGX_CLOUD_SNOWFLAKE_PASSWORD
environment variables, install GX Cloud and its dependencies, and start the GX Cloud agent:Terminal inputdocker run --rm -e GX_CLOUD_ACCESS_TOKEN="<user_access_token>" -e GX_CLOUD_ORGANIZATION_ID="<organization_id>" -e GX_CLOUD_SNOWFLAKE_PASSWORD="<snowflake_password>" greatexpectations/agent
Replace
user_access_token
,organization_id
, andsnowflake_password
with your own values.Optional. If you created a temporary file to record your user access token and Organization ID, delete it.
Optional. Run
docker ps
or open Docker Desktop to confirm the agent is running.If you stop the GX Cloud agent, close the terminal, and open a new terminal you'll need to set the environment variables again.
To edit an environment variable, stop the GX Cloud agent, edit the environment variable, save the change, and then restart the GX Cloud agent.
Create the Snowflake Data Asset
Create a Data Asset to define the data you want GX Cloud to access within Snowflake.
In GX Cloud, click Data Assets > New Asset.
Click the New Data Source tab and then select Snowflake.
Enter a meaningful name for the Data Asset in the Data Source name field.
Optional. To use a connection string to connect to a Data Source, click the Use connection string selector, enter a connection string, and then move to step 6.
Complete the following fields:
Username: Enter your Snowflake username.
Account identifier: Enter your Snowflake account or locator information. The locator value must include the geographical region. For example,
us-east-1
. To locate these values see Account Identifiers.Password/environment variable: Enter
${GX_CLOUD_SNOWFLAKE_PASSWORD}
. If you haven't set this variable, see Set up GX Cloud.Database: Enter the name of the Snowflake database where the data you want to validate is stored.
Schema: Enter the name of the schema for the Snowflake database where the data you want to validate is stored.
Warehouse: Enter the name of the Snowflake database warehouse.
Role: Enter your Snowflake role.
Optional. Select Test connection if you want to test the Data Asset connection. Testing the connection to the Data Asset is a preventative measure that makes sure the connection configuration is correct. This verification can help you avoid errors and can reduce troubleshooting downtime.
Click Continue.
Select Table Asset or Query Asset and complete the following fields:
Table name: When Table Asset is selected, enter a name for the table you're creating in the Data Asset.
Data Asset name: Enter a name for the Data Asset. Data Asset names must be unique. If you use the same name for multiple Data Assets, each Data Asset must be associated with a unique Data Source.
Query: When Query Asset is selected, enter the query that you want to run on the table.
Select the Complete Asset tab to provide all Data Asset records to your Expectations and validations, or select the Batches tab to use subsets of Data Asset records for your Expectations and validations. If you selected the Batches tab, complete the following fields:
Split Data Asset by - Select Year to partition Data Asset records by year, select Year - Month to partition Data Asset records by year and month, or select Year - Month - Day to partition Data Asset records by year, month, and day.
Column of datetime type - Enter the name of the column containing the date and time data.
Optional. Select Add Data Asset to add additional tables or queries and repeat steps 8 and 9.
Click Finish.
Add an Expectation
An Expectation is a verifiable assertion about your data. They make implicit assumptions about your data explicit.
In the Data Assets list, click the Snowflake Data Asset name.
Click New Expectation.
Select an Expectation type, enter the column name, and then complete the optional fields.
If you prefer to work in a code editor, click the JSON Editor tab and define your Expectation parameters in the code pane.
Click Save.
Optional. Repeat steps 1 to 4 to add additional Expectations.
Validate Expectations
Click Validate.
When the confirmation message appears, click See results, or click the Validations tab.