Quickstart for tagging tables

In this quickstart, you:

  1. Create a BigQuery dataset, and then copy public taxi data to a new table in your dataset.
  2. Create a tag template with a schema that defines four tag fields of distinct types (string, double, boolean, and enumerated).
  3. Lookup the Data Catalog entry for your table.
  4. Attach the tag to your table.

Before you begin

  1. Set up your project:

    1. Sign in to your Google Account.

      If you don't already have one, sign up for a new account.

    2. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

      Go to the project selector page

    3. Enable the Data Catalog and BigQuery APIs.

      Enable the APIs

    4. Install and initialize the Cloud SDK.

  2. Create a dataset. You must be the dataset owner to attach a tag to a table in the dataset as shown in this quickstart.

    1. Go to BigQuery in the Google Cloud Console.
    2. In the left navigation pane, click your project name, then click CREATE DATASET.
    3. In the Create Dataset dialog:
      • For Dataset ID, enter "demo_dataset".
      • For Data location, accept the Default location, which sets the dataset location to US multi-region.
      • For Default data expiration, choose one of the following options:
        • Never: (Default) Tables created in the dataset are never automatically deleted. You must delete them manually.
        • Number of days after table creation: Any table created in the dataset is deleted after the specified days from its creation time. This value is applied if you do not set a table expiration when the table is created. Create dataset
      • Click Create dataset. Note: You cannot add a description or a label when you create a dataset using the Google Cloud Console. After the dataset is created, you can add a description, and you can add a label.
  3. Copy a public New York Taxi table to your demo_dataset.

    1. From BigQuery in the Google Cloud Console, under the "bigquery-public-data" project, select the "new_york_taxi_trips" dataset, and then select one of the "tlc_yellow_trips" tables, such as tlc_yellow_trips_2017. Click COPY TABLE to open the Table Details:trips panel.
    2. In the Copy table dialog "Destination" section, select your project and your "demo_dataset". Insert "trips" for the Table name, then click COPY.
    3. Confirm that the trips table is listed in your demo_dataset.
      You add Data Catalog tags to the table in the next section.

Create a tag template and attach the tag to your table

Console

You can create a tag template from the Data Catalog UI in the Google Cloud Console.

  1. Select "Create tag template" to open the Create template page. Fill in the template form to define a "Demo Tag Template".
    1. Template ID: demo_tag_template
    2. Template display name: Demo Tag Template
    3. Project Select your project
  2. Next create four tag fields (previously called tag "attributes"). Click "Add field" to open the New field dialog. Create four fields with the values listed below. Note that the "source" field defines a required tag field.
      • Field ID: source
      • Make this field required: Checked
      • Field display name: Source of data asset
      • Type: String
      • Click Done
      • Field ID: num_rows
      • Make this field required: Not checked
      • Field display name: Number of rows in the data asset
      • Type: Double
      • Click Done
      • Field ID: has_pii
      • Make this field required: Not checked
      • Field display name: Has PII
      • Type: Boolean
      • Click Done
      • Field ID: pii_type
      • Make this field required: Not checked
      • Field display name: PII type
      • Type: Enumerated
        Add 3 values:
        1. EMAIL
        2. SOCIAL SECURITY NUMBER
        3. NONE
      • Click Done

    The completed tag template form should list the four tag fields:

    Click CREATE. The Data Catalog Tag template page displays template details and fields.

  3. To attach a tag to a table in your dataset, open the Data Catalog UI, insert "demo_dataset" in the Search box, then click Search.
  4. The demo_dataset and the trips table that you copied into the dataset are displayed in the search results. Click the trips link.
  5. The Entry details page opens. Click Attach Tags.
  6. In the Attach Tags panel:
    1. Under Choose what to tag, select the trips table and click OK.
    2. Under Choose the tag templates, search for and select Demo Tag Template and click OK.
    3. Under Fill in tag values, fill in the following values for each field:
      • Source of data asset: Copied from tlc_yellow_trips_2017
      • Number of rows in the data asset: 113496874
      • Has PII: FALSE
      • PII type: NONE

      Click Save. The tag fields are now listed in the Tags section below BigQuery dataset details.

