# Snowflake Tag Sync

You have the option of syncing [Tags](https://docs.selectstar.com/features/tags#filter) created in Select Star back to Snowflake. It will sync status and category tags for both tables and columns. Suggested tags will also be synced.

## Enable Snowflake Tag Sync in Select Star

### 1. Create a custom Tag role in Snowflake

First, you will need to create a custom role and give it access to create and apply tags.

<pre class="language-sql"><code class="lang-sql">-- Create tag_admin role
USE ROLE USERADMIN;
CREATE ROLE tag_admin;
GRANT ROLE tag_admin TO USER &#x3C;select_star_user>;


-- Enable tag creation and assignment
USE ROLE ACCOUNTADMIN;
-- &#x3C;db_name>.&#x3C;schema_name> will be where Select Star 
GRANT CREATE TAG ON SCHEMA &#x3C;db_name>.&#x3C;schema_name> TO ROLE tag_admin;
GRANT APPLY TAG ON ACCOUNT TO ROLE tag_admin;

-- Grant usage
GRANT USAGE ON DATABASE &#x3C;db_name> TO ROLE tag_admin;
<strong>GRANT USAGE ON SCHEMA &#x3C;db_name>.&#x3C;schema_name> TO ROLE tag_admin;
</strong></code></pre>

You can find more detailed instructions in Snowflake's documentation [here](https://docs.snowflake.com/en/user-guide/object-tagging.html#step-1-create-a-custom-role-and-assign-privileges).

### 2. Authorize Tag Sync in Select Star

To enable Snowflake Tag Sync in Select Star

1. Go to **Settings**.
2. Choose the **Snowflake data source** in the sidebar.
3. Click the **Snowflake Tag Sync** tab.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-13e10ecdcdc0beec29c65af0c2392f4822af24ec%2Fsnowflake_tag_sync.gif?alt=media\&token=328e4b24-a72d-452b-8a14-1e48104826ab)

4. Click the **Enable Tag Sync** button.

![Snowflake Tag Sync tab in Select Star Settings.](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-5be6e8711200f593bb2e565127371640c4288575%2FScreen%20Shot%202021-11-15%20at%2011.01.05%20AM.png?alt=media\&token=9b97b2d2-47c5-4e98-82da-d4b5c1a1a17e)

5. Enter the **Role name** of the role you created in [step 1](#1.-create-a-custom-tag-role-in-snowflake) of this guide (`tag_admin` in our example).
6. Enter the **Database Name** and **Schema Name** where Select Star should create Snowflake Tags.
7. Click **Connect**.

<figure><img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-4ad143310d5b605eba91ecb9106092ff0c15565f%2FCleanShot%202023-06-02%20at%2020.57.04%402x.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

Select Star will be able to use this role with the credentials you added when you connected Snowflake as outlined in our [Snowflake Setup Guide](https://docs.selectstar.com/integrations/snowflake).

You will first see a message indicating that the Sync is in progress. Once the sync is done, we'll indicate that the tags were synced successfully.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-78c078290421306f8fbc7b17cf711057a64b8a0f%2FCleanShot%202023-06-02%20at%2020.59.00%402x.png?alt=media) ![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-e4de7307d192ec46b1b513a46bc002e006cc4193%2FCleanShot%202023-06-02%20at%2020.59.21%402x.png?alt=media)

{% hint style="info" %}
Please note: It can take a few hours for tags to update in Snowflake's `tag_references` view.
{% endhint %}

{% hint style="danger" %}
You can disable tags at any time by clicking the Disable Tags Sync button.

Disabling tags will delete all tags created by Select Star from your Snowflake instance.
{% endhint %}

## Select Star tags in Snowflake

When Snowflake Tag Sync is enabled, any Tags created in Select Star will be visible in Snowflake.

Select Star tags will have `SELECT_STAR_CATEGORY` (for Category) or `SELECT_STAR_STATUS` (for Status) prepended in the `TAG_NAME` field. The value of the tag is left empty.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-b8803af52c630e7da1ed837f914dc0903316ee18%2FCleanShot%202023-06-02%20at%2021.05.55%402x.png?alt=media) ![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-441ffcc504b25212f5f948753680d013a37fed06%2FIMAGE%202023-06-02%2021%3A10%3A54.jpg?alt=media)

**Example**: If you had a Sales Tag in Select Star created as a Category tag. The Snowflake tag created would be called `SELECT_STAR_CATEGORY_SALES`.

{% hint style="info" %}
Note: Currently, you can only sync tags from Select Star to Snowflake, and not the other way around. This is to prevent the tools from overwriting each other.
{% endhint %}

{% hint style="danger" %}
Tag names in Select Star must follow Snowflake's [identifier requirements](https://docs.snowflake.com/en/sql-reference/identifiers-syntax) in order to be synced to Snowflake. Spaces in tag names will be automatically replaced with an underscore.
{% endhint %}
