將中繼資料新增至 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 - 選取專案。
- 按一下「授予存取權」 。
-
在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。
- 在「Select a role」(選取角色) 清單中,選取角色。
- 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
- 按一下 [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 - 選取專案。
- 按一下「授予存取權」 。
-
在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。
- 在「Select a role」(選取角色) 清單中,選取角色。
- 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
- 按一下 [Save]。
-
前往 Google Cloud 控制台的「BigQuery Studio」頁面。
建立資料集:
在「Explorer」窗格中,找出您的專案。按一下
「View actions」(查看動作),然後點選「Create dataset」(建立資料集)。在「Dataset ID」(資料集 ID) 欄位中,輸入
catalog_demo_dataset
。其他欄位皆使用預設值。
按一下「Create dataset」(建立資料集)。
將公開資料表複製到資料集:
在「Explorer」窗格中,搜尋名為
bigquery-public-data.new_york_citibike.citibike_stations
的資料表。您可能需要設定搜尋範圍,納入bigquery-public-data
專案。這個資料表是紐約市 (NYC) Citi Bike 行程資料集的一部分,該資料集是包含單車共享計畫資料的公開資料集。
選取「
citibike_stations
」資料表。按一下「複製」。 輸入下列資訊:
- 「Project」(專案):選取專案。
- 「Dataset」(資料集):選取
catalog_demo_dataset
。 - 「Table」(資料表):輸入
bike_stations
。
按一下 [複製]。
在「Explorer」窗格中找出
catalog_demo_dataset
資料集,並確認資料集中列出bike_stations
資料表。在 Google Cloud 控制台,前往 Dataplex Universal Catalog 的「Catalog」(目錄) 頁面。
按一下「Aspect types & tag templates」(切面類型和標記範本) 分頁標籤,然後按一下「Custom」(自訂) 分頁標籤。
點選「建立切面類型」。
在「Aspect type ID」(切面類型 ID) 欄位中,輸入
data-governance-demo
。在「Location」(位置) 部分,選取
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 的「Search」(搜尋) 頁面。
在搜尋框中輸入
catalog_demo_dataset
。選取「bike_stations」資料表。
為項目新增自訂切面:
在「Tags & aspects」(標記和切面) 部分,點選「Optional tags & aspects」(選用標記和切面) 旁的
「Add」(新增)。選取
data-governance-demo
切面類型。這會建立以切面類型做為範本的切面。
輸入下列值:
- 資料資產來源:
Copied from NYC Citi Bike Trips public dataset
- 保留日期:請輸入日期。
- 資料分類:
Public
- 具有 PII:
False
- 資料資產來源:
點按「Save」(儲存)。
如要查看您新增的中繼資料值,請在「Tags & aspects」(標記和切面) 部分,選取「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」頁面。
在「Explorer」窗格中,搜尋
catalog_demo_dataset
資料集。按一下
「View actions」(查看動作),然後按一下「Delete」(刪除)。當系統提示時,確認刪除。
刪除切面類型:
在 Google Cloud 控制台,前往 Dataplex Universal Catalog 的「Catalog」(目錄) 頁面。
按一下「Aspect types & tag templates」(切面類型和標記範本) 分頁標籤,然後按一下「Custom」(自訂) 分頁標籤。
按一下
data-governance-demo
切面類型。按一下 [Delete] (刪除),當系統提示時,確認刪除。
建立資料集和資料表
定義中繼資料範本:建立切面類型
將中繼資料新增至資料表:為項目新增切面
清除所用資源
如要避免系統向您的 Google Cloud 帳戶收取本頁所用資源的費用,請按照下列步驟操作。
刪除專案
如要避免付費,最簡單的方法就是刪除您為本快速入門導覽課程建立的專案。
刪除個別資源
如要重複使用專案,請刪除您稍早建立的資源。