gcloud

Run the gcloud data-catalog tag-templates create command shown below to create a tag template with the following four tag fields (also called "attributes"):

  1. display_name: Source of data asset
    id: source
    required: TRUE
    type: String
  2. display_name: Number of rows in the data asset
    id: num_rows
    required: FALSE
    type: Double
  3. display_name: Has PII
    id: has_pii
    required: FALSE
    type: Boolean
  4. display_name: PII type
    id: pii_type
    required: FALSE
    type: Enumerated
    values:
    1. EMAIL
    2. SOCIAL SECURITY NUMBER
    3. NONE
# -------------------------------
# Create a Tag Template.
# -------------------------------
gcloud data-catalog tag-templates create demo_template \
    --location=us-central1 \
    --display-name="Demo Tag Template" \
    --field=id=source,display-name="Source of data asset",type=string,required=TRUE \
    --field=id=num_rows,display-name="Number of rows in the data asset",type=double \
    --field=id=has_pii,display-name="Has PII",type=bool \
    --field=id=pii_type,display-name="PII type",type='enum(EMAIL|SOCIAL SECURITY NUMBER|NONE)'

# -------------------------------
# Lookup the Data Catalog entry for the table.
# -------------------------------
ENTRY_NAME=$(gcloud data-catalog entries lookup '//bigquery.googleapis.com/projects/PROJECT_ID/datasets/DATASET/tables/TABLE' --format="value(name)")

# -------------------------------
# Attach a Tag to the table.
# -------------------------------

# Create the Tag file.
cat > tag_file.json << EOF
  {
    "source": "BigQuery",
    "num_rows": 1000,
    "has_pii": true,
    "pii_type": "EMAIL"
  }
EOF

gcloud data-catalog tags create --entry=${ENTRY_NAME} \
    --tag-template=demo_template --tag-template-location=us-central1 --tag-file=tag_file.json

