Created an Authorized Table

Check my progress

/ 40

Create an authorized view in the Data Publishing project

Check my progress

/ 40

Access the authorized view as a Data Twin

Check my progress

/ 20

This lab may incorporate AI tools to support your learning.

GSP1043

Google Cloud 自學實驗室

總覽

常見情境如下:Google Cloud 資料共用合作夥伴擁有專屬資料集,而客戶可將這些資料集用於分析用途。客戶必須訂閱這類資料、在自己的平台進行查詢、利用自有資料集擴充內容,再自行透過圖表工具製作面向客戶的資訊主頁。藉由這種方式,資料共用合作夥伴可以簡化並加速資料導向解決方案的建構流程,進而創造價值。

總覽示意圖

整合 BigQuery 與 Google Cloud IAM 之後,您可以設定 BigQuery 物件的權限,讓機構內外的使用者都能存取。在本實驗室,您將瞭解資料共用合作夥伴如何在 Google Cloud 或其他雲端服務供應商平台上,為客戶建立資料分身。為配合本實驗室的學習目標,各項專案的客戶都是使用 Google Cloud。

在本實驗室,您將扮演兩個角色,存取三項 Google Cloud 專案。在第一項專案,您扮演資料共用合作夥伴的角色,運用「Data Publishing」專案來共用合作夥伴代管解決方案產生的資料集。在第二項專案,您扮演資料共用合作夥伴的角色,在合作夥伴專案內共用來源資料集,並在「Data Publishing」專案中以授權 view 的形式呈現。在第三項專案,您扮演客戶的角色,以資料分身的形式存取專案的授權 view,並彙整資料與解決方案資料集,建立內容豐富的資料集。

目標

本實驗室的學習內容如下:

  • 在不同專案為「Data Sharing Partner」資料集建立授權 view
  • 確保特定客戶能存取授權 view
  • 彙整客戶產生的資料集與「Data Sharing Partner」資料集,獲得新洞察

設定和需求

瞭解以下事項後,再點選「Start Lab」按鈕

請詳閱以下操作說明。實驗室活動會計時,且中途無法暫停。點選「Start Lab」後就會開始計時,顯示可使用 Google Cloud 資源的時間。

您將在真正的雲端環境完成實作實驗室活動,而不是模擬或示範環境。為此,我們會提供新的暫時憑證,供您在實驗室活動期間登入及存取 Google Cloud。

為了順利完成這個實驗室,請先確認:

  • 可以使用標準的網際網路瀏覽器 (Chrome 瀏覽器為佳)。
注意事項:請使用無痕模式 (建議選項) 或私密瀏覽視窗執行此實驗室,這可以防止個人帳戶和學員帳戶之間的衝突,避免個人帳戶產生額外費用。
  • 是時候完成實驗室活動了!別忘了,活動一旦開始將無法暫停。
注意事項:務必使用實驗室專用的學員帳戶。如果使用其他 Google Cloud 帳戶,可能會產生額外費用。

如何開始研究室及登入 Google Cloud 控制台

  1. 點選「Start Lab」按鈕。如果實驗室會產生費用,畫面上會出現選擇付款方式的對話方塊。左側的「Lab Details」窗格會顯示下列項目:

    • 「Open Google Cloud console」按鈕
    • 剩餘時間
    • 必須在這個研究室中使用的臨時憑證
    • 完成這個實驗室所需的其他資訊 (如有)
  2. 點選「Open Google Cloud console」;如果使用 Chrome 瀏覽器,也能按一下滑鼠右鍵,選取「在無痕視窗中開啟連結」

    接著,實驗室會啟動相關資源,並開啟另一個分頁,顯示「登入」頁面。

    提示:您可以在不同的視窗中並排開啟分頁。

    注意:如果頁面中顯示「選擇帳戶」對話方塊,請點選「使用其他帳戶」
  3. 如有必要,請將下方的 Username 貼到「登入」對話方塊。

    {{{user_0.username | "Username"}}}

    您也可以在「Lab Details」窗格找到 Username。

  4. 點選「下一步」

  5. 複製下方的 Password,並貼到「歡迎使用」對話方塊。

    {{{user_0.password | "Password"}}}

    您也可以在「Lab Details」窗格找到 Password。

  6. 點選「下一步」

    重要事項:請務必使用實驗室提供的憑證,而非自己的 Google Cloud 帳戶憑證。 注意:如果使用自己的 Google Cloud 帳戶來進行這個實驗室,可能會產生額外費用。
  7. 按過後續的所有頁面:

    • 接受條款及細則。
    • 由於這是臨時帳戶,請勿新增救援選項或雙重驗證機制。
    • 請勿申請免費試用。

