Views can reference UDF resources stored in Google Cloud Storage, inline code blobs, or local files (contents will be loaded into inline code blobs).

To create a view with a UDF using the BigQuery UI, just fill out the UDF resources as you would when running the query normally, and save as a view. (In other words, no special actions are required).

To specify these during view creation from the command-line client, use the --view_udf_resource flag:

bq mk --view="SELECT foo FROM myUdf(table)" \ --view_udf_resource="gs://my-bucket/my-code.js"

In the above example, gs://my-bucket/my-code.js would contain the definition for myUdf() . You can provide multiple --view_udf_resources flags if you need to reference multiple code files in your view query.

You may specify gs:// URIs or local files. If you specify a local file, then the code will be read once and packed into an inline code resource.