Skip to content

Snowflake

Snowflake is a cloud based data warehouse that uses SQL as its query language. You can learn more about it by reading its key concepts here.

The basic configuration for the snowflake provider is as follows:

1
<script src="./CFT-snowflake-provider.min.js"></script>
1
2
3
4
5
6
7
8
9
// define providers
var providers = [{
    name: "Snowflake",
    provider: "snowflake",
    account: "account-id",
}]

// Inject the provider to Toolkit
cf.setProviders(providers);

The parameters above are required. It also accepts the warehouse and the role.

Authentication

The Snowflake provider requires user and password for authentication. These credentials can be specified in two ways:

Static credentials

The easiest way is to directly specify the user and password in the provider configuration:

1
2
3
4
5
6
7
// define providers
var providers = [{
    ...
    user: "username",
    password: "my-password",
    ...
}]

This way the provider will read the credentials directly from the configuration without any user interaction. The main drawback of this method is that the credentials can be read by anyone. Therefore, we recommend to use this method only in restricted access environments.

This method works in node and web browser environments.

Authentication window

When credentials are not specified statically, the Snowflake provider renders a modal for users to enter their credentials as shown below. This second method works only on web browsers and desktop applications.

Source names structure

Similar to Dremio and Google Bigquery providers, Snowflake keeps the datasources (tables) in a nested structure that is composed by Database, then Schema, then Table.

1
2
cf.provider('Snowflake')
.source("DB_NAME.SCHEMA_1.MY_TABLE")

Databases, schemas and table names usually should not contain blank spaces altough Snowflake allows to have them if the name is enclosed in doble quotes. Same rule applies for ChartFactor Toolkit if you are going to use them:

1
2
cf.provider('Snowflake')
.source('DB_NAME."SCHEMA 2".OTHER_TABLE')

Supported Aggregations Out-Of-The-Box

SUM

1
    var metric = cf.Metric("amount","sum");

AVG

1
    var metric = cf.Metric("amount","avg");

MIN

1
    var metric = cf.Metric("amount","min");

MAX

1
    var metric = cf.Metric("amount","max");

COUNT DISTINCT

1
    var metric = cf.Metric("my_attribute","unique");

PERCENTILES

1
    var metric = cf.Metric('commission', 'percentiles');

Dependencies

  • None