BigQuery: User-Defined Functions to supercharge your SQL

CREATE [OR REPLACE] [TEMPORARY | TEMP] FUNCTION [IF NOT EXISTS]
[[`project_name`.]dataset_name.]function_name
([named_parameter[, ...]])
[RETURNS data_type]
#Example
(userAge INT64)
#Multi value example
(userAge INT64, gender STRING)
AS (sql_expression/logic/js)#Google's example 
CREATE TEMP FUNCTION
addFourAndDivideAny(x ANY TYPE,
y ANY TYPE) AS ( (x + 4) / y );
SELECT
addFourAndDivideAny(3 /*x*/ ,3 /*y*/ ) AS integer_output
(SELECT VALUE.INT_VALUE FROM UNNEST(EVENT_PARAMS) WHERE KEY = 'CCC') 
CREATE FUNCTION  UDFS.ga4_firebase
SELECT bqutil.fn.udf_name(variable)

--

--

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