Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigQuery UDF in Python or only in JavaScript

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.

like image 696
kee Avatar asked Aug 17 '18 17:08

kee


People also ask

Can we use UDF in Python?

Python UDFs (user-defined functions) allow you to write Python code and call it as though it were a SQL function.

What is UDF in BigQuery?

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.

How do you call a user defined function in Python?

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.

How do you call a function in BigQuery?

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.


1 Answers

From that same page:

Supported external UDF languages

External UDFs support code written in JavaScript, which you specify using js as the LANGUAGE.

You can't use languages other than JavaScript.

like image 124
Elliott Brossard Avatar answered Sep 29 '22 04:09

Elliott Brossard