向 BigQuery 表添加元数据
了解如何开始在 Dataplex Universal Catalog 中管理元数据。
本快速入门介绍了如何向 BigQuery 表添加元数据。在本快速入门中,您将执行以下操作:
基于公共数据集创建 BigQuery 数据集和表。
创建用于定义一组相关元数据字段的模板。
该模板称为“切面类型”。一组相关的元数据字段,用于描述数据资产的业务元数据和技术元数据,称为切面。
向表添加元数据。
在 Dataplex Universal Catalog 中,每个数据资产都表示为一个条目。如需将元数据附加到数据资产,请向条目添加切面。
准备工作
- 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.
-
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 theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
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 theserviceusage.services.enable
permission. Learn how to grant roles. -
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
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
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.
- 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
-
In the Google Cloud console, go to the IAM page.
前往 IAM - 选择项目。
- 点击 授予访问权限。
-
在新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。
- 在选择角色列表中,选择一个角色。
- 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
- 点击 Save(保存)。
-
-
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 theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
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 theserviceusage.services.enable
permission. Learn how to grant roles. -
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
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
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.
- 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
-
In the Google Cloud console, go to the IAM page.
前往 IAM - 选择项目。
- 点击 授予访问权限。
-
在新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。
- 在选择角色列表中,选择一个角色。
- 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
- 点击 Save(保存)。
-
在 Google Cloud 控制台中,前往 BigQuery Studio 页面。
创建数据集:
在探索器窗格中,找到您的项目。点击
查看操作,然后点击创建表。在数据集 ID 字段中,输入
catalog_demo_dataset
。对于其他字段,请保留默认值。
点击创建数据集。
将公共表复制到您的数据集:
在探索器窗格中,搜索名为
bigquery-public-data.new_york_citibike.citibike_stations
的表。您可能需要设置搜索范围,以包含bigquery-public-data
项目。此表是纽约市花旗单车行程数据集的一部分,该数据集是一个包含共享单车计划相关数据的公共数据集。
选择
citibike_stations
表。点击复制。请输入以下信息:
- 项目:选择您的项目。
- 数据集:选择
catalog_demo_dataset
。 - 表:输入
bike_stations
。
点击复制。
在探索器窗格中,找到
catalog_demo_dataset
数据集,并确认bike_stations
表列在该数据集中。在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 目录页面。
点击切面类型和代码模板标签页,然后点击自定义标签页。
点击创建切面类型。
在切面类型 ID 字段中,输入
data-governance-demo
。对于位置,请选择
global
。在模板部分中,点击添加字段。使用下表中的信息向切面类型添加多个字段:
名称 类型 为必填项 说明 source-of-data-asset
文本 否 - retention-date
日期和时间 否 - data-classification
枚举
添加值
Public
、Sensitive
和Confidential
。是 - has-pii
布尔值 是 Whether the data asset has personally identifiable information
点击保存。
在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 搜索页面。
在搜索框中,输入
catalog_demo_dataset
。选择 bike_stations 表。
向条目添加自定义切面:
在标记和切面部分中,点击可选的标记和切面旁边的
添加。选择
data-governance-demo
切面类型。这会创建一个以您的切面类型为模板的切面。
输入以下值:
- 数据资产的来源:
Copied from NYC Citi Bike Trips public dataset
- 保留日期:输入日期。
- 数据分类:
Public
- 含有 PII:
False
- 数据资产的来源:
点击保存。
如需查看您添加的元数据值,请在标记和切面部分中选择 data-governance-demo 切面。
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
删除数据集
在 Google Cloud 控制台中,前往 BigQuery Studio 页面。
在探索器窗格中,搜索
catalog_demo_dataset
数据集。点击
查看操作,然后点击删除。在系统提示时确认。
删除切面类型:
在 Google Cloud 控制台中,前往 Dataplex Universal Catalog 目录页面。
点击切面类型和代码模板标签页,然后点击自定义标签页。
点击
data-governance-demo
切面类型。点击删除。在系统提示时确认。
创建数据集和表
定义元数据模板:创建切面类型
向表添加元数据:向条目添加切面
清理
为避免因本页中使用的资源导致您的 Google Cloud 账号产生费用,请按照以下步骤操作。
删除项目
若要停止计费,最简单的方法是删除您为本快速入门创建的项目。
删除各个资源
如果您希望重复使用该项目,请删除您创建的资源。