將中繼資料新增至 BigQuery 資料表

瞭解如何開始運用 Knowledge Catalog (舊稱 Dataplex Universal Catalog) 管理中繼資料。

本快速入門導覽課程說明如何將中繼資料新增至 BigQuery 資料表。在本快速入門導覽課程中,您將執行下列操作:

  1. 根據公開資料集,建立 BigQuery 資料集和資料表。

  2. 建立範本,定義一組相關的中繼資料欄位。

    範本稱為「切面類型」。這組相關中繼資料欄位用於描述資料資產的業務和技術中繼資料,稱為「切面」

  3. 將中繼資料新增至資料表。

    在 Knowledge Catalog 中,每個資料資產都以項目表示。如要將中繼資料附加至資料資產,請為項目新增切面。

事前準備

  1. 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
  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 role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

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

  5. 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

  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 role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

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

  9. 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

必要的角色

如要取得在 BigQuery 資料表中新增中繼資料所需的權限,請要求系統管理員授予您專案的下列 IAM 角色:

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

建立資料集和資料表

  1. 前往 Google Cloud 控制台的「BigQuery Studio」頁面。

    前往 BigQuery Studio

  2. 建立資料集:

    1. 點選左側窗格中的 「Explorer」

      醒目顯示的「Explorer」窗格按鈕。

      如果沒有看到左側窗格,請按一下 「Expand left pane」(展開左側窗格),開啟窗格。

    2. 在「Explorer」窗格中,找出您的專案。按一下 「View actions」(查看動作),然後點選「Create dataset」(建立資料集)

    3. 在「Dataset ID」(資料集 ID) 欄位中,輸入 catalog_demo_dataset

      其他欄位皆使用預設值。

    4. 按一下「Create dataset」(建立資料集)

  3. 將公開資料表複製到資料集:

    1. 在「Explorer」窗格,搜尋名為 bigquery-public-data.new_york_citibike.citibike_stations 的資料表。您可能需要設定搜尋範圍,將 bigquery-public-data 專案納入其中。

      這個資料表是紐約市 (NYC) Citi Bike 行程資料集的一部分,該資料集是包含單車共享計畫資料的公開資料集。

    2. 選取「citibike_stations」資料表。

    3. 按一下「Copy」(複製)。輸入下列資訊:

      • 「Project」(專案):選取專案。
      • 「Dataset」(資料集):選取 catalog_demo_dataset
      • 「Table」(資料表):輸入 bike_stations
    4. 按一下 [複製]

  4. 在「Explorer」窗格找出 catalog_demo_dataset 資料集,並確認 bike_stations 資料表列於該資料集。

定義中繼資料範本:建立切面類型

  1. 前往 Google Cloud 控制台的 Knowledge Catalog「Metadata types」(中繼資料類型) 頁面。

    前往「Metadata types」(中繼資料類型) 頁面

  2. 按一下「Aspect types & tag templates」(切面類型和標記範本) 分頁標籤,然後按一下「Custom」(自訂) 分頁標籤。

  3. 點選「建立切面類型」

  4. 在「Aspect type ID」(切面類型 ID) 欄位中,輸入 data-governance-demo

  5. 在「Location」(位置) 部分,選取 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 控制台,前往 Knowledge Catalog 的「Search」(搜尋) 頁面。

    前往「Search」(搜尋) 頁面

  2. 在搜尋框輸入 catalog_demo_dataset

  3. 選取「bike_stations」資料表。

  4. 為項目新增自訂切面:

    1. 在「Tags & aspects」(標記和切面) 部分,點選「Optional tags & aspects」(選用標記和切面) 旁的 「Add」(新增)

    2. 選取 data-governance-demo 切面類型。

      這會建立以切面類型做為範本的切面。

    3. 輸入下列值:

      • 資料資產來源Copied from NYC Citi Bike Trips public dataset
      • 保留日期:請輸入日期。
      • 資料分類Public
      • 具有 PIIFalse
    4. 點按「Save」(儲存)

  5. 如要查看您新增的中繼資料值,請在「Tags & aspects」(標記和切面) 部分,選取「data-governance-demo」切面。

清除所用資源

為了避免系統向您的 Google Cloud 帳戶收取本頁面所用資源的費用,請按照下列步驟操作。

刪除專案

如要避免付費,最簡單的方法就是刪除您為本快速入門導覽課程建立的專案。

  1. 前往 Google Cloud 控制台的「Manage resources」(管理資源) 頁面。

    前往「Manage resources」(管理資源)

  2. 在專案清單中選取要刪除的專案,然後點選「Delete」(刪除)
  3. 在對話方塊中輸入專案 ID,然後按一下 [Shut down] (關閉) 以刪除專案。

刪除個別資源

如要重複使用專案,請刪除您稍早建立的資源。

  1. 刪除資料集:

    1. 前往 Google Cloud 控制台的「BigQuery Studio」頁面。

      前往 BigQuery Studio

    2. 點選左側窗格中的 「Explorer」

      醒目顯示的「Explorer」窗格按鈕。

    3. 在「Explorer」窗格,搜尋 catalog_demo_dataset 資料集。

    4. 按一下 「View actions」(查看動作),然後按一下「Delete」(刪除)。當系統提示時,確認刪除。

  2. 刪除切面類型:

    1. 前往 Google Cloud 控制台的 Knowledge Catalog「Metadata types」(中繼資料類型) 頁面。

      前往「Metadata types」(中繼資料類型) 頁面

    2. 按一下「Aspect types & tag templates」(切面類型和標記範本) 分頁標籤,然後按一下「Custom」(自訂) 分頁標籤。

    3. 按一下 data-governance-demo 切面類型。

    4. 按一下 [Delete] (刪除),當系統提示時,確認刪除。

後續步驟