Skip to content

Instantly share code, notes, and snippets.

@mreid-moz
Created March 15, 2019 14:06
Show Gist options
  • Save mreid-moz/17c9c57edfe91cdea498702be0513e78 to your computer and use it in GitHub Desktop.
Save mreid-moz/17c9c57edfe91cdea498702be0513e78 to your computer and use it in GitHub Desktop.
Using a BigQuery udf from the bq cli
$ cat udf.sql
CREATE TEMP FUNCTION foo(v STRING) AS (
(SELECT concat(v, 'foo'))
);
$ cat bq_test.sql
SELECT os, foo(os) FROM telemetry.clients_daily_v6 WHERE submission_date_s3 = '2019-02-10' LIMIT 3
$ cat udf.sql bq_test.sql | bq query
Waiting on bqjob_r167fb1853f68d6fd_000001694a7a7543_1 ... (0s) Current status: DONE
+------------+---------------+
| os | f0_ |
+------------+---------------+
| Darwin | Darwinfoo |
| Windows_95 | Windows_95foo |
| Windows_NT | Windows_NTfoo |
+------------+---------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment