我已使用此示例代码在Big Query的聚合数据上编写函数。
CREATE TEMP FUNCTION aggregate_fruits(fruits ARRAY<STRING>)
RETURNS STRING
LANGUAGE js AS """
return "my fruit bag contains these items: " + fruits.join(",");
""";
WITH fruits AS
(SELECT "apple" AS fruit
UNION ALL SELECT "pear" AS fruit
UNION ALL SELECT "banana" AS fruit)
SELECT aggregate_fruits(ARRAY_AGG(fruit))
FROM fruits;
This已被用作参考。但是查询花费更多时间才能首先定义函数然后运行查询。是否可以只定义一次函数,然后对多个查询使用相同的函数?
当我尝试删除&#34; TEMP&#34;时,BigQuery说这个错误上面的关键字Error: Only temporary functions are currently supported; use CREATE TEMPORARY FUNCTION