向 BigQuery 表添加元数据

了解如何开始在 Dataplex Universal Catalog 中管理元数据。

本快速入门介绍了如何向 BigQuery 表添加元数据。在本快速入门中,您将执行以下操作:

  1. 基于公共数据集创建 BigQuery 数据集和表。

  2. 创建用于定义一组相关元数据字段的模板。

    该模板称为“切面类型”。一组相关的元数据字段,用于描述数据资产的业务元数据和技术元数据,称为切面

  3. 向表添加元数据。

    在 Dataplex Universal Catalog 中,每个数据资产都表示为一个条目。如需将元数据附加到数据资产,请向条目添加切面。

准备工作

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Dataplex and BigQuery APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  5. Make sure that you have the following role or roles on the project: Dataplex Catalog Admin, BigQuery Data Owner, BigQuery Job User

    Check for the roles

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

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

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

      前往 IAM
    2. 选择项目。
    3. 点击 授予访问权限
    4. 新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。

    5. 选择角色列表中,选择一个角色。
    6. 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
    7. 点击 Save(保存)。
  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. Verify that billing is enabled for your Google Cloud project.

  8. Enable the Dataplex and BigQuery APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  9. Make sure that you have the following role or roles on the project: Dataplex Catalog Admin, BigQuery Data Owner, BigQuery Job User

    Check for the roles

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

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

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

      前往 IAM
    2. 选择项目。
    3. 点击 授予访问权限
    4. 新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。

    5. 选择角色列表中,选择一个角色。
    6. 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
    7. 点击 Save(保存)。
  10. 创建数据集和表

    1. 在 Google Cloud 控制台中,前往 BigQuery Studio 页面。

      进入 BigQuery Studio

    2. 创建数据集:

      1. 探索器窗格中,找到您的项目。点击 查看操作,然后点击创建表

      2. 数据集 ID 字段中,输入 catalog_demo_dataset

        对于其他字段,请保留默认值。

      3. 点击创建数据集

    3. 将公共表复制到您的数据集:

      1. 探索器窗格中,搜索名为 bigquery-public-data.new_york_citibike.citibike_stations 的表。您可能需要设置搜索范围,以包含 bigquery-public-data 项目。

        此表是纽约市花旗单车行程数据集的一部分,该数据集是一个包含共享单车计划相关数据的公共数据集。

      2. 选择 citibike_stations 表。

      3. 点击复制。请输入以下信息:

        • 项目:选择您的项目。
        • 数据集:选择 catalog_demo_dataset
        • :输入 bike_stations
      4. 点击复制

    4. 探索器窗格中,找到 catalog_demo_dataset 数据集,并确认 bike_stations 表列在该数据集中。

    定义元数据模板:创建切面类型

    1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 目录页面。

      前往“目录”

    2. 点击切面类型和代码模板标签页,然后点击自定义标签页。

    3. 点击创建切面类型

    4. 切面类型 ID 字段中,输入 data-governance-demo

    5. 对于位置,请选择 global

    6. 模板部分中,点击添加字段。使用下表中的信息向切面类型添加多个字段:

      名称 类型 为必填项 说明
      source-of-data-asset 文本 -
      retention-date 日期和时间 -
      data-classification

      枚举

      添加值 PublicSensitiveConfidential

      -
      has-pii 布尔值 Whether the data asset has personally identifiable information
    7. 点击保存

    向表添加元数据:向条目添加切面

    1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 搜索页面。

      转到搜索

    2. 在搜索框中,输入 catalog_demo_dataset

    3. 选择 bike_stations 表。

    4. 向条目添加自定义切面:

      1. 标记和切面部分中,点击可选的标记和切面旁边的 添加

      2. 选择 data-governance-demo 切面类型。

        这会创建一个以您的切面类型为模板的切面。

      3. 输入以下值:

        • 数据资产的来源Copied from NYC Citi Bike Trips public dataset
        • 保留日期:输入日期。
        • 数据分类Public
        • 含有 PIIFalse
      4. 点击保存

    5. 如需查看您添加的元数据值,请在标记和切面部分中选择 data-governance-demo 切面。

    清理

    为避免因本页中使用的资源导致您的 Google Cloud 账号产生费用,请按照以下步骤操作。

    删除项目

    若要停止计费,最简单的方法是删除您为本快速入门创建的项目。

    1. In the Google Cloud console, go to the Manage resources page.

      Go to Manage resources

    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.

    删除各个资源

    如果您希望重复使用该项目,请删除您创建的资源。

    1. 删除数据集

      1. 在 Google Cloud 控制台中,前往 BigQuery Studio 页面。

        进入 BigQuery Studio

      2. 探索器窗格中,搜索 catalog_demo_dataset 数据集。

      3. 点击 查看操作,然后点击删除。在系统提示时确认。

    2. 删除切面类型:

      1. 在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 目录页面。

        前往“目录”

      2. 点击切面类型和代码模板标签页,然后点击自定义标签页。

      3. 点击 data-governance-demo 切面类型。

      4. 点击删除。在系统提示时确认。

    后续步骤