From the course: Introduction to Modern Data Engineering with Snowflake

Unlock this course with a free trial

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

Computations with user-defined functions

Computations with user-defined functions

Naturally, it's not very scalable to perform data transformations manually every single time. And as I mentioned earlier, there's a good chance that in practice, you'll work with a very large number of tables, so it's a lot more practical to find ways to capture logic in reusable chunks of code. This approach makes it easy to manage chunks of logic in a centralized fashion, meaning you can ensure consistency in the pipelines that you build. One way of doing this is with user-defined functions, also known as UDFs. With a user-defined function, you can write your own custom logic and reuse it over and over in your queries and data transformations. Typically, UDFs are used to capture logic that perform a specific computation. Say I need to perform a calculation that returns a value given some inputs. Or if I need to format a value like a telephone number in a certain way, for example, a user-defined function would be the perfect Snowflake primitive to capture that logic so that I can…

Contents