Add BigQuery labels

This document shows you how to add labels to tables in Dataform.

BigQuery supports adding labels to resources. For more information on labels in BigQuery, see Introduction to labels.

Before you begin

  1. In the Google Cloud console, go to the Dataform page.

    Go to the Dataform page

  2. Select or create a repository.

  3. Select or create a development workspace.

  4. Create a table.

Required roles

To get the permissions that you need to add a BigQuery label to a Dataform table, ask your administrator to grant you the Dataform Editor (roles/dataform.editor) IAM role on workspaces. For more information about granting roles, see Manage access.

You might also be able to get the required permissions through custom roles or other predefined roles.

Add a BigQuery label

To add a BigQuery label to a table in Dataform, add the label to the bigquery block in the config block of the table definition SQLX file.

To add a BigQuery label to a table definition file, follow these steps:

  1. Go to your development workspace.
  2. In the Files pane, expand definitions/.
  3. Select a SQLX table definition file.
  4. In the config block, add a label in the following format:

    bigquery: {
        labels: {
          LABEL1: "VALUE_OF_LABEL1"

    Replace the following:

    • LABEL1: the name of your label
    • VALUE_OF_LABEL1: the value of your label
  5. Optional: To add a label with a name that contains special characters, enter the label name in quotes "".

  6. Optional: Click Format.

The following code sample shows the department:shipping and cost-center:logistics labels added to the bigquery block in a partitioned table definition SQLX file:

config {
  type: "table",
  bigquery: {
    partitionBy: "DATE(ts)",
    labels: {
      department: "shipping",
      "cost-center": "logistics"


What's next