How to Automate Reports in BigQuery

Galaxy Glossary

How can I automate recurring reports in BigQuery?

CREATE SCHEDULE lets you run SQL automatically on a fixed timetable and save results to a managed table or view.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

What does “automating reports” mean in BigQuery?

Automation means BigQuery executes your SQL on a recurring schedule—hourly, daily, or cron-style—without manual clicks, writes results to a target table, and keeps a full history if you choose.

How do I choose between CREATE SCHEDULE and external schedulers?

Use CREATE SCHEDULE for pure-SQL jobs inside BigQuery. Reach for Cloud Scheduler + Cloud Functions only when you need cross-service orchestration, complex branching, or event-driven triggers.

What is the basic CREATE SCHEDULE syntax?

CREATE [OR REPLACE] SCHEDULE schedule_name OPTIONS(...) AS query; defines the frequency, destination, write mode, partitioning, and notification options in one atomic statement.

Step-by-step ecommerce example

1️⃣ Create a dataset analytics.
2️⃣ Run the statement in the Example section below.
3️⃣ Verify a new schedule under BigQuery > Scheduled Queries.
4️⃣ Observe daily tables like analytics.daily_customer_ltv_20240316.

Can I parameterize destination tables?

Yes—use {run_date}, {run_time}, or {run_datetime} inside destination_table_name_template to stamp dates on each report.

Best practices for automated reports

Keep report SQL deterministic, reference fully-qualified tables, use WRITE_TRUNCATE for idempotency, and give each schedule a descriptive name (sales_kpi_daily).

Common mistakes and fixes

Missing dataset permissions: Ensure the scheduled-query service account has BigQuery Data Editor on the destination dataset.

Overwriting history: Avoid WRITE_TRUNCATE when you intend to append. Switch to WRITE_APPEND or add date partitions.

How do I monitor and troubleshoot a schedule?

BigQuery Job History shows each run. Click a failed run to see the error stack. Enable email or Pub/Sub notifications with notification_channel for proactive alerts.

How do I edit or delete a schedule?

Use the console’s Edit button to tweak SQL or frequency, or run bq rm --transfer_config from the CLI to drop it entirely.

Where are the logs stored?

All scheduled query executions produce standard BigQuery job logs, accessible in Cloud Logging under resource.type="bigquery_project".

FAQ

See the FAQ section below for quick answers on cost, limits, and parameter support.

Why How to Automate Reports in BigQuery is important

How to Automate Reports in BigQuery Example Usage


-- Automate a daily customer lifetime value report
CREATE SCHEDULE analytics.ltv_daily
OPTIONS (
  schedule_expression = "every 24 hours",
  destination_table_name_template = "daily_customer_ltv_{run_date}",
  write_disposition = "WRITE_TRUNCATE"
) AS
SELECT  c.id                AS customer_id,
        SUM(oi.quantity*p.price) AS lifetime_value,
        CURRENT_DATE()      AS report_date
FROM    `ecom.Customers`  c
JOIN    `ecom.Orders`     o  ON o.customer_id = c.id
JOIN    `ecom.OrderItems` oi ON oi.order_id    = o.id
JOIN    `ecom.Products`   p  ON p.id           = oi.product_id
GROUP BY customer_id;

How to Automate Reports in BigQuery Syntax


CREATE [ OR REPLACE ] SCHEDULE project.dataset.schedule_name
OPTIONS (
  schedule_expression = "every 24 hours",              -- or cron(0 3 * * *)
  destination_table_name_template = "daily_customer_ltv_{run_date}",
  write_disposition = "WRITE_TRUNCATE",                -- or WRITE_APPEND
  partitioning_field = "run_date",                     -- optional DATE column
  notification_channel = "projects/myproj/notificationChannels/123",
  enabled = TRUE
) AS
SELECT  c.id AS customer_id,
        SUM(oi.quantity * p.price) AS lifetime_value,
        CURRENT_DATE() AS run_date
FROM    `ecom.Customers` AS c
JOIN    `ecom.Orders`      o  ON o.customer_id = c.id
JOIN    `ecom.OrderItems`  oi ON oi.order_id    = o.id
JOIN    `ecom.Products`    p  ON p.id           = oi.product_id
GROUP BY customer_id;

Common Mistakes

Frequently Asked Questions (FAQs)

Does a scheduled query cost more than a manual query?

No. You pay the same on-demand or flat-rate query cost; automation itself is free.

What limits apply to CREATE SCHEDULE?

Each project can have up to 1000 schedules and each schedule must run at least every 15 minutes.

Can I pass runtime parameters?

You can reference {run_date}, {run_time}, and {run_datetime} in SQL via @run_date-style named parameters.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.