I plan to have a scheduled query in BigQuery where it run the some query to check for some conditions first. Then, if all condition passed, it will run the aggregation query.
What I can think of right now is to do something like this:
declare A default (select count(*) from mydataset.mytable); --SELECT query to get a value
declare B ...
declare C ...
. . . -- get all of the value into a variable
-- Then use if-else condition e.g.
if A > 100 and B = C+D+E and B = F and ...
then
-- run an aggregation queries
else
select "not pass the condition"; -- don't run anything
end if;
This way is workable but I want to make it more visible when some condition is not met. I can view later what condition is not passed. Any idea to improve this when running in scheduled query?


