You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- SET YOUR DESIRED BQ REGION BELOWSET @@location="us-east4";
/********************************** * DO NOT EDIT SQL BELOW THIS LINE **********************************/
DECLARE YOUR_PROJECT_ID STRING DEFAULT(@@project_id);
DECLARE YOUR_REGION STRING DEFAULT(@@location);
DECLARE region_suffix STRING DEFAULT(
IF(YOUR_REGION="US", "", "_"|| REPLACE(YOUR_REGION, "-", "_"))
);
-- Get regional UDFs
DECLARE cw_udf_ddls ARRAY<STRING>;
EXECUTE IMMEDIATE
FORMAT(""" SELECT ARRAY_AGG(ddl ORDER BY created) AS cw_udf_ddls FROM bqutil.fn%s.INFORMATION_SCHEMA.ROUTINES WHERE specific_name LIKE "cw_%%"""",
region_suffix
)
INTO cw_udf_ddls;
-- Creates the fn dataset within your project
EXECUTE IMMEDIATE "CREATE SCHEMA IF NOT EXISTS "|| YOUR_PROJECT_ID ||".fn"|| region_suffix;
-- Creates all cw_* UDFs within your new fn dataset
FOR cw_udf_ddl IN (SELECT*FROM UNNEST(cw_udf_ddls) ddl)
DO EXECUTE IMMEDIATE REPLACE(REPLACE(cw_udf_ddl.ddl, "bqutil", YOUR_PROJECT_ID), "CREATE ", "CREATE OR REPLACE ");
END FOR;
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: