在BQ中运行相关的预定查询 [英] Running dependent scheduled queries in BQ
问题描述
我每个月都要在BQ中运行一组查询.设A>B表示A依赖于B.我有以下查询:
I have a set of queries I want to run each month in BQ. Let A > B denote that A DEPENDS on B. I have the below queries:
- q1
- q2>q1
- q3>q1
- q4>q1
如您所见,查询2-4取决于等待查询1完成.我真的很喜欢bigquery中的"计划的查询" 系统,但是无论如何,我可以利用它做这样的事情?主要问题是我无法弄清楚如何让我的计划查询等待BQ控制台中的其他查询完成.我知道我的替代方法是使用Google BQ Jobs,但我确实想看看使用计划查询系统是否有可能实现这一目标.
As you can see, Queries 2-4 depend on waiting for query 1 to be completed. I really like the "Scheduled query" system in bigquery, but is there anyway that I can leverage it do something like this? The main issue is I cant figure out how to tell my scheduled query to wait until some other query has finished in the BQ console. I know my alternative here is using Google BQ Jobs, but really wanted to see if this was possible to pull off with scheduled query system.
推荐答案
在计划的查询中将它们全部作为一个脚本运行.使用 BEGIN ... EXCEPTION 块:>
Run them all as a single script in the scheduled query. Use BEGIN...EXCEPTION block:
isert into q1_results
select ...
from table;
BEGIN
isert into q2_results
select ...
from q1_results;
EXCEPTION WHEN ERROR THEN
END;
BEGIN
isert into q3_results
select ...
from q1_results;
EXCEPTION WHEN ERROR THEN
END;
这篇关于在BQ中运行相关的预定查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!