Photo by Aditya Chinchure on Unsplash

Google BigQuery supports user-defined functions (UDFs) written in Javascript as well as SQL, this opens up a whole new world of capabilities that UDFs could provide.

Let’s start by running through some basics for using Javascript in UDFs in BigQuery. The examples here uses standard SQL mode as that’s the preferred syntax.

In the examples below, temporary UDFs are created but this just makes testing and development easier.

Return types

First, a simple Javascript UDF to return a single boolean value:

Next a UDF…

Mark Terry

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store