Python

  1. Install the client library
  2. Set up application default credentials
  3. Run the code
    # -------------------------------
    # Import required modules.
    # -------------------------------
    from google.cloud import datacatalog_v1
    
    # -------------------------------
    # Set your Google Cloud Platform project ID.
    # -------------------------------
    project_id = 'PROJECT'
    
    # -------------------------------
    # Currently, Data Catalog stores metadata in the
    # us-central1 region.
    # -------------------------------
    location = 'us-central1'
    
    # -------------------------------
    # Use Application Default Credentials to create a new
    # Data Catalog client. GOOGLE_APPLICATION_CREDENTIALS
    # environment variable must be set with the location
    # of a service account key file.
    # -------------------------------
    datacatalog_client = datacatalog_v1.DataCatalogClient()
    
    # -------------------------------
    # Create a Tag Template.
    # -------------------------------
    tag_template = datacatalog_v1.types.TagTemplate()
    
    tag_template.display_name = 'Demo Tag Template'
    
    tag_template.fields['source'] = datacatalog_v1.types.TagTemplateField()
    tag_template.fields['source'].display_name = 'Source of data asset'
    tag_template.fields['source'].type.primitive_type = datacatalog_v1.types.FieldType.PrimitiveType.STRING
    
    tag_template.fields['num_rows'] = datacatalog_v1.types.TagTemplateField()
    tag_template.fields['num_rows'].display_name = 'Number of rows in data asset'
    tag_template.fields['num_rows'].type.primitive_type = datacatalog_v1.types.FieldType.PrimitiveType.DOUBLE
    
    tag_template.fields['has_pii'] = datacatalog_v1.types.TagTemplateField()
    tag_template.fields['has_pii'].display_name = 'Has PII'
    tag_template.fields['has_pii'].type.primitive_type = datacatalog_v1.types.FieldType.PrimitiveType.BOOL
    
    tag_template.fields['pii_type'] = datacatalog_v1.types.TagTemplateField()
    tag_template.fields['pii_type'].display_name = 'PII type'
    
    for display_name in ['EMAIL', 'SOCIAL SECURITY NUMBER', 'NONE']:
        enum_value = datacatalog_v1.types.FieldType.EnumType.EnumValue(display_name = display_name)
        tag_template.fields['pii_type'].type.enum_type.allowed_values.append(enum_value)
    
    expected_template_name = datacatalog_v1.DataCatalogClient\
        .tag_template_path(project_id, location, 'example_tag_template')
    
    # Delete any pre-existing Template with the same name.
    try:
        datacatalog_client.delete_tag_template(name=expected_template_name, force=True)
        print('Deleted template: {}'.format(expected_template_name))
    except:
        print('Cannot delete template: {}'.format(expected_template_name))
    
    # Create the Tag Template.
    try:
        tag_template = datacatalog_client.create_tag_template(
            parent='projects/{}/locations/us-central1'.format(project_id),
            tag_template_id='example_tag_template',
            tag_template=tag_template)
        print('Created template: {}'.format(tag_template.name))
    except OSError as e:
        print('Cannot create template: {}'.format(expected_template_name))
        print('{}'.format(e))
    
    # -------------------------------
    # Lookup Data Catalog's Entry referring to the table.
    # -------------------------------
    resource_name = '//bigquery.googleapis.com/projects/{}' \
                    '/datasets/demo_dataset/tables/trips'.format(project_id)
    table_entry = datacatalog_client.lookup_entry(request={"linked_resource": resource_name})
    
    # -------------------------------
    # Attach a Tag to the table.
    # -------------------------------
    tag = datacatalog_v1.types.Tag()
    
    tag.template = tag_template.name
    tag.name="my_tag"
    
    tag.fields['source'] = datacatalog_v1.types.TagField()
    tag.fields['source'].string_value = 'Copied from tlc_yellow_trips_2018'
    
    tag.fields['num_rows'] = datacatalog_v1.types.TagField()
    tag.fields['num_rows'].double_value = 113496874
    
    tag.fields['has_pii'] = datacatalog_v1.types.TagField()
    tag.fields['has_pii'].bool_value = False
    
    tag.fields['pii_type'] = datacatalog_v1.types.TagField()
    tag.fields['pii_type'].enum_value.display_name = 'NONE'
    
    tag = datacatalog_client.create_tag(parent=table_entry.name, tag=tag)
    print('Created tag: {}'.format(tag.name))
    
    

