Week 45 - Snowpark & Python
This week we're creating permanent UDFs via Snowpark and giving them a whiz!
Run this in the Snowflake console
CREATE OR REPLACE TABLE website_clicks (id INTEGER,user_id INTEGER,page_url STRING,click_time TIMESTAMP,click_location STRING);INSERT INTO website_clicks VALUES (1, 101, 'https://www.example.com/home', '2023-05-12 08:00:00', '<div id="header" class="header">');INSERT INTO website_clicks VALUES (2, 102, 'https://www.example.com/products', '2023-05-12 08:05:00', '<main class="content">');INSERT INTO website_clicks VALUES (3, 101, 'https://www.example.com/about', '2023-05-12 08:10:00', '<footer class="site-footer">');INSERT INTO website_clicks VALUES (4, 103, 'https://www.example.com/home', '2023-05-12 08:15:00', '<section class="main-content">');INSERT INTO website_clicks VALUES (5, 102, 'https://www.example.com/contact', '2023-05-12 08:20:00', '<header class="site-header">');- Download this file
- Place that file into an internal stage
- Create a UDF from that stage called
exctract_class_value - Run the below code and check that you've done it correctly
clean_data = (session.table("website_clicks").withColumn("click_location",call_udf("extract_class_value", col("click_location"))))P.S. I'll be speaking about all things Snowpark at a panel discussion at Summit!

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