# Using Password Authentication

## Before you start

To connect Snowflake to Select Star, you will need:

* Admin access to your Snowflake instance via the `ACCOUNTADMIN` role.

Complete the following steps to enable metadata, lineage, and popularity for your Snowflake data in Select Star.

1. [Create a Select Star role and user in Snowflake](#id-1.-create-select-star-user-in-snowflake)
2. [Grant optional permissions](#id-2.-grant-optional-permissions)
3. [Connect Snowflake to Select Star](#id-3.-connect-snowflake-to-select-star)
4. [Choose databases and schemas](#id-4.-choose-databases-and-schemas)

## 1. Create Select Star user in Snowflake

Log in to Snowflake. Using the `ACCOUNTADMIN` role, execute the following SQL:

```sql
-- Required for basic metadata & query history access
create role selectstar_role;
grant imported privileges on database snowflake to role selectstar_role;
create user selectstar password='s313ctst8r' default_role='selectstar_role' type='LEGACY_SERVICE';
grant role selectstar_role to user selectstar;
grant usage on warehouse MED to selectstar_role;
```

{% hint style="info" %}
These are the minimum permissions required for Select Star to collect basic metadata and query history. Query history is also used to generate lineage.
{% endhint %}

## 2. Grant optional permissions

To enable Select Star’s **Preview** feature and access additional metadata—such as **Primary Keys (PK)** and **Foreign Keys (FK)** —you’ll need to grant the following permissions.

Using the `ACCOUNTADMIN` role, execute the following SQL for each database you want to ingest (example uses `DWH` as the database name):

```sql
use role ACCOUNTADMIN;
grant usage on database DWH to role selectstar_role;
grant usage on all schemas in database DWH to role selectstar_role;
grant select on all tables in database DWH to role selectstar_role;
grant select on all views in database DWH to role selectstar_role;
grant usage on future schemas in database DWH to role selectstar_role;
grant select on future tables in database DWH to role selectstar_role;
grant select on future views in database DWH to role selectstar_role;
```

{% hint style="info" %}
If the latency of updates in `ACCOUNT_USAGE` is too high for your needs (see [Snowflake documentation on data latency](https://docs.snowflake.com/en/sql-reference/account-usage#data-latency)), you can switch to `INFORMATION_SCHEMA` instead, providing faster updates in the UI.
{% endhint %}

#### Enhanced Lineage for Dynamic Tables

To see **lineage for dynamic tables**, we recommend granting permission to **read dynamic table definitions**. Without this, lineage can only be inferred from query logs, which may not be fully reliable.

Using the `ACCOUNTADMIN` role, execute the following SQL for each database you want to ingest (example uses `DWH` as the database name):

```sql
use role ACCOUNTADMIN;
grant usage on database DWH to role selectstar_role;
grant usage on all schemas in database DWH to role selectstar_role;
grant monitor on all dynamic tables in database DWH to role selectstar_role;
grant monitor on future dynamic tables in database DWH to role selectstar_role;
```

{% hint style="success" %}
If you're granting these permissions after your Snowflake metadata has already been synced, you'll need to re-sync it.

1. Go to **Settings > Data**
2. Click on **Sync metadata** on your Snowflake Data source.
   {% endhint %}

## 3. Connect Snowflake to Select Star

Go to the Select Star **Settings**. Click **Data** in the sidebar, then **+ Add** to create a new Data Source.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-1b5ef3716637dedbfa0eb69326a83270b0773b0b%2FAdd_Data_Source_Settings.gif?alt=media)

Choose **Snowflake** in the Source Type dropdown and provide the following information:

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-eaccd28498c9b3450c2ac45669a66a4eae72a289%2Fsnowflake-1.png?alt=media)

* **Display Name:** This value is `Snowflake` by default, but you can override it if desired.
* **Account:** The account name is the name to the left of `snowflakecomputing.com` when you log in to Snowflake.
* **Role:** The role you granted the service account user. In the example above, it is `selectstar_role`
* **Warehouse:** The name of the data warehouse you've given us access to. In the example above it is `MED`

Click **Save** and fill in the Authentication Details:

* **Authentication:** Select **Password**.
* **Username:** The name of the service account user you created. In the example above, it is `selectstar`
* **Password:** The password for the service account user you created. In the example above, it is `s313ctst8r`

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-0be4be9c41d90f06bdccde352dedb2373c4b0cd7%2Fsnowflake-3.png?alt=media)

## 4. Choose databases and schemas

After you fill in the information, you'll be asked to select the databases you'd like to load into Select Star.

{% hint style="info" %}
Select Star will not read queries or metadata or generate lineage for databases, schemas, or tables that are not loaded. Please load all data for which you expect to see lineage.

You can [change the databases and schemas](https://docs.selectstar.com/data-source-management/manage-data-sources#configure-a-data-source) you have loaded if needed.
{% endhint %}

Select the database and click **Next**.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-7a2b6f22780956a34298382de4cbae404a0113ed%2FScreen%20Shot%202021-11-11%20at%203.25.49%20PM.png?alt=media)

For each database you selected, you'll be able to select the schemas.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-f39bf07760f525c2fe54eeb25b543181eceb90a9%2FScreen%20Shot%202021-11-11%20at%203.26.35%20PM.png?alt=media)

Your metadata should start loading automatically. Please allow 24-48 hours to completely generate popularity and lineage.

When the sync is complete, you'll be able to explore Snowflake in Select Star. See the link below for more information on Snowflake in Select Star.

{% content-ref url="../../learning-data/getting-started-snowflake" %}
[getting-started-snowflake](https://docs.selectstar.com/learning-data/getting-started-snowflake)
{% endcontent-ref %}
