bigquery-etl/bigquery_etl/glam/templates/scalar_percentiles_v1.udf.sql

19 строки
427 B
SQL

CREATE TEMP FUNCTION udf_get_values(required ARRAY<FLOAT64>, VALUES ARRAY<FLOAT64>)
RETURNS ARRAY<STRUCT<key STRING, value FLOAT64>> AS (
(
SELECT
ARRAY_AGG(record)
FROM
(
SELECT
STRUCT<key STRING, value FLOAT64>(
CAST(k AS STRING),
VALUES
[OFFSET(CAST(k AS INT64))]
) AS record
FROM
UNNEST(required) AS k
)
)
);