Snowflake

Install Snowflake Driver

Follow the steps here about how to install new database drivers when setting up Superset locally via docker compose.

  1. echo "snowflake-sqlalchemy" >> ./docker/requirements-local.txt

The recommended connector library for Snowflake is snowflake-sqlalchemy.

The connection string for Snowflake looks like this:

  1. snowflake://{user}:{password}@{account}.{region}/{database}?role={role}&warehouse={warehouse}

The schema is not necessary in the connection string, as it is defined per table/query. The role and warehouse can be omitted if defaults are defined for the user, i.e.

  1. snowflake://{user}:{password}@{account}.{region}/{database}

Make sure the user has privileges to access and use all required databases/schemas/tables/views/warehouses, as the Snowflake SQLAlchemy engine does not test for user/role rights during engine creation by default. However, when pressing the “Test Connection” button in the Create or Edit Database dialog, user/role credentials are validated by passing “validate_default_parameters”: True to the connect() method during engine creation. If the user/role is not authorized to access the database, an error is recorded in the Superset logs.

And if you want connect Snowflake with Key Pair Authentication. Please make sure you have the key pair and the public key is registered in Snowflake. To connect Snowflake with Key Pair Authentication, you need to add the following parameters to “SECURE EXTRA” field.

Please note that you need to merge multi-line private key content to one line and insert \n between each line

  1. {
  2. "auth_method": "keypair",
  3. "auth_params": {
  4. "privatekey_body": "-----BEGIN ENCRYPTED PRIVATE KEY-----\n...\n...\n-----END ENCRYPTED PRIVATE KEY-----",
  5. "privatekey_pass":"Your Private Key Password"
  6. }
  7. }

If your private key is stored on server, you can replace “privatekey_body” with “privatekey_path” in parameter.

  1. {
  2. "auth_method": "keypair",
  3. "auth_params": {
  4. "privatekey_path":"Your Private Key Path",
  5. "privatekey_pass":"Your Private Key Password"
  6. }
  7. }