From the course: Intro to Snowflake for Devs, Data Scientists, Data Engineers
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
User-defined table functions (UDTFs) - Snowflake Tutorial
From the course: Intro to Snowflake for Devs, Data Scientists, Data Engineers
User-defined table functions (UDTFs)
- We've learned about user-defined functions, which are great, but have the limitation that you can only return a single value, no more, no less. Now we're going to learn about the elder sibling to UDFs. User-defined table functions UDTFs, which return a table that can have multiple rows and multiple columns. Once you understand UDFs, UDTFs aren't that much harder to grasp. Let's work from the first UDF we made and convert it into a UDTF so the output can be a bit more flexible. So that first UDF we made was this max menu price function. Now instead of just finding the max price, let's find all menu items above a certain price that we specify when we call the function. We'll call this UDTF menu prices above. To change our earlier UDF to our new UDTF, we need to do four things. First, change the name. Let's make it menu prices above. Second, give it an argument. We'll call this price floor and make it a number. Third, change the content of the query so that it does the new thing we…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.