在BigQuery中定义永久用户定义函数以聚合结果

时间:2017-12-07 13:59:14

标签: google-bigquery aggregate-functions user-defined-functions permanent

我已使用此示例代码在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

0 个答案:

没有答案