Automating Snowflake UDF Creation with DataMates
Supademo
In this example we use the knowledge hub to create a guide for LLMs to create Snowflake UDFs.
Walkthrough
-
Overview
In this walkthrough, we'll see how we can use DataMates to automate the creation of Snowflake User-Defined Functions (UDFs) for data validation and formatting tasks. -
Setting Up the Guide
First we'll create an artifact in the knowledge hub. In this example we create a piece of knowledge called "Snowflake UDFs For LLMs". This guide has best practices and coding examples of how to build Snowflake UDFs. It's written in a format to allow coding assistants to grab the context of the guide. -
Prompting Cursor
Next we prompt Cursor with "Create a set of UDFs that validate user emails and phone numbers for my user table in snowflake. Store them in the folder snowflake-udfs" We reference our Guide in the step above by adding the context as a Cursor Doc. -
Generated UDFs
The following UDFs are created with best practices in mind:
UDF Name & Signature | Description |
---|---|
validate_email(email VARCHAR) |
Validates the format of an email address. |
validate_email_domain(email VARCHAR) |
Validates the email and categorizes its domain. |
validate_phone(phone_number VARCHAR) |
Checks the format of a phone number. |
format_phone_number() |
Formats phone numbers according to the specified country code. |
validate_username() |
Validates usernames based on length constraints. |
mask_pii() |
Masks personally identifiable information. |
- Documentation Generation
As a final step, DataMate automatically generates aREADME.md
file summarizing all the created UDFs, providing clear documentation for future reference.
By following these steps, DataMate streamlines the process of building, organizing, and documenting Snowflake UDFs, making it easier for teams to implement robust data validation and formatting logic.