簡體   English   中英

Dataprep 將數據集/表留在 BigQuery 中

[英]Dataprep is leaving Datasets/Tables behind in BigQuery

我正在使用 Google Cloud Dataprep 處理存儲在 BigQuery 中的數據。 我在使用 dataprep/dataflow 創建一個名稱以“temp_dataset_beam_job_”開頭的新數據集時遇到問題

它似乎為 dataprep 創建的失敗和成功的數據流作業創建了臨時數據集。 這是一個問題,因為 BigQuery 很快就會在所有這些流程中變得混亂。

這在過去不是問題。

在此 GitHub 線程中描述了類似的問題: https://github.com/GoogleCloudPlatform/DataflowJavaSDK/issues/609

有沒有辦法不創建臨時數據集,或者在 Cloud Storage 文件夾中創建它們?

我使用 Cloud Scheduler 編寫了一個在 Cloud Run(請參閱本文)中運行的清理腳本。

下面是腳本:

#!/bin/bash

PROJECT={PROJECT_NAME}

# get list of datasets with temp_dataset_beam
# optional: write list of files to cloud storage
obj="gs://{BUCKET_NAME}/maintenance-report-$(date +%s).txt"
bq ls --max_results=100 | grep "temp_dataset_beam" | gsutil -q cp -J - "${obj}"

datasets=$(bq ls --max_results=100 | grep "temp_dataset_beam")

for dataset in $datasets
do
  echo $PROJECT:$dataset
  # WARNING: Uncomment the line below to remove datasets
  # bq rm --dataset=true --force=true $PROJECT:$dataset
done

我通過運行 SQL 腳本發布數據發布直接在 Dataprep 中解決了這個問題,該腳本將在每個作業之后運行。 您可以在 output 手動設置中的 Dataprep 中進行設置。

  (SELECT CONCAT("drop table `<project_id>.",table_schema,".",   table_name, "`;" ) AS value
      FROM <dataset>.INFORMATION_SCHEMA.TABLES -- or region.INFORMATION_SCHEMA.TABLES
      WHERE table_name LIKE "Dataprep_%"
      ORDER BY table_name DESC)
DO
  EXECUTE IMMEDIATE(drop_statement.value);--Here the table is dropped
END FOR;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM