將中繼資料新增至 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. 在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。

    5. 在「Select a role」(選取角色) 清單中,選取角色。
    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. 在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。

    5. 在「Select a role」(選取角色) 清單中,選取角色。
    6. 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
    7. 按一下 [Save]
  10. 建立資料集和資料表

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

      前往 BigQuery Studio

    2. 建立資料集:

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

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

        其他欄位皆使用預設值。

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

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

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

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

      2. 選取「citibike_stations」資料表。

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

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

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

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

    1. 在 Google Cloud 控制台,前往 Dataplex Universal Catalog 的「Catalog」(目錄) 頁面。

      前往「Catalog」(目錄) 頁面

    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 控制台,前往 Dataplex Universal 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. 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. 在「Explorer」窗格中,搜尋 catalog_demo_dataset 資料集。

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

    2. 刪除切面類型:

      1. 在 Google Cloud 控制台,前往 Dataplex Universal Catalog 的「Catalog」(目錄) 頁面。

        前往「Catalog」(目錄) 頁面

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

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

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

    後續步驟