Java

  1. Install the client library
  2. Set up application default credentials
  3. Run the code
    /*
    This application demonstrates how to perform core operations with the
    Data Catalog API.
    
    For more information, see the README.md and the official documentation at
    https://cloud.google.com/data-catalog/docs.
    */
    
    package com.example.datacatalog;
    
    import com.google.cloud.datacatalog.v1.CreateTagRequest;
    import com.google.cloud.datacatalog.v1.CreateTagTemplateRequest;
    import com.google.cloud.datacatalog.v1.DataCatalogClient;
    import com.google.cloud.datacatalog.v1.DeleteTagTemplateRequest;
    import com.google.cloud.datacatalog.v1.Entry;
    import com.google.cloud.datacatalog.v1.FieldType;
    import com.google.cloud.datacatalog.v1.FieldType.EnumType;
    import com.google.cloud.datacatalog.v1.FieldType.EnumType.EnumValue;
    import com.google.cloud.datacatalog.v1.FieldType.PrimitiveType;
    import com.google.cloud.datacatalog.v1.LocationName;
    import com.google.cloud.datacatalog.v1.LookupEntryRequest;
    import com.google.cloud.datacatalog.v1.Tag;
    import com.google.cloud.datacatalog.v1.TagField;
    import com.google.cloud.datacatalog.v1.TagTemplate;
    import com.google.cloud.datacatalog.v1.TagTemplateField;
    import com.google.cloud.datacatalog.v1.TagTemplateName;
    
    public class CreateTags {
    
      public static void createTags() {
        // TODO(developer): Replace these variables before running the sample.
        String projectId = "my-project";
        String tagTemplateId = "my_tag_template";
        createTags(projectId, tagTemplateId);
      }
    
      public static void createTags(String projectId, String tagTemplateId) {
        // Currently, Data Catalog stores metadata in the us-central1 region.
        String location = "us-central1";
    
        // Initialize client that will be used to send requests. This client only needs to be created
        // once, and can be reused for multiple requests. After completing all of your requests, call
        // the "close" method on the client to safely clean up any remaining background resources.
        try (DataCatalogClient dataCatalogClient = DataCatalogClient.create()) {
    
          // -------------------------------
          // Create a Tag Template.
          // -------------------------------
          TagTemplateField sourceField =
              TagTemplateField.newBuilder()
                  .setDisplayName("Source of data asset")
                  .setType(FieldType.newBuilder().setPrimitiveType(PrimitiveType.STRING).build())
                  .build();
    
          TagTemplateField numRowsField =
              TagTemplateField.newBuilder()
                  .setDisplayName("Number of rows in data asset")
                  .setType(FieldType.newBuilder().setPrimitiveType(PrimitiveType.DOUBLE).build())
                  .build();
    
          TagTemplateField hasPiiField =
              TagTemplateField.newBuilder()
                  .setDisplayName("Has PII")
                  .setType(FieldType.newBuilder().setPrimitiveType(PrimitiveType.BOOL).build())
                  .build();
    
          TagTemplateField piiTypeField =
              TagTemplateField.newBuilder()
                  .setDisplayName("PII type")
                  .setType(
                      FieldType.newBuilder()
                          .setEnumType(
                              EnumType.newBuilder()
                                  .addAllowedValues(
                                      EnumValue.newBuilder().setDisplayName("EMAIL").build())
                                  .addAllowedValues(
                                      EnumValue.newBuilder()
                                          .setDisplayName("SOCIAL SECURITY NUMBER")
                                          .build())
                                  .addAllowedValues(
                                      EnumValue.newBuilder().setDisplayName("NONE").build())
                                  .build())
                          .build())
                  .build();
    
          TagTemplate tagTemplate =
              TagTemplate.newBuilder()
                  .setDisplayName("Demo Tag Template")
                  .putFields("source", sourceField)
                  .putFields("num_rows", numRowsField)
                  .putFields("has_pii", hasPiiField)
                  .putFields("pii_type", piiTypeField)
                  .build();
    
          CreateTagTemplateRequest createTagTemplateRequest =
              CreateTagTemplateRequest.newBuilder()
                  .setParent(
                      LocationName.newBuilder()
                          .setProject(projectId)
                          .setLocation(location)
                          .build()
                          .toString())
                  .setTagTemplateId("demo_tag_template")
                  .setTagTemplate(tagTemplate)
                  .build();
    
          String expectedTemplateName =
              TagTemplateName.newBuilder()
                  .setProject(projectId)
                  .setLocation(location)
                  .setTagTemplate("demo_tag_template")
                  .build()
                  .toString();
    
          // Delete any pre-existing Template with the same name.
          try {
            dataCatalogClient.deleteTagTemplate(
                DeleteTagTemplateRequest.newBuilder()
                    .setName(expectedTemplateName)
                    .setForce(true)
                    .build());
    
            System.out.println(String.format("Deleted template: %s", expectedTemplateName));
          } catch (Exception e) {
            System.out.println(String.format("Cannot delete template: %s", expectedTemplateName));
          }
    
          // Create the Tag Template.
          tagTemplate = dataCatalogClient.createTagTemplate(createTagTemplateRequest);
          System.out.println(String.format("Template created with name: %s", tagTemplate.getName()));
    
          // -------------------------------
          // Lookup Data Catalog's Entry referring to the table.
          // -------------------------------
          String linkedResource =
              String.format(
                  "//bigquery.googleapis.com/projects/%s/datasets/demo_dataset/tables/trips",
                  projectId);
          LookupEntryRequest lookupEntryRequest =
              LookupEntryRequest.newBuilder().setLinkedResource(linkedResource).build();
          Entry tableEntry = dataCatalogClient.lookupEntry(lookupEntryRequest);
    
          // -------------------------------
          // Attach a Tag to the table.
          // -------------------------------
          TagField sourceValue =
              TagField.newBuilder().setStringValue("Copied from tlc_yellow_trips_2017").build();
          TagField numRowsValue = TagField.newBuilder().setDoubleValue(113496874).build();
          TagField hasPiiValue = TagField.newBuilder().setBoolValue(false).build();
          TagField piiTypeValue =
              TagField.newBuilder()
                  .setEnumValue(TagField.EnumValue.newBuilder().setDisplayName("NONE").build())
                  .build();
    
          Tag tag =
              Tag.newBuilder()
                  .setTemplate(tagTemplate.getName())
                  .putFields("source", sourceValue)
                  .putFields("num_rows", numRowsValue)
                  .putFields("has_pii", hasPiiValue)
                  .putFields("pii_type", piiTypeValue)
                  .build();
    
          CreateTagRequest createTagRequest =
              CreateTagRequest.newBuilder().setParent(tableEntry.getName()).setTag(tag).build();
    
          dataCatalogClient.createTag(createTagRequest);
    
        } catch (Exception e) {
          System.out.print("Error during CreateTags:\n" + e.toString());
        }
      }
    }
    

