Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Google Cloud · Professional Data Engineer

Automating workloads

Professional Data Engineer · Lesson 21 of 23 · 2:37:01

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Google Cloud Professional Data Engineer exam, on the official exam guide. In this lesson: idempotent DAG tasks, sensors, trigger operators, and pools in Airflow, logical dates, retries, and backfills, choosing between scheduled queries, Dataform, Cloud Scheduler, events, and Airflow, and interactive, batch, and continuous queries. Includes three original practice questions, with Cymbal Mobility, a fictional ride-hailing and scooter company, as the example.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Reruns that duplicate

At Cymbal Mobility, every rerun of the nightly DAG adds the same trips to the tables again. A failed day must be processed again after a fix, and month-end reports slow down the analysts' queries. The data engineer must make every run repeatable, and organize the work by priority.

Designing DAGs

A good DAG makes each task a single, idempotent unit of work, rather than a whole program inside one Python task. Airflow orchestrates, and the heavy work runs elsewhere: in BigQuery, Dataflow, or Spark through their operators, and in pods on a separate cluster for custom code. Group related tasks inside a DAG rather than in sub-DAGs, and keep DAG files light, because Airflow parses them continuously. Between two DAGs, a trigger operator at the end of the first starts the second, while a sensor waits for an artifact, like a file or a message. And pools limit how many tasks run at once, to protect quotas and the systems downstream.

Idempotent and repeatable runs

Each run processes one logical date, passed to the tasks through templates, rather than reading the current time. Write results so that a rerun replaces them, for example by overwriting the partition for that date, instead of appending the rows again. Then retries and backfills are safe: a failed day can run again, and past dates can be processed after a fix, with the same result. And enable task retries, since a retry count of zero means that a single failure stops the run.

Choosing a scheduler

Not every job needs Airflow. A BigQuery scheduled query runs SQL on a schedule, with run time and run date parameters, and a time a few minutes off the hour avoids rare double runs. Dataform schedules its SQL workflows with release and workflow configurations. Cloud Scheduler starts a workflow, a function, or a job on a cron schedule, and events, like a new file or a Pub/Sub message, can start work as soon as data arrives. Managed Airflow brings these together, when many jobs depend on each other, across services.

Interactive or batch queries

BigQuery runs queries as interactive jobs by default, meant to start as quickly as possible. Batch jobs have a lower priority: when the project or reservation uses all its compute, they are more likely to wait in a queue, and once started, they run like interactive queries. Use interactive jobs for people waiting on results, like analysts and dashboards, and batch jobs for reports that can wait, so they do not compete. Continuous queries are a third type, which processes data as it arrives, and writes results to a table, to Bigtable, or to Pub/Sub.

Recap

Let's recap. Make each task one idempotent unit of work, and let BigQuery, Dataflow, or Spark do the heavy work. Link DAGs with trigger operators or sensors, and protect quotas with pools. Process one logical date per run, and overwrite its partition, so retries and backfills are safe. Choose the lightest scheduler that fits: scheduled queries, Dataform, Cloud Scheduler, events, or Airflow. And run work that can wait as batch queries, so interactive users go first.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. A nightly task appends the day’s trips to a table, and every retry or rerun adds the same rows again. What should the data engineer change?

    • Set the number of retries of the task to zero
    • Overwrite the partition of the run’s logical date
    • Make the task read the current date when it runs
    • Run the task once a week instead of every night
    Show the answer

    Overwrite the partition of the run’s logical date

    Overwriting the partition of the logical date makes the task idempotent, so reruns give the same result. “Set the number of retries of the task to zero” would stop retries, but a manual rerun would still duplicate the rows. “Make the task read the current date when it runs” would break backfills, since every run would process today. And “Run the task once a week instead of every night” only makes repeated rows less frequent.

  2. One SQL statement must rebuild a daily summary table each morning, with no dependency on any other job. What is the simplest option?

    • A new Managed Airflow environment with one DAG
    • A Dataflow streaming pipeline that runs all day
    • A persistent Spark cluster, with a cron entry
    • A BigQuery scheduled query, every morning
    Show the answer

    A BigQuery scheduled query, every morning

    A scheduled query runs the statement every morning, with nothing else to manage. “A new Managed Airflow environment with one DAG” would add a whole Airflow environment for a single statement. “A Dataflow streaming pipeline that runs all day” would run all the time, for a job needed once a day. And “A persistent Spark cluster, with a cron entry” would mean a cluster and a server schedule to maintain.

  3. Hundreds of month-end report queries start at the same time, and slow down the analysts’ queries in the same project. The reports can finish at any time during the day. What should the data engineer do?

    • Run the report queries as batch jobs
    • Turn the reports into continuous queries
    • Add a dry run before each report query
    • Move all the reports to one hour later
    Show the answer

    Run the report queries as batch jobs

    Batch jobs wait when compute is busy, so the analysts' interactive queries go first. “Turn the reports into continuous queries” would keep queries running all the time, for reports needed once a month. “Add a dry run before each report query” would estimate the data processed, but change no priority. And “Move all the reports to one hour later” would start them all at once again, at another time.