剖析資料

本文說明如何使用資料剖析掃描作業,進一步瞭解資料。BigQuery 會使用 Dataplex Universal Catalog 分析資料的統計特徵,例如平均值、不重複值和最大值。Dataplex Universal Catalog 也會使用這項資訊建議資料品質檢查規則

如要進一步瞭解資料剖析,請參閱「關於資料剖析」。

事前準備

Enable the Dataplex API.

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 API

必要的角色

如要取得建立及管理資料剖析掃描作業所需的權限,請要求管理員在專案或資料表等資源中,授予您下列 IAM 角色:

  • 如要建立、執行、更新及刪除資料剖析掃描作業,您必須在包含資料掃描作業的專案中,具備 Dataplex DataScan 編輯者 (roles/dataplex.dataScanEditor) 角色。
  • 如要允許 Dataplex Universal Catalog 對 BigQuery 資料執行資料剖析掃描,請將下列角色授予 Dataplex Universal Catalog 服務帳戶: 在執行掃描的專案中,授予「BigQuery 工作使用者」(roles/bigquery.jobUser) 角色;在掃描的資料表中,授予「BigQuery 資料檢視者」(roles/bigquery.dataViewer) 角色。
  • 如要對使用 Cloud Storage 資料的 BigQuery 外部資料表執行資料剖析掃描: 在 Cloud Storage bucket 中,授予 Dataplex Universal Catalog 服務帳戶「Storage 物件檢視者」 (roles/storage.objectViewer) 和「Storage 舊版 Bucket 讀取者」 (roles/storage.legacyBucketReader) 角色。
  • 如要查看資料剖析掃描結果、工作和記錄,您必須在包含資料掃描作業的專案中,具備 Dataplex DataScan 檢視者 (roles/dataplex.dataScanViewer) 角色。
  • 如要將資料剖析掃描結果匯出至 BigQuery 資料表,請確認您擁有該資料表的 BigQuery 資料編輯者 (roles/bigquery.dataEditor) 角色。
  • 如要將資料剖析掃描結果發布至 Dataplex Universal Catalog,請在 @bigquery 項目群組中擁有 Dataplex Catalog 編輯者 (roles/dataplex.catalogEditor) 角色。
  • 如要在「資料剖析」分頁中,查看 BigQuery 中已發布的資料剖析掃描結果,您必須具備資料表的 BigQuery 資料檢視者 (roles/bigquery.dataViewer) 角色。

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

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

所需權限

如果您使用自訂角色,則需要授予下列 IAM 權限:

  • 如要建立、執行、更新及刪除資料剖析掃描作業:
    • dataplex.datascans.create 專案:建立 DataScan
    • dataplex.datascans.update 進行資料掃描時,更新 DataScan
    • dataplex.datascans.delete 資料掃描作業 - 刪除 DataScan
    • dataplex.datascans.run 掃描資料 - 執行 DataScan
    • dataplex.datascans.get 資料掃描 - 查看DataScan詳細資料 (不含結果)
    • 專案的 dataplex.datascans.list 權限 - 列出 DataScan
    • 資料掃描工作上的 dataplex.dataScanJobs.get - 讀取 DataScan 工作資源
    • dataplex.dataScanJobs.list on data scan:列出專案中的 DataScan 工作資源
  • 如要允許 Dataplex Universal Catalog 對 BigQuery 資料執行資料設定檔掃描,請按照下列步驟操作:
    • 專案的 bigquery.jobs.create 權限:執行工作
    • 資料表上的 bigquery.tables.get:取得資料表中繼資料
    • 資料表上的 bigquery.tables.getData:取得資料表資料
  • 如要對使用 Cloud Storage 資料的 BigQuery 外部資料表執行資料剖析掃描作業,請按照下列步驟操作:
    • storage.buckets.get (值區) - 讀取值區中繼資料
    • storage.objects.get on object:讀取物件資料
  • 如要查看資料剖析掃描結果、工作和記錄,請按照下列步驟操作:
    • dataplex.datascans.getData 資料掃描:查看DataScan詳細資料,包括結果
    • 專案的 dataplex.datascans.list 權限 - 列出 DataScan
    • 資料掃描工作上的 dataplex.dataScanJobs.get - 讀取 DataScan 工作資源
    • dataplex.dataScanJobs.list on data scan:列出專案中的 DataScan 工作資源
  • 如要將資料剖析掃描結果匯出至 BigQuery 資料表,請按照下列步驟操作:
    • 資料集上的 bigquery.tables.create - 建立表格
    • 資料表上的 bigquery.tables.updateData:將資料寫入資料表
  • 如要將資料剖析掃描結果發布至 Dataplex Universal Catalog,請按照下列步驟操作:
    • 項目群組的 dataplex.entryGroups.useDataProfileAspect:允許 Dataplex Universal Catalog 資料剖析掃描將結果儲存至 Dataplex Universal Catalog
    • 此外,您還需要下列其中一種權限:
      • bigquery.tables.update 資料表:更新資料表中繼資料
      • dataplex.entries.update 項目 - 更新項目
  • 如要在 BigQuery 或 Dataplex Universal Catalog 中查看資料表的已發布資料剖析結果,請按照下列步驟操作:
    • 資料表上的 bigquery.tables.get:取得資料表中繼資料
    • 資料表上的 bigquery.tables.getData:取得資料表資料

如果資料表使用 BigQuery 資料列層級安全性,Dataplex Universal Catalog 只能掃描 Dataplex Universal Catalog 服務帳戶可見的資料列。如要允許 Dataplex Universal Catalog 掃描所有資料列,請將其服務帳戶新增至述詞為 TRUE 的資料列篩選器。

如果資料表使用 BigQuery 資料欄層級安全防護機制,Dataplex Universal Catalog 就必須具備存取權,才能掃描受保護的資料欄。如要授予存取權,請在資料表使用的所有政策標記上,將「Data Catalog Fine-Grained Reader」(roles/datacatalog.fineGrainedReader) 角色指派給 Dataplex Universal Catalog 服務帳戶。建立或更新資料掃描的使用者也需要受保護欄的權限。

將角色授予 Dataplex Universal Catalog 服務帳戶