Node.js

  1. Install the client library
  2. Set up application default credentials
  3. Run the code
    async function main() {
        // -------------------------------
        // Import required modules.
        // -------------------------------
        const { DataCatalogClient } = require('@google-cloud/datacatalog').v1;
    
        // Common fields.
        let request;
        let responses;
    
        // -------------------------------
        // Set your Google Cloud Platform project ID.
        // -------------------------------
        const projectId = 'PROJECT_ID';
    
        // -------------------------------
        // Currently, Data Catalog stores metadata in the
        // us-central1 region.
        // -------------------------------
        const location = 'us-central1';
    
        // -------------------------------
        // Use Application Default Credentials to create a new
        // Data Catalog client. GOOGLE_APPLICATION_CREDENTIALS
        // environment variable must be set with the location
        // of a service account key file.
        // -------------------------------
        const datacatalog = new DataCatalogClient();
    
        // Create Fields.
        const fieldSource = {
            displayName: 'Source of data asset',
            type: {
                primitiveType: 'STRING',
            },
        };
    
        const fieldNumRows = {
            displayName: 'Number of rows in data asset',
            type: {
                primitiveType: 'DOUBLE',
            },
        };
    
        const fieldHasPII = {
            displayName: 'Has PII',
            type: {
                primitiveType: 'BOOL',
            },
        };
    
        const fieldPIIType = {
            displayName: 'PII type',
            type: {
                enumType: {
                    allowedValues: [
                        {
                            displayName: 'EMAIL',
                        },
                        {
                            displayName: 'SOCIAL SECURITY NUMBER',
                        },
                        {
                            displayName: 'NONE',
                        },
                    ],
                },
            },
        };
    
        // -------------------------------
        // Create Tag Template.
        // -------------------------------
        const tagTemplateId = 'demo_tag_template';
    
        const tagTemplate = {
            displayName: 'Demo Tag Template',
            fields: {
                source: fieldSource,
                num_rows: fieldNumRows,
                has_pii: fieldHasPII,
                pii_type: fieldPIIType,
            },
        };
    
        const tagTemplatePath = datacatalog.tagTemplatePath(
            projectId,
            location,
            tagTemplateId
        );
    
        // Delete any pre-existing Template with the same name.
        try {
            request = {
                name: tagTemplatePath,
                force: true,
            };
            await datacatalog.deleteTagTemplate(request);
            console.log(`Deleted template: ${tagTemplatePath}`);
        } catch (error) {
            console.log(`Cannot delete template: ${tagTemplatePath}`);
        }
    
        // Create the Tag Template request.
        const locationPath = datacatalog.locationPath(projectId, location);
    
        request = {
            parent: locationPath,
            tagTemplateId: tagTemplateId,
            tagTemplate: tagTemplate,
        };
    
        // Execute the request.
        responses = await datacatalog.createTagTemplate(request);
        const createdTagTemplate = responses[0];
        console.log(`Created template: ${createdTagTemplate.name}`);
    
        // -------------------------------
        // Lookup Data Catalog's Entry referring to the table.
        // -------------------------------
        responses = await datacatalog.lookupEntry({
            linkedResource: `//bigquery.googleapis.com/projects/` +
                `${projectId}/datasets/demo_dataset/tables/trips`,
        });
        const entry = responses[0];
        console.log(`Entry name: ${entry.name}`);
        console.log(`Entry type: ${entry.type}`);
        console.log(`Linked resource: ${entry.linkedResource}`);
    
        // -------------------------------
        // Attach a Tag to the table.
        // -------------------------------
        const tag = {
            name: entry.name,
            template: createdTagTemplate.name,
            fields: {
                source: {
                    stringValue: 'Copied from tlc_yellow_trips_2017',
                },
                num_rows: {
                    doubleValue: 113496874,
                },
                has_pii: {
                    boolValue: false,
                },
                pii_type: {
                    enumValue: {
                        displayName: 'NONE',
                    },
                },
            },
        };
    
        request = {
            parent: entry.name,
            tag: tag,
        };
    
        // Create the Tag.
        await datacatalog.createTag(request);
        console.log(`Tag created for entry: ${entry.name}`);
    }
    
    main();
    

