簡體   English   中英

BigQuery 是否可以在完成將文件從 Cloud Storage 上傳到 BQ 或通過 Streaming 插入數據時調用端點?

[英]Is it possible for BigQuery to call an endpoint when it has finished uploading a file from Cloud Storage to BQ or when inserting data via Streaming?

我正在從 Cloud Storage 和通過流將文件上傳到 BigQuery,我想知道當 BigQuery 完成將數據加載到表中時,它是否可以調用我選擇的端點。

例如,存儲中的文件:

load_job = bq_client.load_table_from_uri(
                source_uris=uri,
                destination=destination_table,
                job_config=job_config, endpoint="http://my-endpoint.com"
            )

或者,例如,在流媒體中:

rows_to_insert = [
    { "name": "John", "age": 22},
    {"name": "Will", "age": 33},
]

errors = bq_client.insert_rows_json(table_id, rows_to_insert, endpoint="http://my-endpoint.com)

在我的端點中,我有一個 python 代碼,我想在數據插入 BigQuery 時執行該代碼。

插入數據(流式或來自存儲)的代碼不應等待 BigQuery 確認數據已插入,這應該由 BigQuery 調用端點來完成。

有沒有辦法做到這一點?

對於該用例,您可以使用Eventarc Eventarc 根據審計日志捕獲事件並生成事件以調用 Cloud Run 和 Cloud Functions V2(還有 Cloud Workflows,還有更多端點即將到來)。

您必須檢查事件的狀態是否已完成。 您應該會收到每個 state 更新的事件。


另一種解決方案是從Cloud Workflow觸發您的加載作業,並使用阻塞 BigQuery 作業插入連接器等待加載作業結束,然后再進入下一步

暫無
暫無

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

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