JavaScript UDFs (user-defined functions) allow you to write JavaScript functions and invoke them from your SQL query. They come in handy when you want to perform certain operations on your data and the set of built-in SQL functions do not meet your needs.
Two types of JavaScript UDFs are supported:
- Scalar JavaScript UDFs: these are vanilla JavaScript functions that return a single value. These are the most common ones.
- Tabular JavaScript UDFs: these are JavaScript functions that return iterables and can be used as SQL table functions that produce rows. These UDFs can only be used as part of the
FROM
clause in your SQL query.
JavaScript UDFs are supported in your SQL queries, Query Lambdas, and SQL ingest transformation. They are not supported in Views just yet. JavaScript UDFs to define custom Aggregate or Window functions are not supported yet. JavaScript UDFs are only available on dedicated Virtual Instances.