REST & CMD LINE

If you do not have access to Cloud Client libraries for your language or want to test the API using REST requests, see the following examples and refer to the Data Catalog REST API documentation.

1. Create a tag template.

Before using any of the request data below, make the following replacements:

  • project-id: your GCP project ID

HTTP method and URL:

POST https://datacatalog.googleapis.com/v1/projects/project-id/locations/us-central1/tagTemplates?tagTemplateId=demo_tag_template

Request JSON body:

{
  "displayName":"Demo Tag Template",
  "fields":{
    "source":{
      "displayName":"Source of data asset",
      "isRequired": "true",
      "type":{
        "primitiveType":"STRING"
      }
    },
    "num_rows":{
      "displayName":"Number of rows in data asset",
      "isRequired": "false",
      "type":{
        "primitiveType":"DOUBLE"
      }
    },
    "has_pii":{
      "displayName":"Has PII",
      "isRequired": "false",
      "type":{
        "primitiveType":"BOOL"
      }
    },
    "pii_type":{
      "displayName":"PII type",
      "isRequired": "false",
      "type":{
        "enumType":{
          "allowedValues":[
            {
              "displayName":"EMAIL"
            },
            {
              "displayName":"SOCIAL SECURITY NUMBER"
            },
            {
              "displayName":"NONE"
            }
          ]
        }
      }
    }
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name":"projects/project-id/locations/us-central1/tagTemplates/demo_tag_template",
  "displayName":"Demo Tag Template",
  "fields":{
    "num_rows":{
      "displayName":"Number of rows in data asset",
      "isRequired": "false",
      "type":{
        "primitiveType":"DOUBLE"
      }
    },
    "has_pii":{
      "displayName":"Has PII",
      "isRequired": "false",
      "type":{
        "primitiveType":"BOOL"
      }
    },
    "pii_type":{
      "displayName":"PII type",
      "isRequired": "false",
      "type":{
        "enumType":{
          "allowedValues":[
            {
              "displayName":"EMAIL"
            },
            {
              "displayName":"NONE"
            },
            {
              "displayName":"SOCIAL SECURITY NUMBER"
            }
          ]
        }
      }
    },
    "source":{
      "displayName":"Source of data asset",
      "isRequired":"true",
      "type":{
        "primitiveType":"STRING"
      }
    }
  }
}

2. Lookup the Data Catalog entry-id for your BigQuery table.

Before using any of the request data below, make the following replacements:

  • project-id: GCP project ID

HTTP method and URL:

GET https://datacatalog.googleapis.com/v1/entries:lookup?linkedResource=//bigquery.googleapis.com/projects/project-id/datasets/demo_dataset/tables/trips

Request JSON body:

Request body is empty.

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "projects/project-id/locations/US/entryGroups/@bigquery/entries/entry-id",
  "type": "TABLE",
  "schema": {
    "columns": [
      {
        "type": "STRING",
        "description": "A code indicating the TPEP provider that provided the record. 1= ",
        "mode": "REQUIRED",
        "column": "vendor_id"
      },
      ...
    ]
  },
  "sourceSystemTimestamps": {
    "createTime": "2019-01-25T01:45:29.959Z",
    "updateTime": "2019-03-19T23:20:26.540Z"
  },
  "linkedResource": "//bigquery.googleapis.com/projects/project-id/datasets/demo_dataset/tables/trips",
  "bigqueryTableSpec": {
    "tableSourceType": "BIGQUERY_TABLE"
  }
}

