Google BigQuery Routine

This page shows how to write Terraform for BigQuery Routine and write them securely.

google_bigquery_routine (Terraform)

The Routine in BigQuery can be configured in Terraform with the resource name google_bigquery_routine. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub
resource "google_bigquery_routine" "IP_FROM_CIDR_STRING" {
  project      = var.logs_project_id
  dataset_id   = var.dataset_name
  routine_id   = "IP_FROM_CIDR_STRING"
  language     = "SQL"
  routine_type = "SCALAR_FUNCTION"
resource "google_bigquery_routine" "my_sum_udf" {
  project         = var.project
  dataset_id      = google_bigquery_dataset.dataset.dataset_id
  routine_id      = "my_sum"
  routine_type    = "SCALAR_FUNCTION"
  //  language        = "SQL"


  • creation_time requiredcomputed - number
    • The time when this routine was created, in milliseconds since the epoch.

  • dataset_id required - string
    • The ID of the dataset containing this routine

  • definition_body required - string
    • The body of the routine. For functions, this is the expression in the AS clause. If language=SQL, it is the substring inside (but excluding) the parentheses.

  • description optional - string
    • The description of the routine if defined.

  • determinism_level optional - string
    • The determinism level of the JavaScript UDF if defined. Possible values: ["DETERMINISM_LEVEL_UNSPECIFIED", "DETERMINISTIC", "NOT_DETERMINISTIC"]

  • id optionalcomputed - string
  • imported_libraries optional - list / string
    • Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries.

  • language optional - string
    • The language of the routine. Possible values: ["SQL", "JAVASCRIPT"]

  • last_modified_time requiredcomputed - number
    • The time when this routine was modified, in milliseconds since the epoch.

  • project optionalcomputed - string
  • return_type optional - string
    • A JSON schema for the return type. Optional if language = "SQL"; required otherwise. If absent, the return type is inferred from definitionBody at query time in each query that references this routine. If present, then the evaluated result will be cast to the specified returned type at query time. ~>NOTE: Because this field expects a JSON string, any changes to the string will create a diff, even if the JSON itself hasn't changed. If the API returns a different value for the same schema, e.g. it switche d the order of values or replaced STRUCT field type with RECORD field type, we currently cannot suppress the recurring diff this causes. As a workaround, we recommend using the schema as returned by the API.

  • routine_id required - string
    • The ID of the the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.

  • routine_type optional - string
    • The type of routine. Possible values: ["SCALAR_FUNCTION", "PROCEDURE"]

Explanation in Terraform Registry

A user-defined function or a stored procedure that belongs to a Dataset To get more information about Routine, see:

Frequently asked questions

What is Google BigQuery Routine?

Google BigQuery Routine is a resource for BigQuery of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google BigQuery Routine?

For Terraform, the GoogleCloudPlatform/professional-services and bmwieczorek/my-apache-beam-dataflow source code examples are useful. See the Terraform Example section for further details.


Scan your IaC problem in 3 minutes for free

You can keep your IaC security for free. No credit card required.