英文:
How can I create a cloud function 2nd gen which will be triggered when new entry comes to a table
问题
我想创建一个函数,当新条目插入到名为“staging_tbl”的BigQuery表中时将触发该函数。
staging_tbl
A | B | C
val1 | val2 | val3
通常会插入新条目,我希望每次插入新条目时都会触发一个云函数,其中包含这个条目。
我有一个具有以下触发器的函数:
event_trigger = {
trigger_region = var.region
event_type = "google.cloud.pubsub.topic.v1.messagePublished"
pubsub_topic = "projects/${var.project_id}/topics/greeny_data_inserted_in_tbl"
retry_policy = "RETRY_POLICY_DO_NOT_RETRY"
service_account_email = var.tf_service_account
}
我应该如何创建订阅?
英文:
I would like to create a function which will be triggered when new entry was inserted into a BigQuery table called "staging_tbl".
staging_tbl
A | B | C
val1 | val2 | val3
Often new entries will be inserted and I want that everytime when a new entry is inserted into the table, a cloud function is triggered with this entry.
I have a function with the following trigger:
event_trigger = {
trigger_region = var.region
event_type = "google.cloud.pubsub.topic.v1.messagePublished"
pubsub_topic = "projects/${var.project_id}/topics/greeny_data_inserted_in_tbl"
retry_policy = "RETRY_POLICY_DO_NOT_RETRY"
service_account_email = var.tf_service_account
}
How should I create the subscription?
答案1
得分: 1
将此发布为社区维基。正如Guillaume Blaquiere所说,您可以选择添加一个插入日期列,并每分钟执行一次请求以获取最新行。您可以在云函数中编写脚本,并使用调度程序定期从BigQuery中获取最新数据并将其写入另一个表格。
英文:
Posting this as a community wiki. As what guillaume blaquiere said, you can opt instead to add an insert date column and perform a request every minute to get the latest row. You can write a script in cloud function and use scheduler to schedule pulling latest data from big query and writing it to another table.<br>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论