This document shows you how to control column access by adding BigQuery
policy tags to table columns with
[Dataform core](https://docs.cloud.google.com/dataform/docs/overview#dataform-core).

You can set
[BigQuery policy tags](https://docs.cloud.google.com/bigquery/docs/column-level-security-intro)
on table columns in the `config` block in a table definition SQLX file.

## Before you begin

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

   [Go to the Dataform page](https://console.cloud.google.com/bigquery/dataform)
2. Select or [create a repository](https://docs.cloud.google.com/dataform/docs/create-repository).

3. Select or [create a development workspace](https://docs.cloud.google.com/dataform/docs/create-workspace).

4. [Create a table](https://docs.cloud.google.com/dataform/docs/create-tables#create-table).

### Required roles


To get the permissions that
you need to add a BigQuery policy tag to a table in Dataform,

ask your administrator to grant you the
[Dataform Editor](https://docs.cloud.google.com/iam/docs/roles-permissions/dataform#dataform.editor) (`roles/dataform.editor`) IAM role on workspaces.


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access).


You might also be able to get
the required permissions through [custom
roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles) or other [predefined
roles](https://docs.cloud.google.com/iam/docs/roles-overview#predefined).

Additionally, you must grant the
[BigQuery roles for column-level access control](https://docs.cloud.google.com/bigquery/docs/column-level-security-intro#roles)
to your
[custom service account](https://docs.cloud.google.com/dataform/docs/access-control#about-service-accounts).

## Add a BigQuery policy tag

To add a BigQuery policy tag to a table column, follow these steps:

1. Go to your development workspace.
2. In the **Files** pane, expand `definitions/`.
3. Select a table definition SQLX file.
4. In the `config` block, add a full tag identifier to a selected
   column in the following format:

       columns: {
           column_name: {
             bigqueryPolicyTags: ["FULL_TAG_IDENTIFIER"]
           }
         }

   Replace <var translate="no">FULL_TAG_IDENTIFIER</var> with the full identifier
   of the selected tag.
5. Optional: Click **Format**.

The following code sample shows the
`projects/example-project/locations/us/taxonomies/123456789/policyTags/123456789`
sample BigQuery policy tag added to `column1`:

    config {
      type: "table",
      columns: {
        column1: {
          description: "Some description",
          bigqueryPolicyTags: ["projects/example-project/locations/us/taxonomies/123456789/policyTags/123456789"]
        }
      }
    }

    SELECT "test" AS column1

## What's next

- To learn more about BigQuery policy tags, see [Introduction to column-level access control](https://docs.cloud.google.com/bigquery/docs/column-level-security-intro).
- To learn how to add BigQuery labels in Dataform, see [Add BigQuery labels](https://docs.cloud.google.com/dataform/docs/labels).
- To learn how to add Dataform tags to create collections of tables, see [Add execution tags](https://docs.cloud.google.com/dataform/docs/configure-additional-actions#add-execution-tags).