From the course: Snowpark for Data Engineers

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Creating anonymous UDFs in Snowpark

Creating anonymous UDFs in Snowpark - Snowflake Tutorial

From the course: Snowpark for Data Engineers

Creating anonymous UDFs in Snowpark

- [Instructor] User defined functions or UDFs in Snowflake are custom functions created by users to perform specific operations that are not available via built-in functions. Most data warehouses support creating UDFs using SQL queries. Snowflake allows you to use Snowpark APIs to create and register UDFs that you can use from within Python code as well as from within your SQL queries. Snowflake supports two types of UDFs, an anonymous UDF or a named UDF. An anonymous UDF is essentially a function that you assign to a variable. As long as this variable is in scope, you can use this variable to invoke the UDF. We'll first see how anonymous UDFs work before we move on to named UDFs. Here within my Python worksheet, I've set up a Snowpark handler that is the main function, which takes in a session as an input argument. On line eight, I've used the UDF function to register a UDF. This function creates a UDF by taking in a reference to a Python function or to a lambda. I've specified a…

Contents