Ok… bear with us a minute. We have a few requirements with this one. We are very worried about clustering depth this week, and so we need to build a DAG of tasks that will monitor this.
Create the following table:
create or replace table cluster_depth_monitoring (
database_name varchar,
sceham_name varchar,
table_name varchar,
clustering_depth float,
inserted_at timestamp,
inserted_by varchar
);
We want a DAG like the one above where:
CM_IDENTIFY_TABLES:
- Identify the tables in your database that are clustered
- Create a transient table with this information
CM_INSERT_DETAILS
- Execute a Snowpark stored procedure that examines the clustering depth of each of those tables
- Inserts the result into the
cluster_depth_monitoring
table
CM_CLEAN_UP
- Drops the transient table created by CM_IDENTIFY_TABLES
Importantly, we want all these tasks to tag the queries with ‘cluster_depth_monitoring’
If you need a db to use
The above DB has clustered tables, I would recommend perhaps editing the db name, though…
alter database SFSALESSHARED_SFC_SAMPLES_AWS_EU_WEST_2_SAMPLE_DATA rename to SNOWFLAKE_SAMPLE_DATA;
Note that the name might appear different in your account, and that, depending on your account’s permission structures, you may need ACCOUNTADMIN to add this db.
Your end result ought to look something like this:
Remember, if you want to participate:
- Sign up as a member of Frosty Friday. You can do this by clicking on the sidebar, and then going to ‘REGISTER‘
- Post your code to GitHub and make it publicly available (Check out our guide if you don’t know how to here)
- Post the URL in the comments of the challenge
2 responses to “Week 33 – Hard”
-
That was a fun one, thanks!
- Solution URL – https://github.com/ChrisHastieIW/Frosty-Friday
-
Well that *was* hard. This blog was a huge help – thank you CH. https://interworks.com/blog/2022/08/16/a-definitive-guide-to-python-stored-procedures-in-the-snowflake-ui/
- Solution URL – https://github.com/apd-jlaird/frosty-friday/blob/main/week_33/ff_week_33.sql
Leave a Reply
You must be logged in to post a comment.