Google Cloud 控制台稍後會在這個分頁開啟。

注意:如要使用 Google Cloud 產品和服務,請點選「導覽選單」,或在「搜尋」欄位輸入服務或產品名稱。「導覽選單」圖示和搜尋欄位

工作 1:建立授權資料表

在第一項專案,您將扮演資料共用合作夥伴的角色,運用授權資料表建立及共用資料集。

建立客戶授權資料表

  1. 從研究室窗格開啟「Data Sharing Partner Project Console」,並使用相關憑證登入。

  2. 從「導覽選單」依序前往「BigQuery」>「Studio」

  3. 執行下列查詢,選取各州土地面積前 10 大的城市並排序,建立來源資料集:

SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY state_code ORDER BY area_land_meters DESC) AS cities_by_area FROM `bigquery-public-data.geo_us_boundaries.zip_codes`) cities WHERE cities_by_area <= 10 ORDER BY cities.state_code LIMIT 1000;
  1. 在工具列依序點選「更多」>「查詢設定」
注意:如果沒有看到「更多」選項,請點選工具列上的三點圖示來瀏覽。
  1. 選取「為查詢結果設定目標資料表」選項。

  2. 在「資料集」部分,選取 .demo_dataset

  3. 在「資料表 ID」部分,輸入 authorized_table

  4. 其餘欄位保留預設值,點選「繼續」

  5. 點選「執行」再次執行查詢,將結果寫入指定的資料表。

  6. 確認 authorized_table 建立完成。

授權資料集

  1. 在 BigQuery Explorer 窗格開啟 demo_dataset,依序點選「+ 共用」>「授權資料集」

  2. 新增須經授權才能共用的授權 view.demo_dataset

  3. 點選「新增授權」

  4. 點選「關閉」

將 view 存取權授予資料發布者

  1. 在專案的 demo_dataset 中,開啟 authorized_table

  2. 依序點選「共用」>「共用」

  3. 點選「新增主體」,新增 Data PublisherCustomer 使用者:

  4. 選取「BigQuery 資料檢視者」角色。

新增 BigQuery 資料檢視者主體

  1. 點選「儲存」

點選「Check my progress」,確認工作已完成。

建立授權資料表

工作 2:在「Data Publishing」專案中建立授權 view

在第二項專案,您將扮演資料共用合作夥伴的角色,在合作夥伴專案共用來源資料集,並在「Data Publishing」專案中以授權 view 的形式呈現。

  1. 關閉「Data Sharing Partner Project Console」,從研究室窗格開啟「Data Publisher Project Console」,並使用相關憑證登入。

  2. 從「導覽選單」依序前往「BigQuery」>「Studio」

  3. 執行下列查詢,從授權 view 選取紐約州的城市:

SELECT * FROM `{{{isv_project.project_id|Data Sharing Partner Project ID}}}.demo_dataset.authorized_table` WHERE state_code="NY" LIMIT 1000
  1. 在查詢工具列,依序選取「儲存」>「儲存 view」

  2. 點選「資料集」欄位,選取「data_publisher_dataset」

  3. 在「資料表」欄位輸入 authorized_view

  4. 點選「儲存」。現在您應該能看見資料集和資料表並進行查詢。

為「Data Publisher」view 指派 IAM 權限

  1. 在 BigQuery Explorer 窗格開啟 data_publisher_dataset,依序點選「+ 共用」>「授權 view」

  2. 新增須經授權才能共用的授權 view.data_publisher_dataset.authorized_view

  3. 點選「新增授權」

  4. 點選「關閉」

授予使用者存取 view 的權限

  1. 在專案的 data_publisher_dataset 中,開啟 authorized_view

  2. 依序點選「+ 共用」>「共用」

  3. 點選「新增主體」,新增 Customer 使用者:

  4. 選取「BigQuery 資料檢視者」角色。

新增 BigQuery 資料檢視者主體

  1. 點選「儲存」

點選「Check my progress」,確認工作已完成。

在「Data Publishing」專案中建立授權 view

