我试图在web大查询UI中使用用户定义的查询。根据文档https://cloud.google.com/bigquery/sql-reference/user-defined-functions,我一步一步地做了这件事。
以下代码与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。在UDF语句下方,键入您的查询。
SELECT timesTwo(numbers) as doubles
FROM UNNEST([1, 2, 3, 4, 5]) AS numbers;
然后我点击了运行查询但是给了我这样的错误
Not Implemented: UDFs are currently only supported for legacy SQL queries.
是否因为遗留SQL选项?但正如文件所说,我取消了它。
答案 0 :(得分:2)
标量UDF(标准中更多)是"部分"查询,因此所有需要放在查询编辑器(这里不需要UDF编辑器)
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;