3. Create a tag from the template and attach it to your BigQuery table.

Before using any of the request data below, make the following replacements:

  • project-id: GCP project ID
  • entry-id: Data Catalog entry ID for the Demo Dataset trips table (returned in the lookup results in the previous step).

HTTP method and URL:

POST https://datacatalog.googleapis.com/v1/projects/project-id/locations/us-central1/entryGroups/@bigquery/entries/entry-id/tags?tagTemplateId=demo_tag_template

Request JSON body:

{
  "template":"projects/project-id/locations/us-central1/tagTemplates/demo_tag_template",
  "fields":{
    "source":{
      "stringValue":"Copied from tlc_yellow_trips_2017"
    },
    "num_rows":{
      "doubleValue":113496874
    },
    "has_pii":{
      "boolValue":false
    },
    "pii_type":{
      "enumValue":{
        "displayName":"NONE"
      }
    }
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name":"projects/project-id/locations/US/entryGroups/@bigquery/entries/entry-id/tags/tag-id",
  "template":"projects/project-id/locations/us-central1/tagTemplates/demo_tag_template",
  "fields":{
    "pii_type":{
      "displayName":"PII type",
      "enumValue":{
        "displayName":"NONE"
      }
    },
    "has_pii":{
      "displayName":"Has PII",
      "boolValue":false
    },
    "source":{
      "displayName":"Source of data asset",
      "stringValue":"Copied from tlc_yellow_trips_2017"
    },
    "num_rows":{
      "displayName":"Number of rows in data asset",
      "doubleValue":113496874
    }
  },
  "templateDisplayName":"Demo Tag Template"
}

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.

Deleting the project

The easiest way to eliminate billing is to delete the project that you created for the tutorial.

To delete the project:

  1. In the Cloud Console, go to the Manage resources page.

    Go to the Manage resources page

  2. In the project list, select the project that you want to delete and then click Delete .
  3. In the dialog, type the project ID and then click Shut down to delete the project.

Deleting the dataset

  1. If necessary, open the BigQuery web UI.

    Go to the BigQuery web UI

  2. In the navigation panel, in the Resources section, click the demo_dataset dataset you created.

  3. In the details panel, on the right side, click Delete dataset. This action deletes the dataset, the table, and all the data.

  4. In the Delete dataset dialog box, confirm the delete command by typing the name of your dataset (demo_dataset) and then click Delete.

Deleting the tag template

  1. Open the Data Catalog UI in the Google Cloud Console. Under Tag Template, click Manage tag templates.

  2. Click Demo Tag Template.

  3. On the Tag Template page, click Delete to delete the Demo Tag Template.

What's next