工作 3:以資料分身的形式存取授權 view

在第三項專案,學員將扮演客戶的角色,以資料分身的形式存取專案的授權 view,並彙整資料與解決方案資料集,建立內容豐富的資料集。

  1. 關閉「Data Publisher Console」,從研究室窗格開啟「Customer (Data Twin) Project Console」,並使用相關憑證登入。

  2. 從「導覽選單」依序前往「BigQuery」>「Studio」

  3. 執行下列查詢,存取「Data Sharing Partner Data」發布專案的資料,並彙整客戶資料與合作夥伴 view,進而獲得新洞察。

SELECT cities.zip_code, cities.city, cities.state_code, customers.last_name, customers.first_name FROM `{{{consumer_project_2.project_id|Data Twin Project ID}}}.customer_dataset.customer_info` as customers JOIN `{{{consumer_project.project_id|Data Publisher Project ID}}}.data_publisher_dataset.authorized_view` as cities ON cities.state_code = customers.state;

查詢結果應如下所示:

客戶查詢

  1. 在查詢工具列,依序選取「儲存」>「儲存 view」

  2. 點選「資料集」欄位,選取「customer_dataset」

  3. 在「資料表」欄位輸入 customer_table

  4. 點選「儲存」。現在您應該能看見資料集和資料表並進行查詢。

點選「Check my progress」,確認工作已完成。

以「Data Twin」的身分存取授權 view

工作 4:確認「Customer (Data Twin)」的運作狀況

為確認資料分身的運作狀況,您將在「Data Sharing Partner」專案插入新資料列,並在客戶專案測試這項功能。

  1. 關閉「Customer (Data Twin) Project Console」,從研究室窗格開啟「Data Sharing Partner Project Console」,並使用相關憑證登入。

  2. 從「導覽選單」依序前往「BigQuery」>「Studio」

  3. 執行下列查詢,在「Data Sharing Partner」資料集插入新資料列:

INSERT INTO `{{{isv_project.project_id|Data Sharing Partner Project ID}}}.demo_dataset.authorized_table` (zip_code, city, county, state_fips_code, state_code, state_name, fips_class_code, functional_status, area_land_meters, area_water_meters, cities_by_area) VALUES ("11012", "New City", "New County", "02", "NY", "New York", "B5", "S", 123632007174.0, 544474039.0, 10)

輸出內容應如下所示:

This statement added 1 row to authorized_table.
  1. 關閉「Data Sharing Partner Project Console」,從研究室窗格開啟「Customer (Data Twin) Project Console」,並使用相關憑證登入。

  2. 最後在「Customer (Data Twin)」專案查詢 view,確認新加入的資料列是否可供查看。

SELECT cities.zip_code, cities.city, cities.state_code, customers.last_name, customers.first_name FROM `{{{consumer_project_2.project_id|Data Twin Project ID}}}.customer_dataset.customer_info` as customers JOIN `{{{consumer_project.project_id|Data Publisher Project ID}}}.data_publisher_dataset.authorized_view` as cities ON cities.state_code = customers.state;

結果應如下所示:

final results updated row

恭喜!

在本研究室,您為「Data Sharing Partner」資料集建立了授權 view,與「Data Publishing」專案的使用者共用。接著您登入「Data Publishing」專案,並與「Data Twin」專案的客戶使用者共用授權 view。最後您登入「Customer/Data Twin」專案,彙整當中的資料與客戶專屬資料,建立內容豐富的資料集。

Google Cloud 教育訓練與認證

協助您瞭解如何充分運用 Google Cloud 的技術。我們的課程會介紹專業技能和最佳做法,讓您可以快速掌握要領並持續進修。我們提供從基本到進階等級的訓練課程,並有隨選、線上和虛擬課程等選項,方便您抽空參加。認證可協助您驗證及證明自己在 Google Cloud 技術方面的技能和專業知識。

使用手冊上次更新日期:2025 年 9 月 8 日

實驗室上次測試日期:2025 年 9 月 8 日

Copyright 2026 Google LLC 保留所有權利。Google 和 Google 標誌是 Google LLC 的商標,其他公司和產品名稱則有可能是其關聯公司的商標。

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

This content is not currently available

We will notify you via email when it becomes available

Great!

We will contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Using an Incognito or private browser window is the best way to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.

Complete this quick step to start your lab.