如要執行資料剖析掃描,Dataplex Universal Catalog 會使用服務帳戶,該帳戶必須具備執行 BigQuery 工作和讀取 BigQuery 資料表資料的權限。如要授予必要角色,請按照下列步驟操作:

  1. 取得 Dataplex Universal Catalog 服務帳戶的電子郵件地址。如果您尚未在這個專案中建立資料剖析或資料品質掃描作業,請執行下列 gcloud 指令來產生服務身分:

    gcloud beta services identity create --service=dataplex.googleapis.com
    

    指令會傳回服務帳戶電子郵件地址,格式如下:service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com

    如果服務帳戶已存在,您可以在 Google Cloud 主控台的 IAM 頁面中,查看具有 Dataplex 名稱的主體,找出服務帳戶的電子郵件地址。

  2. 在專案中授予服務帳戶「BigQuery 工作使用者」(roles/bigquery.jobUser) 角色。服務帳戶取得這個角色後,就能執行掃描的 BigQuery 工作。

    gcloud projects add-iam-policy-binding PROJECT_ID \
        --member="serviceAccount:service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com" \
        --role="roles/bigquery.jobUser"
    

    更改下列內容:

    • PROJECT_ID:您的 Google Cloud 專案 ID。
    • service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com:Dataplex Universal Catalog 服務帳戶的電子郵件地址。
  3. 針對要剖析的每個資料表,授予服務帳戶「BigQuery 資料檢視者」(roles/bigquery.dataViewer) 角色。這個角色可授予資料表的唯讀存取權。

    gcloud bigquery tables add-iam-policy-binding DATASET_ID.TABLE_ID \
        --member="serviceAccount:service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com" \
        --role="roles/bigquery.dataViewer"
    

    更改下列內容:

    • DATASET_ID:包含資料表的資料集 ID。
    • TABLE_ID:要分析的資料表 ID。
    • service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com:Dataplex Universal Catalog 服務帳戶的電子郵件地址。

      建立資料剖析掃描

      控制台

      1. 在 Google Cloud 控制台的 BigQuery「中繼資料管理」頁面,前往「資料剖析與品質」分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 按一下「建立資料剖析掃描」

      3. 選用:輸入「顯示名稱」

      4. 輸入 ID。請參閱「資源命名慣例」。

      5. 選用:輸入說明

      6. 在「Table」(資料表) 欄位中,按一下「Browse」(瀏覽)。選擇要掃描的資料表,然後按一下「選取」

        如為多區域資料集內的資料表,請選擇要建立資料掃描作業的區域。

        如要瀏覽 Dataplex Universal Catalog 湖泊中整理的資料表,請按一下「Browse within Dataplex Lakes」(在 Dataplex 湖泊中瀏覽)

      7. 在「範圍」欄位中,選擇「增量」或「完整資料」

        • 如果選擇「增量資料」,請在「時間戳記資料欄」欄位中,從 BigQuery 資料表選取 DATETIMESTAMP 類型的資料欄,這類資料欄的值只會增加,並能用來識別新的記錄。如要以 DATETIMESTAMP 類型的資料欄做為分區依據,建議使用分區資料欄做為時間戳記欄位。
      8. 選用:如要篩選資料,請執行下列任一操作:

        • 如要依資料列篩選,請勾選「篩選資料列」核取方塊。 輸入有效的 SQL 運算式,該運算式可用於 GoogleSQL 語法中的 WHERE 子句。 例如:col1 >= 0

          篩選器可以是多個資料欄的 SQL 條件組合。例如 col1 >= 0 AND col2 < 10

        • 如要依欄篩選,請選取「篩選欄」核取方塊。

          • 如要在設定檔掃描中加入資料欄,請在「Include columns」(包含資料欄) 欄位中按一下「Browse」(瀏覽)。選取要納入的資料欄,然後按一下「選取」

          • 如要從設定檔掃描中排除資料欄,請在「排除資料欄」欄位中按一下「瀏覽」。選取要排除的資料欄,然後按一下「選取」

      9. 如要對資料剖析掃描作業套用取樣,請在「取樣大小」清單中選取取樣百分比。請選擇介於 0.0% 和 100.0% 之間的百分比值,最多可有 3 位小數。

        • 如果是較大的資料集,請選擇較低的取樣百分比。舉例來說,如果資料表大小為 1 PB,且您輸入的值介於 0.1% 到 1.0% 之間,資料剖析就會取樣 1 到 10 TB 的資料。

        • 抽樣資料中必須至少有 100 筆記錄,才能傳回結果。

        • 如果是增量資料掃描,資料剖析掃描會對最新增量套用取樣。

      10. 選用步驟:在Google Cloud 控制台中,將來源資料表的資料剖析掃描結果發布至 BigQuery 和 Dataplex Universal Catalog 頁面。選取「將結果發布至 BigQuery 和 Dataplex Catalog」核取方塊。

        您可以在來源資料表的 BigQuery 和 Dataplex Universal Catalog 頁面中,查看「資料剖析」分頁的最新掃描結果。如要讓使用者存取已發布的掃描結果,請參閱本文的「授予資料剖析掃描結果的存取權」一節。

        在下列情況下,可能無法使用發布選項:

        • 您沒有資料表的必要權限。
        • 已將另一項資料品質掃描設為發布結果。
      11. 在「時間表」部分,選擇下列其中一個選項:

        • 重複:按照排程執行資料剖析掃描,排程可以是每小時、每天、每週、每月或自訂。指定掃描的執行頻率和時間。如果選擇自訂,請使用 cron 格式指定排程。

        • 依需求:依需求執行資料剖析掃描。

      12. 按一下「繼續」

      13. 選用步驟:將掃描結果匯出至 BigQuery 標準資料表。在「將掃描結果匯出至 BigQuery 資料表」部分,請執行下列操作:

        1. 在「選取 BigQuery 資料集」欄位中,按一下「瀏覽」。選取要用來儲存資料剖析檔掃描結果的 BigQuery 資料集。

        2. 在「BigQuery table」(BigQuery 資料表) 欄位中,指定要儲存資料設定檔掃描結果的資料表。如果使用現有資料表,請確認該資料表與匯出資料表結構定義相容。如果指定的資料表不存在,Dataplex Universal Catalog 會為您建立。

      14. 選用:新增標籤。標籤是鍵/值組合,可用來將相關物件組成群組,或是與其他 Google Cloud 資源分為一組。

      15. 如要建立掃描作業,請按一下「建立」

        如果將排程設為隨選,您也可以按一下「執行掃描」立即執行掃描。

      gcloud

      如要建立資料剖析掃描,請使用 gcloud dataplex datascans create data-profile 指令

      如果來源資料是依 Dataplex Universal Catalog 湖泊整理,請加入 --data-source-entity 旗標:

      gcloud dataplex datascans create data-profile DATASCAN \
      --location=LOCATION \
      --data-source-entity=DATA_SOURCE_ENTITY
      

      如果來源資料未整理到 Dataplex Universal Catalog 湖泊中,請加入 --data-source-resource 旗標:

      gcloud dataplex datascans create data-profile DATASCAN \
      --location=LOCATION \
      --data-source-resource=DATA_SOURCE_RESOURCE
      

      替換下列變數:

      • DATASCAN:資料剖析掃描的名稱。
      • LOCATION:建立資料剖析掃描的 Google Cloud 區域。
      • DATA_SOURCE_ENTITY:包含資料剖析檔掃描資料的 Dataplex Universal Catalog 實體。例如:projects/test-project/locations/test-location/lakes/test-lake/zones/test-zone/entities/test-entity
      • DATA_SOURCE_RESOURCE:包含資料剖析掃描資料的資源名稱。例如://bigquery.googleapis.com/projects/test-project/datasets/test-dataset/tables/test-table

      C#

      C#

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 C# 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog C# API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      using Google.Api.Gax.ResourceNames;
      using Google.Cloud.Dataplex.V1;
      using Google.LongRunning;
      
      public sealed partial class GeneratedDataScanServiceClientSnippets
      {
          /// <summary>Snippet for CreateDataScan</summary>
          /// <remarks>
          /// This snippet has been automatically generated and should be regarded as a code template only.
          /// It will require modifications to work:
          /// - It may require correct/in-range values for request initialization.
          /// - It may require specifying regional endpoints when creating the service client as shown in
          ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
          /// </remarks>
          public void CreateDataScanRequestObject()
          {
              // Create client
              DataScanServiceClient dataScanServiceClient = DataScanServiceClient.Create();
              // Initialize request argument(s)
              CreateDataScanRequest request = new CreateDataScanRequest
              {
                  ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                  DataScan = new DataScan(),
                  DataScanId = "",
                  ValidateOnly = false,
              };
              // Make the request
              Operation<DataScan, OperationMetadata> response = dataScanServiceClient.CreateDataScan(request);
      
              // Poll until the returned long-running operation is complete
              Operation<DataScan, OperationMetadata> completedResponse = response.PollUntilCompleted();
              // Retrieve the operation result
              DataScan result = completedResponse.Result;
      
              // Or get the name of the operation
              string operationName = response.Name;
              // This name can be stored, then the long-running operation retrieved later by name
              Operation<DataScan, OperationMetadata> retrievedResponse = dataScanServiceClient.PollOnceCreateDataScan(operationName);
              // Check if the retrieved long-running operation has completed
              if (retrievedResponse.IsCompleted)
              {
                  // If it has completed, then access the result
                  DataScan retrievedResult = retrievedResponse.Result;
              }
          }
      }

      Go

      Go

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Go 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Go API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      
      package main
      
      import (
      	"context"
      
      	dataplex "cloud.google.com/go/dataplex/apiv1"
      	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
      )
      
      func main() {
      	ctx := context.Background()
      	// This snippet has been automatically generated and should be regarded as a code template only.
      	// It will require modifications to work:
      	// - It may require correct/in-range values for request initialization.
      	// - It may require specifying regional endpoints when creating the service client as shown in:
      	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
      	c, err := dataplex.NewDataScanClient(ctx)
      	if err != nil {
      		// TODO: Handle error.
      	}
      	defer c.Close()
      
      	req := &dataplexpb.CreateDataScanRequest{
      		// TODO: Fill request struct fields.
      		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#CreateDataScanRequest.
      	}
      	op, err := c.CreateDataScan(ctx, req)
      	if err != nil {
      		// TODO: Handle error.
      	}
      
      	resp, err := op.Wait(ctx)
      	if err != nil {
      		// TODO: Handle error.
      	}
      	// TODO: Use resp.
      	_ = resp
      }
      

      Java

      Java

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Java 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Java API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      import com.google.cloud.dataplex.v1.CreateDataScanRequest;
      import com.google.cloud.dataplex.v1.DataScan;
      import com.google.cloud.dataplex.v1.DataScanServiceClient;
      import com.google.cloud.dataplex.v1.LocationName;
      
      public class SyncCreateDataScan {
      
        public static void main(String[] args) throws Exception {
          syncCreateDataScan();
        }
      
        public static void syncCreateDataScan() throws Exception {
          // This snippet has been automatically generated and should be regarded as a code template only.
          // It will require modifications to work:
          // - It may require correct/in-range values for request initialization.
          // - It may require specifying regional endpoints when creating the service client as shown in
          // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
          try (DataScanServiceClient dataScanServiceClient = DataScanServiceClient.create()) {
            CreateDataScanRequest request =
                CreateDataScanRequest.newBuilder()
                    .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                    .setDataScan(DataScan.newBuilder().build())
                    .setDataScanId("dataScanId1260787906")
                    .setValidateOnly(true)
                    .build();
            DataScan response = dataScanServiceClient.createDataScanAsync(request).get();
          }
        }
      }

      Python

      Python

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Python 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Python API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      # This snippet has been automatically generated and should be regarded as a
      # code template only.
      # It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      #   client as shown in:
      #   https://googleapis.dev/python/google-api-core/latest/client_options.html
      from google.cloud import dataplex_v1
      
      
      def sample_create_data_scan():
          # Create a client
          client = dataplex_v1.DataScanServiceClient()
      
          # Initialize request argument(s)
          data_scan = dataplex_v1.DataScan()
          data_scan.data_quality_spec.rules.dimension = "dimension_value"
          data_scan.data.entity = "entity_value"
      
          request = dataplex_v1.CreateDataScanRequest(
              parent="parent_value",
              data_scan=data_scan,
              data_scan_id="data_scan_id_value",
          )
      
          # Make the request
          operation = client.create_data_scan(request=request)
      
          print("Waiting for operation to complete...")
      
          response = operation.result()
      
          # Handle the response
          print(response)
      
      

      Ruby

      Ruby

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Ruby 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Ruby API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      require "google/cloud/dataplex/v1"
      
      ##
      # Snippet for the create_data_scan call in the DataScanService service
      #
      # This snippet has been automatically generated and should be regarded as a code
      # template only. It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      # client as shown in https://cloud.google.com/ruby/docs/reference.
      #
      # This is an auto-generated example demonstrating basic usage of
      # Google::Cloud::Dataplex::V1::DataScanService::Client#create_data_scan.
      #
      def create_data_scan
        # Create a client object. The client can be reused for multiple calls.
        client = Google::Cloud::Dataplex::V1::DataScanService::Client.new
      
        # Create a request. To set request fields, pass in keyword arguments.
        request = Google::Cloud::Dataplex::V1::CreateDataScanRequest.new
      
        # Call the create_data_scan method.
        result = client.create_data_scan request
      
        # The returned object is of type Gapic::Operation. You can use it to
        # check the status of an operation, cancel it, or wait for results.
        # Here is how to wait for a response.
        result.wait_until_done! timeout: 60
        if result.response?
          p result.response
        else
          puts "No response received."
        end
      end

      REST

      如要建立資料剖析掃描作業,請使用 dataScans.create 方法

      建立多項資料剖析掃描作業

      您可以使用 Google Cloud 控制台,同時為 BigQuery 資料集中的多個資料表設定資料剖析掃描作業。

      1. 在 Google Cloud 控制台的 BigQuery「中繼資料管理」頁面,前往「資料剖析與品質」分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 按一下「建立資料剖析掃描」

      3. 選取「多項資料剖析掃描作業」選項。

      4. 輸入 ID 前置字串。Dataplex Universal Catalog 會使用提供的前置字串和不重複的後置字串,自動產生掃描 ID。

      5. 為所有資料剖析掃描輸入說明

      6. 在「Dataset」欄位中,按一下「Browse」(瀏覽)。選取要從中挑選資料表的資料集。按一下「選取」

      7. 如果資料集屬於多區域,請選取要建立資料剖析掃描作業的區域

      8. 設定掃描的常見設定:

        1. 在「範圍」欄位中,選擇「增量」或「完整資料」

        2. 如要對資料剖析掃描套用取樣,請在「取樣大小」清單中選取取樣百分比。

          請選擇介於 0.0% 和 100.0% 之間的百分比值,最多可有 3 位小數。

        3. 選用步驟:在Google Cloud 控制台中,將來源資料表的資料剖析掃描結果發布至 BigQuery 和 Dataplex Universal Catalog 頁面。勾選「將結果發布至 BigQuery 和 Dataplex Catalog」核取方塊。

          您可以在來源資料表的 BigQuery 和 Dataplex Universal Catalog 頁面中,查看「資料剖析」分頁的最新掃描結果。如要讓使用者存取已發布的掃描結果,請參閱本文的「授予資料剖析掃描結果的存取權」一節。

        4. 在「時間表」部分,選擇下列其中一個選項:

          • 重複:按照排程執行資料剖析掃描,包括每小時、每天、每週、每月或自訂。指定掃描的執行頻率和時間。如果選擇自訂,請使用 cron 格式指定排程。

          • 隨選:隨選執行資料剖析掃描。

      9. 按一下「繼續」

      10. 在「選擇資料表」欄位中,按一下「瀏覽」。選擇要掃描的一或多個表格,然後按一下「選取」

      11. 按一下「繼續」

      12. 選用步驟:將掃描結果匯出至 BigQuery 標準資料表。在「將掃描結果匯出至 BigQuery 資料表」部分,請執行下列操作:

        1. 在「選取 BigQuery 資料集」欄位中,按一下「瀏覽」。選取要用來儲存資料剖析檔掃描結果的 BigQuery 資料集。

        2. 在「BigQuery table」(BigQuery 資料表) 欄位中,指定要儲存資料設定檔掃描結果的資料表。如果使用現有資料表,請確認該資料表與匯出資料表結構定義相容。如果指定的資料表不存在,Dataplex Universal Catalog 會為您建立。

          Dataplex Universal Catalog 會為所有資料剖析掃描作業使用相同的結果資料表。

      13. 選用:新增標籤。標籤是鍵/值組合,可用來將相關物件分組,或與其他 Google Cloud 資源組合。

      14. 如要建立掃描作業,請按一下「建立」

        如果將排程設為「按需求」,您也可以點選「執行掃描」立即執行掃描。

      執行資料剖析掃描

      控制台

      1. 在 Google Cloud 控制台的 BigQuery「中繼資料管理」頁面,前往「資料剖析與品質」分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 按一下要執行的資料剖析掃描。
      3. 按一下「立即執行」

      gcloud

      如要執行資料剖析掃描,請使用 gcloud dataplex datascans run 指令

      gcloud dataplex datascans run DATASCAN \
      --location=LOCATION
      

      替換下列變數:

      • DATASCAN:資料剖析掃描的名稱。
      • LOCATION:建立資料剖析掃描的 Google Cloud 區域。

      C#

      C#

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 C# 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog C# API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      using Google.Cloud.Dataplex.V1;
      
      public sealed partial class GeneratedDataScanServiceClientSnippets
      {
          /// <summary>Snippet for RunDataScan</summary>
          /// <remarks>
          /// This snippet has been automatically generated and should be regarded as a code template only.
          /// It will require modifications to work:
          /// - It may require correct/in-range values for request initialization.
          /// - It may require specifying regional endpoints when creating the service client as shown in
          ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
          /// </remarks>
          public void RunDataScanRequestObject()
          {
              // Create client
              DataScanServiceClient dataScanServiceClient = DataScanServiceClient.Create();
              // Initialize request argument(s)
              RunDataScanRequest request = new RunDataScanRequest
              {
                  DataScanName = DataScanName.FromProjectLocationDataScan("[PROJECT]", "[LOCATION]", "[DATASCAN]"),
              };
              // Make the request
              RunDataScanResponse response = dataScanServiceClient.RunDataScan(request);
          }
      }

      Go

      Go

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Go 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Go API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      
      package main
      
      import (
      	"context"
      
      	dataplex "cloud.google.com/go/dataplex/apiv1"
      	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
      )
      
      func main() {
      	ctx := context.Background()
      	// This snippet has been automatically generated and should be regarded as a code template only.
      	// It will require modifications to work:
      	// - It may require correct/in-range values for request initialization.
      	// - It may require specifying regional endpoints when creating the service client as shown in:
      	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
      	c, err := dataplex.NewDataScanClient(ctx)
      	if err != nil {
      		// TODO: Handle error.
      	}
      	defer c.Close()
      
      	req := &dataplexpb.RunDataScanRequest{
      		// TODO: Fill request struct fields.
      		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#RunDataScanRequest.
      	}
      	resp, err := c.RunDataScan(ctx, req)
      	if err != nil {
      		// TODO: Handle error.
      	}
      	// TODO: Use resp.
      	_ = resp
      }
      

      Java

      Java

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Java 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Java API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      import com.google.cloud.dataplex.v1.DataScanName;
      import com.google.cloud.dataplex.v1.DataScanServiceClient;
      import com.google.cloud.dataplex.v1.RunDataScanRequest;
      import com.google.cloud.dataplex.v1.RunDataScanResponse;
      
      public class SyncRunDataScan {
      
        public static void main(String[] args) throws Exception {
          syncRunDataScan();
        }
      
        public static void syncRunDataScan() throws Exception {
          // This snippet has been automatically generated and should be regarded as a code template only.
          // It will require modifications to work:
          // - It may require correct/in-range values for request initialization.
          // - It may require specifying regional endpoints when creating the service client as shown in
          // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
          try (DataScanServiceClient dataScanServiceClient = DataScanServiceClient.create()) {
            RunDataScanRequest request =
                RunDataScanRequest.newBuilder()
                    .setName(DataScanName.of("[PROJECT]", "[LOCATION]", "[DATASCAN]").toString())
                    .build();
            RunDataScanResponse response = dataScanServiceClient.runDataScan(request);
          }
        }
      }

      Python

      Python

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Python 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Python API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      # This snippet has been automatically generated and should be regarded as a
      # code template only.
      # It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      #   client as shown in:
      #   https://googleapis.dev/python/google-api-core/latest/client_options.html
      from google.cloud import dataplex_v1
      
      
      def sample_run_data_scan():
          # Create a client
          client = dataplex_v1.DataScanServiceClient()
      
          # Initialize request argument(s)
          request = dataplex_v1.RunDataScanRequest(
              name="name_value",
          )
      
          # Make the request
          response = client.run_data_scan(request=request)
      
          # Handle the response
          print(response)
      
      

      Ruby

      Ruby

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Ruby 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Ruby API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      require "google/cloud/dataplex/v1"
      
      ##
      # Snippet for the run_data_scan call in the DataScanService service
      #
      # This snippet has been automatically generated and should be regarded as a code
      # template only. It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      # client as shown in https://cloud.google.com/ruby/docs/reference.
      #
      # This is an auto-generated example demonstrating basic usage of
      # Google::Cloud::Dataplex::V1::DataScanService::Client#run_data_scan.
      #
      def run_data_scan
        # Create a client object. The client can be reused for multiple calls.
        client = Google::Cloud::Dataplex::V1::DataScanService::Client.new
      
        # Create a request. To set request fields, pass in keyword arguments.
        request = Google::Cloud::Dataplex::V1::RunDataScanRequest.new
      
        # Call the run_data_scan method.
        result = client.run_data_scan request
      
        # The returned object is of type Google::Cloud::Dataplex::V1::RunDataScanResponse.
        p result
      end

      REST

      如要執行資料剖析掃描,請使用 dataScans.run 方法

      查看資料剖析掃描結果

      控制台

      1. 在 Google Cloud 控制台的 BigQuery「中繼資料管理」頁面,前往「資料剖析與品質」分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 按一下資料剖析掃描的名稱。

        • 「總覽」部分會顯示最近一次工作的相關資訊,包括掃描執行時間、掃描的資料表記錄數和工作狀態。

        • 「資料剖析掃描設定」部分會顯示掃描的詳細資料。

      3. 如要查看工作的詳細資訊,例如掃描的資料表欄、掃描中找到的欄統計資料和工作記錄,請按一下「工作記錄」分頁標籤。然後按一下工作 ID。

      gcloud

      如要查看資料剖析掃描工作結果,請使用 gcloud dataplex datascans jobs describe 指令

      gcloud dataplex datascans jobs describe JOB \
      --location=LOCATION \
      --datascan=DATASCAN \
      --view=FULL
      

      替換下列變數:

      • JOB:資料剖析掃描作業的作業 ID。
      • LOCATION:建立資料剖析掃描的 Google Cloud 區域。
      • DATASCAN:作業所屬資料剖析掃描的名稱。
      • --view=FULL:如要查看掃描作業結果,請指定 FULL

      C#

      C#

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 C# 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog C# API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      using Google.Cloud.Dataplex.V1;
      
      public sealed partial class GeneratedDataScanServiceClientSnippets
      {
          /// <summary>Snippet for GetDataScan</summary>
          /// <remarks>
          /// This snippet has been automatically generated and should be regarded as a code template only.
          /// It will require modifications to work:
          /// - It may require correct/in-range values for request initialization.
          /// - It may require specifying regional endpoints when creating the service client as shown in
          ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
          /// </remarks>
          public void GetDataScanRequestObject()
          {
              // Create client
              DataScanServiceClient dataScanServiceClient = DataScanServiceClient.Create();
              // Initialize request argument(s)
              GetDataScanRequest request = new GetDataScanRequest
              {
                  DataScanName = DataScanName.FromProjectLocationDataScan("[PROJECT]", "[LOCATION]", "[DATASCAN]"),
                  View = GetDataScanRequest.Types.DataScanView.Unspecified,
              };
              // Make the request
              DataScan response = dataScanServiceClient.GetDataScan(request);
          }
      }

      Go

      Go

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Go 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Go API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      
      package main
      
      import (
      	"context"
      
      	dataplex "cloud.google.com/go/dataplex/apiv1"
      	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
      )
      
      func main() {
      	ctx := context.Background()
      	// This snippet has been automatically generated and should be regarded as a code template only.
      	// It will require modifications to work:
      	// - It may require correct/in-range values for request initialization.
      	// - It may require specifying regional endpoints when creating the service client as shown in:
      	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
      	c, err := dataplex.NewDataScanClient(ctx)
      	if err != nil {
      		// TODO: Handle error.
      	}
      	defer c.Close()
      
      	req := &dataplexpb.GetDataScanRequest{
      		// TODO: Fill request struct fields.
      		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#GetDataScanRequest.
      	}
      	resp, err := c.GetDataScan(ctx, req)
      	if err != nil {
      		// TODO: Handle error.
      	}
      	// TODO: Use resp.
      	_ = resp
      }
      

      Java

      Java

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Java 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Java API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      import com.google.cloud.dataplex.v1.DataScan;
      import com.google.cloud.dataplex.v1.DataScanName;
      import com.google.cloud.dataplex.v1.DataScanServiceClient;
      import com.google.cloud.dataplex.v1.GetDataScanRequest;
      
      public class SyncGetDataScan {
      
        public static void main(String[] args) throws Exception {
          syncGetDataScan();
        }
      
        public static void syncGetDataScan() throws Exception {
          // This snippet has been automatically generated and should be regarded as a code template only.
          // It will require modifications to work:
          // - It may require correct/in-range values for request initialization.
          // - It may require specifying regional endpoints when creating the service client as shown in
          // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
          try (DataScanServiceClient dataScanServiceClient = DataScanServiceClient.create()) {
            GetDataScanRequest request =
                GetDataScanRequest.newBuilder()
                    .setName(DataScanName.of("[PROJECT]", "[LOCATION]", "[DATASCAN]").toString())
                    .build();
            DataScan response = dataScanServiceClient.getDataScan(request);
          }
        }
      }

      Python

      Python

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Python 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Python API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      # This snippet has been automatically generated and should be regarded as a
      # code template only.
      # It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      #   client as shown in:
      #   https://googleapis.dev/python/google-api-core/latest/client_options.html
      from google.cloud import dataplex_v1
      
      
      def sample_get_data_scan():
          # Create a client
          client = dataplex_v1.DataScanServiceClient()
      
          # Initialize request argument(s)
          request = dataplex_v1.GetDataScanRequest(
              name="name_value",
          )
      
          # Make the request
          response = client.get_data_scan(request=request)
      
          # Handle the response
          print(response)
      
      

      Ruby

      Ruby

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Ruby 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Ruby API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      require "google/cloud/dataplex/v1"
      
      ##
      # Snippet for the get_data_scan call in the DataScanService service
      #
      # This snippet has been automatically generated and should be regarded as a code
      # template only. It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      # client as shown in https://cloud.google.com/ruby/docs/reference.
      #
      # This is an auto-generated example demonstrating basic usage of
      # Google::Cloud::Dataplex::V1::DataScanService::Client#get_data_scan.
      #
      def get_data_scan
        # Create a client object. The client can be reused for multiple calls.
        client = Google::Cloud::Dataplex::V1::DataScanService::Client.new
      
        # Create a request. To set request fields, pass in keyword arguments.
        request = Google::Cloud::Dataplex::V1::GetDataScanRequest.new
      
        # Call the get_data_scan method.
        result = client.get_data_scan request
      
        # The returned object is of type Google::Cloud::Dataplex::V1::DataScan.
        p result
      end

      REST

      如要查看資料剖析掃描結果,請使用 dataScans.get 方法

      查看已發布的結果

      如果資料剖析掃描結果發布至 Google Cloud 控制台的 BigQuery 和 Dataplex Universal Catalog 頁面,您可以在來源資料表的「資料剖析」分頁中查看最新的掃描結果。

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

        前往「BigQuery」

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

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

        如果沒有看到左側窗格,請按一下「展開左側窗格」圖示 開啟窗格。

      3. 在「Explorer」窗格中,按一下「Datasets」(資料集),然後點選您的資料集。

      4. 依序點按「總覽」>「資料表」,然後選取要查看資料剖析掃描結果的資料表。

      5. 按一下「資料設定檔」分頁標籤。

        系統會顯示最新發布的結果。

      查看最近一次的資料剖析掃描工作

      控制台

      1. 在 Google Cloud 控制台的 BigQuery「中繼資料管理」頁面,前往「資料剖析與品質」分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 按一下資料剖析掃描的名稱。

      3. 按一下「最近一次的工作結果」分頁標籤。

        如果至少有一項工作順利完成,最近一次的工作結果分頁就會顯示最近一次工作的相關資訊。這份報表會列出掃描的資料表欄,以及掃描時發現的欄統計資料。

      gcloud

      如要查看最近一次成功執行的資料剖析掃描,請使用 gcloud dataplex datascans describe 指令

      gcloud dataplex datascans describe DATASCAN \
      --location=LOCATION \
      --view=FULL
      

      替換下列變數:

      • DATASCAN:要查看最新作業的資料剖析掃描名稱。
      • LOCATION:建立資料剖析掃描的 Google Cloud 區域。
      • --view=FULL:如要查看掃描作業結果,請指定 FULL

      REST

      如要查看最近的掃描工作,請使用 dataScans.get 方法

      查看歷來掃描結果

      Dataplex Universal Catalog 會儲存最近 300 項工作或過去一年的資料剖析掃描記錄 (以先到者為準)。

      控制台

      1. 在 Google Cloud 控制台的 BigQuery「中繼資料管理」頁面,前往「資料剖析與品質」分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 按一下資料剖析掃描的名稱。

      3. 按一下「工作記錄」分頁標籤。

        「工作記錄」分頁提供過去工作相關資訊,例如每項工作掃描的記錄數量、工作狀態,以及工作執行時間。

      4. 如要查看工作的詳細資訊,請按一下「工作 ID」欄中的任一工作。

      gcloud

      如要查看歷來資料剖析掃描工作,請使用 gcloud dataplex datascans jobs list 指令

      gcloud dataplex datascans jobs list \
      --location=LOCATION \
      --datascan=DATASCAN
      

      替換下列變數:

      • LOCATION:建立資料剖析掃描的 Google Cloud 區域。
      • DATASCAN:要查看作業的資料剖析掃描名稱。

      C#

      C#

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 C# 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog C# API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      using Google.Api.Gax;
      using Google.Cloud.Dataplex.V1;
      using System;
      
      public sealed partial class GeneratedDataScanServiceClientSnippets
      {
          /// <summary>Snippet for ListDataScanJobs</summary>
          /// <remarks>
          /// This snippet has been automatically generated and should be regarded as a code template only.
          /// It will require modifications to work:
          /// - It may require correct/in-range values for request initialization.
          /// - It may require specifying regional endpoints when creating the service client as shown in
          ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
          /// </remarks>
          public void ListDataScanJobsRequestObject()
          {
              // Create client
              DataScanServiceClient dataScanServiceClient = DataScanServiceClient.Create();
              // Initialize request argument(s)
              ListDataScanJobsRequest request = new ListDataScanJobsRequest
              {
                  ParentAsDataScanName = DataScanName.FromProjectLocationDataScan("[PROJECT]", "[LOCATION]", "[DATASCAN]"),
                  Filter = "",
              };
              // Make the request
              PagedEnumerable<ListDataScanJobsResponse, DataScanJob> response = dataScanServiceClient.ListDataScanJobs(request);
      
              // Iterate over all response items, lazily performing RPCs as required
              foreach (DataScanJob item in response)
              {
                  // Do something with each item
                  Console.WriteLine(item);
              }
      
              // Or iterate over pages (of server-defined size), performing one RPC per page
              foreach (ListDataScanJobsResponse page in response.AsRawResponses())
              {
                  // Do something with each page of items
                  Console.WriteLine("A page of results:");
                  foreach (DataScanJob item in page)
                  {
                      // Do something with each item
                      Console.WriteLine(item);
                  }
              }
      
              // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
              int pageSize = 10;
              Page<DataScanJob> singlePage = response.ReadPage(pageSize);
              // Do something with the page of items
              Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
              foreach (DataScanJob item in singlePage)
              {
                  // Do something with each item
                  Console.WriteLine(item);
              }
              // Store the pageToken, for when the next page is required.
              string nextPageToken = singlePage.NextPageToken;
          }
      }

      Go

      Go

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Go 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Go API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      
      package main
      
      import (
      	"context"
      
      	dataplex "cloud.google.com/go/dataplex/apiv1"
      	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
      	"google.golang.org/api/iterator"
      )
      
      func main() {
      	ctx := context.Background()
      	// This snippet has been automatically generated and should be regarded as a code template only.
      	// It will require modifications to work:
      	// - It may require correct/in-range values for request initialization.
      	// - It may require specifying regional endpoints when creating the service client as shown in:
      	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
      	c, err := dataplex.NewDataScanClient(ctx)
      	if err != nil {
      		// TODO: Handle error.
      	}
      	defer c.Close()
      
      	req := &dataplexpb.ListDataScanJobsRequest{
      		// TODO: Fill request struct fields.
      		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#ListDataScanJobsRequest.
      	}
      	it := c.ListDataScanJobs(ctx, req)
      	for {
      		resp, err := it.Next()
      		if err == iterator.Done {
      			break
      		}
      		if err != nil {
      			// TODO: Handle error.
      		}
      		// TODO: Use resp.
      		_ = resp
      
      		// If you need to access the underlying RPC response,
      		// you can do so by casting the `Response` as below.
      		// Otherwise, remove this line. Only populated after
      		// first call to Next(). Not safe for concurrent access.
      		_ = it.Response.(*dataplexpb.ListDataScanJobsResponse)
      	}
      }
      

      Java

      Java

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Java 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Java API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      import com.google.cloud.dataplex.v1.DataScanJob;
      import com.google.cloud.dataplex.v1.DataScanName;
      import com.google.cloud.dataplex.v1.DataScanServiceClient;
      import com.google.cloud.dataplex.v1.ListDataScanJobsRequest;
      
      public class SyncListDataScanJobs {
      
        public static void main(String[] args) throws Exception {
          syncListDataScanJobs();
        }
      
        public static void syncListDataScanJobs() throws Exception {
          // This snippet has been automatically generated and should be regarded as a code template only.
          // It will require modifications to work:
          // - It may require correct/in-range values for request initialization.
          // - It may require specifying regional endpoints when creating the service client as shown in
          // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
          try (DataScanServiceClient dataScanServiceClient = DataScanServiceClient.create()) {
            ListDataScanJobsRequest request =
                ListDataScanJobsRequest.newBuilder()
                    .setParent(DataScanName.of("[PROJECT]", "[LOCATION]", "[DATASCAN]").toString())
                    .setPageSize(883849137)
                    .setPageToken("pageToken873572522")
                    .setFilter("filter-1274492040")
                    .build();
            for (DataScanJob element : dataScanServiceClient.listDataScanJobs(request).iterateAll()) {
              // doThingsWith(element);
            }
          }
        }
      }

      Python

      Python

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Python 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Python API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      # This snippet has been automatically generated and should be regarded as a
      # code template only.
      # It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      #   client as shown in:
      #   https://googleapis.dev/python/google-api-core/latest/client_options.html
      from google.cloud import dataplex_v1
      
      
      def sample_list_data_scan_jobs():
          # Create a client
          client = dataplex_v1.DataScanServiceClient()
      
          # Initialize request argument(s)
          request = dataplex_v1.ListDataScanJobsRequest(
              parent="parent_value",
          )
      
          # Make the request
          page_result = client.list_data_scan_jobs(request=request)
      
          # Handle the response
          for response in page_result:
              print(response)
      
      

      Ruby

      Ruby

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Ruby 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Ruby API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      require "google/cloud/dataplex/v1"
      
      ##
      # Snippet for the list_data_scan_jobs call in the DataScanService service
      #
      # This snippet has been automatically generated and should be regarded as a code
      # template only. It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      # client as shown in https://cloud.google.com/ruby/docs/reference.
      #
      # This is an auto-generated example demonstrating basic usage of
      # Google::Cloud::Dataplex::V1::DataScanService::Client#list_data_scan_jobs.
      #
      def list_data_scan_jobs
        # Create a client object. The client can be reused for multiple calls.
        client = Google::Cloud::Dataplex::V1::DataScanService::Client.new
      
        # Create a request. To set request fields, pass in keyword arguments.
        request = Google::Cloud::Dataplex::V1::ListDataScanJobsRequest.new
      
        # Call the list_data_scan_jobs method.
        result = client.list_data_scan_jobs request
      
        # The returned object is of type Gapic::PagedEnumerable. You can iterate
        # over elements, and API calls will be issued to fetch pages as needed.
        result.each do |item|
          # Each element is of type ::Google::Cloud::Dataplex::V1::DataScanJob.
          p item
        end
      end

      REST

      如要查看歷來資料剖析掃描工作,請使用 dataScans.jobs.list 方法

      查看資料表的資料剖析掃描

      如要查看適用於特定資料表的資料剖析掃描,請按照下列步驟操作:

      1. 在 Google Cloud 控制台的 BigQuery「Metadata curation」(中繼資料管理) 頁面,前往「Data profiling & quality」(資料剖析與品質) 分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 依資料表名稱和掃描類型篩選清單。

      授予資料剖析掃描結果的存取權

      如要讓貴機構使用者查看掃描結果,請按照下列步驟操作:

      1. 在 Google Cloud 控制台的 BigQuery「中繼資料管理」頁面,前往「資料剖析與品質」分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 按一下要分享結果的資料品質掃描。

      3. 按一下「Permissions」(權限) 分頁標籤。

      4. 請執行下列步驟:

        • 如要授予主體存取權,請按一下「授予存取權」。將「Dataplex DataScan 資料檢視者」角色授予相關聯的主體。
        • 如要移除主體的存取權,請選取要移除 Dataplex DataScan DataViewer 角色的主體。依序點選 「移除存取權」,然後在系統提示時確認。

      管理特定資料表的資料剖析掃描

      本文的步驟說明如何使用Google Cloud 控制台的 BigQuery「Metadata curation」(中繼資料管理) >「Data profiling & quality」(資料剖析與品質) 頁面,管理專案中的資料剖析掃描作業。

      您也可以在處理特定資料表時,建立及管理資料剖析掃描作業。在 Google Cloud 控制台中,前往資料表的 BigQuery 頁面,然後使用「資料設定檔」分頁標籤。請執行下列步驟:

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

        前往「BigQuery」頁面

        在「Explorer」窗格 (左側窗格) 中,按一下「Datasets」,然後按一下您的資料集。 現在點選「總覽」>「表格」,然後選取要查看資料設定檔掃描結果的表格。

      2. 按一下「資料設定檔」分頁標籤。

      3. 視資料表是否已發布資料剖析掃描結果而定,您可以透過下列方式使用資料表的資料剖析掃描:

        • 已發布資料剖析掃描結果:頁面會顯示最新發布的掃描結果。

          如要管理這個資料表的資料剖析掃描作業,請按一下「資料剖析掃描」,然後選取下列其中一個選項:

          • 建立新的掃描作業:建立新的資料剖析掃描作業。詳情請參閱本文的「建立資料剖析掃描」一節。從資料表的詳細資料頁面建立掃描時,系統會預先選取該資料表。

          • 「立即執行」:執行掃描。

          • 編輯掃描作業設定:編輯設定,包括顯示名稱、篩選器、取樣大小和時間表。

          • 管理掃描作業權限:控管哪些人可以存取掃描結果。 詳情請參閱本文的「授予資料剖析掃描結果的存取權」一節。

          • 查看歷來結果:查看先前資料剖析掃描工作的詳細資訊。詳情請參閱本文的「查看資料剖析掃描結果」和「查看歷來掃描結果」部分。

          • 查看所有掃描作業:查看適用於這個資料表的資料剖析掃描作業清單。

        • 資料剖析掃描結果未發布:按一下「快速剖析資料」旁邊的選單,然後選取下列任一選項:

          • 自訂資料剖析作業:建立新的資料剖析掃描作業。詳情請參閱本文的「建立資料剖析掃描」一節。從資料表的詳細資料頁面建立掃描時,系統會預先選取該資料表。

          • 查看先前的剖析檔:查看適用於這個資料表的資料剖析掃描清單。

      更新資料剖析掃描

      控制台

      1. 在 Google Cloud 控制台的 BigQuery「中繼資料管理」頁面,前往「資料剖析與品質」分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 按一下資料剖析掃描的名稱。

      3. 按一下「編輯」,然後編輯值。

      4. 按一下 [儲存]

      gcloud

      如要更新資料剖析掃描,請使用 gcloud dataplex datascans update data-profile 指令

      gcloud dataplex datascans update data-profile DATASCAN \
      --location=LOCATION \
      --description=DESCRIPTION
      

      替換下列變數:

      • DATASCAN:要更新的資料剖析掃描名稱。
      • LOCATION:建立資料剖析掃描的 Google Cloud 區域。
      • DESCRIPTION:資料設定檔掃描的新說明。

      C#

      C#

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 C# 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog C# API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      using Google.Cloud.Dataplex.V1;
      using Google.LongRunning;
      using Google.Protobuf.WellKnownTypes;
      
      public sealed partial class GeneratedDataScanServiceClientSnippets
      {
          /// <summary>Snippet for UpdateDataScan</summary>
          /// <remarks>
          /// This snippet has been automatically generated and should be regarded as a code template only.
          /// It will require modifications to work:
          /// - It may require correct/in-range values for request initialization.
          /// - It may require specifying regional endpoints when creating the service client as shown in
          ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
          /// </remarks>
          public void UpdateDataScanRequestObject()
          {
              // Create client
              DataScanServiceClient dataScanServiceClient = DataScanServiceClient.Create();
              // Initialize request argument(s)
              UpdateDataScanRequest request = new UpdateDataScanRequest
              {
                  DataScan = new DataScan(),
                  UpdateMask = new FieldMask(),
                  ValidateOnly = false,
              };
              // Make the request
              Operation<DataScan, OperationMetadata> response = dataScanServiceClient.UpdateDataScan(request);
      
              // Poll until the returned long-running operation is complete
              Operation<DataScan, OperationMetadata> completedResponse = response.PollUntilCompleted();
              // Retrieve the operation result
              DataScan result = completedResponse.Result;
      
              // Or get the name of the operation
              string operationName = response.Name;
              // This name can be stored, then the long-running operation retrieved later by name
              Operation<DataScan, OperationMetadata> retrievedResponse = dataScanServiceClient.PollOnceUpdateDataScan(operationName);
              // Check if the retrieved long-running operation has completed
              if (retrievedResponse.IsCompleted)
              {
                  // If it has completed, then access the result
                  DataScan retrievedResult = retrievedResponse.Result;
              }
          }
      }

      Go

      Go

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Go 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Go API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      
      package main
      
      import (
      	"context"
      
      	dataplex "cloud.google.com/go/dataplex/apiv1"
      	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
      )
      
      func main() {
      	ctx := context.Background()
      	// This snippet has been automatically generated and should be regarded as a code template only.
      	// It will require modifications to work:
      	// - It may require correct/in-range values for request initialization.
      	// - It may require specifying regional endpoints when creating the service client as shown in:
      	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
      	c, err := dataplex.NewDataScanClient(ctx)
      	if err != nil {
      		// TODO: Handle error.
      	}
      	defer c.Close()
      
      	req := &dataplexpb.UpdateDataScanRequest{
      		// TODO: Fill request struct fields.
      		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#UpdateDataScanRequest.
      	}
      	op, err := c.UpdateDataScan(ctx, req)
      	if err != nil {
      		// TODO: Handle error.
      	}
      
      	resp, err := op.Wait(ctx)
      	if err != nil {
      		// TODO: Handle error.
      	}
      	// TODO: Use resp.
      	_ = resp
      }
      

      Java

      Java

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Java 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Java API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      import com.google.cloud.dataplex.v1.DataScan;
      import com.google.cloud.dataplex.v1.DataScanServiceClient;
      import com.google.cloud.dataplex.v1.UpdateDataScanRequest;
      import com.google.protobuf.FieldMask;
      
      public class SyncUpdateDataScan {
      
        public static void main(String[] args) throws Exception {
          syncUpdateDataScan();
        }
      
        public static void syncUpdateDataScan() throws Exception {
          // This snippet has been automatically generated and should be regarded as a code template only.
          // It will require modifications to work:
          // - It may require correct/in-range values for request initialization.
          // - It may require specifying regional endpoints when creating the service client as shown in
          // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
          try (DataScanServiceClient dataScanServiceClient = DataScanServiceClient.create()) {
            UpdateDataScanRequest request =
                UpdateDataScanRequest.newBuilder()
                    .setDataScan(DataScan.newBuilder().build())
                    .setUpdateMask(FieldMask.newBuilder().build())
                    .setValidateOnly(true)
                    .build();
            DataScan response = dataScanServiceClient.updateDataScanAsync(request).get();
          }
        }
      }

      Python

      Python

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Python 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Python API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      # This snippet has been automatically generated and should be regarded as a
      # code template only.
      # It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      #   client as shown in:
      #   https://googleapis.dev/python/google-api-core/latest/client_options.html
      from google.cloud import dataplex_v1
      
      
      def sample_update_data_scan():
          # Create a client
          client = dataplex_v1.DataScanServiceClient()
      
          # Initialize request argument(s)
          data_scan = dataplex_v1.DataScan()
          data_scan.data_quality_spec.rules.dimension = "dimension_value"
          data_scan.data.entity = "entity_value"
      
          request = dataplex_v1.UpdateDataScanRequest(
              data_scan=data_scan,
          )
      
          # Make the request
          operation = client.update_data_scan(request=request)
      
          print("Waiting for operation to complete...")
      
          response = operation.result()
      
          # Handle the response
          print(response)
      
      

      Ruby

      Ruby

      在試用這個範例之前,請先按照「使用用戶端程式庫的 Dataplex Universal Catalog 快速入門導覽課程」中的 Ruby 設定操作說明進行操作。詳情請參閱 Dataplex Universal Catalog Ruby API 參考文件

      如要向 Dataplex Universal Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

      require "google/cloud/dataplex/v1"
      
      ##
      # Snippet for the update_data_scan call in the DataScanService service
      #
      # This snippet has been automatically generated and should be regarded as a code
      # template only. It will require modifications to work:
      # - It may require correct/in-range values for request initialization.
      # - It may require specifying regional endpoints when creating the service
      # client as shown in https://cloud.google.com/ruby/docs/reference.
      #
      # This is an auto-generated example demonstrating basic usage of
      # Google::Cloud::Dataplex::V1::DataScanService::Client#update_data_scan.
      #
      def update_data_scan
        # Create a client object. The client can be reused for multiple calls.
        client = Google::Cloud::Dataplex::V1::DataScanService::Client.new
      
        # Create a request. To set request fields, pass in keyword arguments.
        request = Google::Cloud::Dataplex::V1::UpdateDataScanRequest.new
      
        # Call the update_data_scan method.
        result = client.update_data_scan request
      
        # The returned object is of type Gapic::Operation. You can use it to
        # check the status of an operation, cancel it, or wait for results.
        # Here is how to wait for a response.
        result.wait_until_done! timeout: 60
        if result.response?
          p result.response
        else
          puts "No response received."
        end
      end

      REST

      如要編輯資料剖析掃描作業,請使用 dataScans.patch 方法

      刪除資料剖析掃描

      控制台

      1. 在 Google Cloud 控制台的 BigQuery「中繼資料管理」頁面,前往「資料剖析與品質」分頁。

        前往「Data profiling & quality」(資料剖析與品質) 頁面

      2. 按一下要刪除的掃描結果。

      3. 按一下「Delete」(刪除),然後在系統提示時確認刪除。

      gcloud

      如要刪除資料剖析檔掃描作業,請使用 gcloud dataplex datascans delete 指令

      gcloud dataplex datascans delete DATASCAN \
      --location=LOCATION --async
      

      替換下列變數:

      • DATASCAN:要刪除的資料設定檔掃描名稱。
      • LOCATION:建立資料剖析掃描的 Google Cloud 區域。

      REST

      如要刪除資料剖析檔掃描作業,請使用 dataScans.delete 方法

      後續步驟