I have been looking into how to write a UDF in BigQuery and found this syntax:
CREATE { TEMPORARY | TEMP } FUNCTION
function_name ([named_parameter[, ...]])
[RETURNS data_type]
{ [LANGUAGE language AS """body"""] | [AS (function_definition)] };
In the document I found, there is no clear mention of what languages are supported. In the examples given in the page, it only talks about "js" and I can't find any other language examples so I presume it only supports JavaScript but I am wondering whether anyone knows for sure.
Python UDFs (user-defined functions) allow you to write Python code and call it as though it were a SQL function.
A user-defined function (UDF) lets you create a function by using a SQL expression or JavaScript code. A UDF accepts columns of input, performs actions on the input, and returns the result of those actions as a value. You can define a UDFs as either persistent or temporary.
In Python, def keyword is used to declare user defined functions. An indented block of statements follows the function name and arguments which contains the body of the function.
Calling persistent user-defined functions (UDFs)After creating a persistent UDF, you can call it as you would any other function, prepended with the name of the dataset in which it is defined as a prefix. To call a UDF in a project other than the project that you are using to run the query, project_name is required.
From that same page:
External UDFs support code written in JavaScript, which you specify using
js
as theLANGUAGE
.
You can't use languages other than JavaScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With