I have used this sample code to write functions on the aggregated data from 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 has been used as a reference. But the query is taking more time in order to first define the function and then run the query. Is it possible to define the function only once and then use the same function for multiple queries ?
BigQuery says this error when I tried removing "TEMP" keyword from the above
Error: Only temporary functions are currently supported; use CREATE TEMPORARY FUNCTION