Snowflake: Object tagging

Ivan Jimenez
SDG Group
Published in
5 min readApr 6, 2024
Photo by Angèle Kamp on Unsplash

When we talk about TAGs, normally everybody knows about the meaning of this but a TAG in Snowflake can be used for several interesting purposes including cost monitoring and data classification. These two purposes will be what we will talk about during this post.

Tags enable data stewards to monitor sensitive data for compliance, discovery, protection, and resource usage use cases through either a centralized or decentralized data governance management approach.

Cost Monitoring

One of the purposes of object tagging in Snowflake can be cost management or cost monitoring. It may be that in certain scenarios you want to monitor the cost associated with one or several Snowflake resources that, for example, will be associated with a particular area.
First of all, I want to say that there are several ways to monitor this consumption or cost, and in this article, we are only going to show how it could be done with the use of TAGs in a simple way, but not the only one.
Let’s imagine that we have 2 areas: Marketing and Sales. The marketing area will have 1 associated warehouse of size S. On the other hand, the Sales area will have 2 associated warehouses, one of size S and the other of size L.We will associate the Marketing warehouse with TAG=’MARKETING’ and the two Sales warehouses with TAG=’SALES’.

--tags creation
CREATE TAG COST_MONITORING;


--tag association
ALTER WAREHOUSE WH_S_MARKETING SET TAG COST_MONITORING = 'MARKETING';
ALTER WAREHOUSE WH_S_SALES SET TAG COST_MONITORING = 'SALES';
ALTER WAREHOUSE WH_L_SALES SET TAG COST_MONITORING = 'SALES';

To see the consumption associated with each area:

  • Select the ADMIN>COST MANAGEMENT
  • Switch to the Consumption tab
  • Filter by the account and tag that we want to monitor
Cost Monitoring for MARKETING
Cost Monitoring for SALES

Something important that we will have to take into account will be the latency that the dashboard will have to refresh the information.

Data Classification for Governance

Another purpose for using object tagging will be data classification, something that will greatly help data governance. Snowflake offers the ability to classify data, such as columns that contain sensitive data. To go into more detail about these concepts we can refer to the official Snowflake documentation:

Let’s see a simple example of the classification that Snowflake (using Snowsight) performs for some example tables that we have previously created:

  • Select the Data>Databases
  • Select our database called TEST_DATABASE and schema called SCHEMA_TEST
  • To the left of the Create button, click on the ellipsis
  • Deselect the “Automatically tag data” option and click on “Classify Data”
Classify data
  • Click on “Review Classification”

Here we see an example of the classification that Snowflake has performed for one of the columns, in this case for the CUSTOMER_EMAIL column.

Review Classification
Auto classification

Now we can apply that tag or select another that we consider more appropriate, in the same way, that we can manually classify those columns that Snowflake has not classified, such as CUSTOMER_NAME, and finally, we will apply the tags in “Apply tags and view next table

Manual classification

If we want to replicate this same operation from the Snowflake console and make use of the EXTRACT_SEMANTIC_CATEGORIES function and the stored procedure ASSOCIATE_SEMANTIC_CATEGORY_TAGS. (You can check the link in the References section below).

Finally, to see the columns tagged we will go through the Governance tab inside the Data section:

Columns tagged

Conclusions

As we see, in addition to other purposes, the use of TAGs can facilitate both cost monitoring and data governance. The idea with this post is to bring out one of the many options that Snowflake offers to make our lives easier.
I hope this post helps you and that you can use it for the purpose that best suits your needs.

THANKS!!

Who I am?

I am an enthusiast of new technologies and a data lover. Working with data I feel comfortable and I am always constantly seeking to learn and improve. Currently, I am working as a Data Management Specialist. If you want, you can follow me on LinkedIn.

Linkedin: https://www.linkedin.com/in/iv%C3%A1n-jim%C3%A9nez-s%C3%A1nchez-23496a91/

References

--

--