Creating a Scalar user-defined function using SQL
Snowflake provides capabilities for creating UDFs that can extend the system and perform operations not available out of the box in Snowflake. Snowflake allows two languages for the creation of UDFs, SQL-based UDFs, and JavaScript-based UDFs. Either of the UDF types can return scalar or table results.
In this recipe, we will be walking you through the creation of SQL-based Scalar UDFs and demonstrating how to call the UDFs for various scenarios. A scalar UDF can return a single row of results consisting of a single column, which is essentially equivalent to returning a single value.
Getting ready
You will need to be connected to your Snowflake instance via the web UI or the SnowSQL client to execute this recipe.
How to do it...
We will be creating a series of UDFs to demonstrate the various SQL UDF capabilities provided by Snowflake. We will start by creating a relatively simple UDF and will slowly increase the complexity...