Reputation: 133
I was trying to use a user defined query in web big query UI. According to documentation, https://cloud.google.com/bigquery/sql-reference/user-defined-functions, I did this step by step.
Codes below are the same as https://cloud.google.com/bigquery/sql-reference/user-defined-functions
CREATE TEMPORARY FUNCTION timesTwo(x INT64)
RETURNS INT64
LANGUAGE js AS """
return x*2;
""";
3. Below the UDF statement, type your query.
SELECT timesTwo(numbers) as doubles
FROM UNNEST([1, 2, 3, 4, 5]) AS numbers;
Then I clicked Run Query but gives me error like this
Not Implemented: UDFs are currently only supported for legacy SQL queries.
Is it because of the legacy SQL option? But I unchecked it as the document says.
Upvotes: 2
Views: 172
Reputation: 172964
Scalar UDF (in Standard more) is a "part" of query, thus all needs to be put in Query Editor (no UDF Editor needed here)
CREATE TEMPORARY FUNCTION timesTwo(x INT64)
RETURNS INT64
LANGUAGE js AS """
return x*2;
""";
SELECT timesTwo(numbers) as doubles
FROM UNNEST([1, 2, 3, 4, 5]) AS numbers;
Upvotes: 2