How to set up a destination table for a scheduled query in Google Bigquery

There are instances where you want to schedule a query in bigquery and save its results into a table, so its ready for you to look at once you login at work in the morning.

From the Bigquery Webui:

Write your select sql and on top of it add a CTAS (Create table as select), and also add a drop table command, so its refreshed per schedule

 DROP TABLE IF EXISTS mydataset.mynewtable;
 CREATE TABLE mydataset.mynewtable
AS
SELECT * FROM mydataset.myothertable;

Now you can go ahead and schedule this query by,

  • Clicking on the schedule query option
  • Choose your desired schedule
  • And hit Schedule

nVector

posted on 01 Nov 19

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds