Week 5 – Basic

This week, we’re using a feature that, at the time of writing, is pretty hot off the press :
Python in Snowflake.

To start out  create a simple table with a single column with a number, the size and amount are up to you, 

After that we’ll start with a very basic function: multiply those numbers by 3.

The challenge here is not ‘build a very difficult python function’ but to build and use the function in Snowflake.

We can test the code with a simple select statement :

SELECT timesthree(start_int)
FROM FF_week_5

Remember if you want to participate:

  1. Sign up as a member of Frosty Friday. You can do this by clicking on the sidebar, and then going to ‘REGISTER‘ (note joining our mailing list does not give you a Frosty Friday account)
  2. Post your code to GitHub and make it publicly available (Check out our guide if you don’t know how to here)
  3. Post the URL in the comments of the challenge.

If you have any technical questions you’d like to pose to the community, you can ask here on our dedicated thread.

18 responses to “Week 5 – Basic”

  1. ChrisHastie avatar
    ChrisHastie

    I’ve just spent two weeks practicing making Python UDFs for a customer, so this was oddly the easiest challenge so far for me!

    Solution URL: https://github.com/ChrisHastieIW/Frosty-Friday/blob/main/Week%205%20-%20Basic%20-%20UDFs/Week%205%20-%20Basic%20-%20UDFs.sql

      1. ChrisHastie avatar
        ChrisHastie

        Reorganised my submission repo, new master solution URL here.

        • Solution URL – https://github.com/ChrisHastieIW/Frosty-Friday
    • dsmdavid avatar
      dsmdavid

      I’m finding it very difficult to format answers in this comment box.

      My approach:
      1. Create a table with a single column

      2. Create a view querying that table that uses an udf

      2.1. Use a pre-hook to create the udf needed in the view.

      dbt-docs: http://dvd-il-bucket-public.s3-website-eu-west-1.amazonaws.com/#!/model/model.frosty.challenge_05_01#code

      • Solution URL – https://github.com/dsmdavid/frostyfridays-sf/blob/main/models/challenge_05_01.sql
    • zlzlzl2 avatar
      zlzlzl2

      My knowledge of Python is minimum, probably need to invest a lot more to make the function more useful.

      • Solution URL – https://github.com/zlzlzl2-data/FrostyFriday/blob/main/FF5_LZ.sql
    • CBoyles avatar
      CBoyles

      Created 2 functions, basic SQL UDF and a Python one as well. In this case, a simple SQL one is simpler as you have less to define.

      • Solution URL – https://github.com/ChrisBBiztory/FrostyFriday/blob/main/Week_5.sql
    • nuova maglia hellas verona 2022

      Week 5 – Basic

    • Isabella avatar
      Isabella

      My solution for week 5

      • Solution URL – https://github.com/isarenz/FrostyFridayChallenges/blob/main/FrostyFriday_Challenge_Week5.sql
    • Atzmonky avatar
      Atzmonky

      Check out Challenge 5 blog: https://theinformationlab.nl/en/2022/09/21/python-udfs-in-snowflake/

      • Solution URL – https://github.com/Atzmonky/snowflake/blob/main/ch_5_UDFs.sql
    • Pekka Kanerva avatar
      Pekka Kanerva

      This was fast one to finish just by using Snowflake docs to get the create function syntax right!

      • Solution URL – https://github.com/pekka-kanerva/frosty-friday/blob/main/week5/ff-week5-solution.sql
    • Jamie Laird avatar
      Jamie Laird

      Here’s my solution, which the docs made very easy!

      • Solution URL – https://github.com/apd-jlaird/frosty-friday/blob/main/week_5/ff_week_5.sql
    • Ben_Connor avatar
      Ben_Connor

      Nice little intro, wasn’t aware you could do this is snowflake. My Solution ^

      • Solution URL – https://github.com/BenAConnor/Frosty_Friday/blob/main/Week%205%20Solution.sql
    • jameskalfox avatar
      jameskalfox

      Solution

      • Solution URL – https://github.com/jameskalfox/frosty-friday-snowflake-challenges/blob/main/Week_05.sql
    • canonicalized avatar
      canonicalized

      Lovely!

      • Solution URL – https://github.com/canonicalized/FrostyFriday/blob/main/WEEK5.sql
    • arjan.loogman avatar
      arjan.loogman

      Nice!!

      • Solution URL – https://github.com/arjansnowflake/Frosty_Friday/blob/main/Week_5/week_5.sql
    • Non-deterministicNorman avatar
      Non-deterministicNorman

      Noice

      • Solution URL – https://github.com/NMangera/frosty_friday/blob/main/wk%205%20-%20basic%20/UDFs
    • mvdvelden avatar
      mvdvelden

      Used the `GENERATOR()` table function with the `ROW_NUMBER()` window function for a dynamic amount of test data!

      https://github.com/marioveld/frosty_friday/tree/main/ffw5

      • Solution URL – https://github.com/marioveld/frosty_friday/tree/main/ffw5

    Leave a Reply