BigQuery supports adding labels to resources. For more information on labels in BigQuery, see Introduction to labels.
Before you begin
In the Google Cloud console, go to the Dataform page.
Select or create a repository.
Select or create a development workspace.
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 to projects, folders, and organizations.
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:
- Go to your development workspace.
- In the Files pane, expand
definitions/
. - Select a SQLX table definition file.
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
Optional: To add a label with a name that contains special characters, enter the label name in quotes
""
.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"
}
}
}
SELECT CURRENT_TIMESTAMP() AS ts
What's next
- To learn how to reuse code with includes, see Reuse variables and functions with includes.
- To learn to manually trigger executions, see Trigger execution.