Prepare and test your skills

Prepare and test your skills

A Directed Acyclic Graph (DAG) is a Python-defined workflow in Managed Service for Apache Airflow (opens in a new tab) that sets task order so downstream tasks run only after upstream tasks complete. Dependencies are declared in code with >> and <<, as in hello_python >> goodbye_bash, where the first task must finish before the second starts. Each task is one unit of work, such as preparing data for ingestion, monitoring an API, sending an email, or running a pipeline.
A DAG (opens in a new tab) can run on a schedule, be triggered manually, or be triggered by events such as a Cloud Storage bucket change or a Pub/Sub topic message. For reliable parsing, define only one DAG object per Python module, group tasks inside DAGs instead of using SubDAGs, place parse-time files in the dags/ folder rather than data/, keep custom libraries in a nested directory inside a DAG ZIP archive, and add unit and pre-deployment DAG tests.
A managed Airflow environment is a self-contained Airflow deployment based on Google Kubernetes Engine (GKE) that runs schedulers, workers, and supporting services as one system. You can create one or more environments in a single Google Cloud project in any supported region, and Managed Airflow provisions the Google Cloud services and Airflow components for you. The environment connects to other Google Cloud services through connectors built into Airflow. Data flows from the environment's Cloud Storage bucket to the GKE cluster, where the scheduler parses DAG files and workers execute tasks. The GKE cluster hosts schedulers, triggerers, workers, Composer Agent, and Airflow Monitoring, while logs flow outward to Cloud Logging and metrics flow outward to Cloud Monitoring. The Airflow database sits behind the scheduler and web server to hold metadata about DAG runs, tasks, and state, and the Airflow web server reads that state to show DAG status in the Airflow user interface (UI).
Secure execution in Managed Airflow separates environment management from DAG management across different trust boundaries. Environments are created and configured through the Google Cloud console, Google Cloud CLI, Cloud Composer API, or Terraform, with project-level Identity and Access Management (IAM) roles controlling who can create or modify environments. Individual DAGs are managed through the Google Cloud console, native Airflow UI, or Google Cloud CLI and Airflow CLI commands, with extra UI access control from the Apache Airflow access-control model. Authentication for Google Cloud tasks depends on Airflow connections, which Managed Airflow configures automatically for many Google Cloud services so operators do not need hard-coded credentials. Airflow configuration options can be changed from Managed Airflow defaults to custom values, although some options are blocked. Python dependencies can be installed from the Python Package Index or a private repository including Artifact Registry, and custom plugins extend behavior with in-house operators, hooks, sensors, or interfaces.
An Airflow operator defines the type of work a task performs, while a task is a single instance of that operator inside a DAG. Choosing the correct operator controls where code runs, which service it calls, and how resources are used. Managed Airflow supports standard operators, Google Cloud operators, notification operators, and custom operators installed as plugins.
BashOperator runs command-line programs on an Airflow worker, which is a Debian-based container that includes gcloud including gcloud storage, bq for BigQuery (opens in a new tab), and kubectl for GKE pods. Use BashOperator when the task wraps existing CLI automation. PythonOperator runs arbitrary Python code in a container that includes packages for the environment's Managed Airflow image version, with extra packages added through managed dependency installation. Use PythonOperator for custom transformation, branching, or callback logic such as decoding Pub/Sub messages. Google Cloud operators execute natively in managed services, such as BigQueryInsertJobOperator sending SQL with destination project, dataset, and table to BigQuery, and transfer operators moving data between BigQuery and Cloud Storage. EmailOperator sends email from a DAG and can pull values from prior tasks with XCom, while email_on_failure sends alerts on failure and depends on SendGrid configuration with recipient, retry count, and retry delay.
Scheduling in Managed Airflow determines how a DAG run starts, either on a timetable or in response to external events. A time-driven DAG uses a schedule interval such as daily or every four weeks with a fixed start_date evaluated at parse time. An event-driven pattern uses a frequently scheduled controller DAG that polls for external events and then triggers target DAGs dynamically.
The Pub/Sub controller pattern moves control through an ordered sequence:
PubSubCreateSubscriptionOperator ensures the trigger_dag_subscription subscription exists for the dag-topic-trigger topic and outputs the subscription name.PubSubPullOperator pulls up to 50 messages, acknowledges them automatically, and runs a callback that decodes each body into a target DAG ID returned through XCom.TriggerDagRunOperator expands dynamically over the returned DAG IDs and triggers one run of each target DAG.This sequence lets one controller fan out to many targets based on message content:
| Scheduler | Best for | Scheduling method |
|---|---|---|
| Managed Service for Apache Airflow | Complex ETL/ELT and MLOps across Google Cloud and external systems with many operator types | Time-driven and event-driven |
| Dataform | Organized, tested, version-controlled SQL transformations inside BigQuery | Time-driven |
| Workflows | Chaining HTTP-based microservices and infrastructure tasks with low latency | Time-driven and event-driven |
| Cloud Scheduler | Batch or infrastructure jobs on defined time intervals | Time-driven |
Exam tip: Choose Managed Airflow when the workflow spans heterogeneous systems and needs diverse operators and dependencies, while Dataform fits SQL-only transformations that remain strictly inside BigQuery.
Cloud Scheduler is a fully managed, time-driven scheduler for batch, streaming, and infrastructure jobs that must occur on defined intervals. Each job defines a name unique in the same region, a region such as us-central1, a frequency in unix-cron format, and a target such as Pub/Sub or HTTP. Documented frequency examples are */5 * * * * to run every 5 minutes and 30 16 * * 7 to send a message at 16:30 on Sundays.
Cloud Scheduler evaluates the schedule in a configured time zone, with a default of UTC and values from the tz database. Cloud Scheduler runs on wall clock time, so daylight saving time can cause a job to run twice or not at all when a local time repeats as clocks go backward. If exact cadence matters, choose a time zone without daylight saving time, with UTC as the recommended choice.
Cloud Scheduler also supports groc, a human-readable alternative for schedules awkward in cron such as the third Tuesday of every month or biweekly intervals. A groc schedule must be created through the gcloud CLI or Cloud Scheduler API, not the console. Supported constructs include every 5 minutes, every 336 hours, every day 09:00, first sunday of month 12:00, 1st,third monday of month 04:00, and second,4th tue,thursday of 3rd month of quarter 18:30.
Exam tip: Use UTC for Cloud Scheduler when exact cadence matters, because wall clock time in daylight saving time zones can cause a scheduled run to repeat or be skipped.
The native scheduler defines where retry, dependency handling, and state live, so the choice depends on whether the workload is SQL transformation, service chaining, or cross-system ETL. Time-driven scheduling starts work on a timetable, while event-driven scheduling starts work on a state change such as file arrival or message receipt. Simple GoogleSQL chains with data definition language (DDL) and data manipulation language (DML) and no external dependencies fit the lightest time-driven option, while workloads spanning external systems need a full orchestrator.
| Scheduler | Best fit | Scheduling method |
|---|---|---|
| Dataform | Organized, tested, version-controlled SQL collections in BigQuery after raw data is loaded | Time-driven |
| Workflows | Chaining HTTP-based microservices with very low latency, automating infrastructure, and integrating external systems | Event-driven and time-driven |
| Managed Service for Apache Airflow | Durable ETL or ELT and MLOps across heterogeneous systems with more than 1,000 prebuilt operators | Time-driven and event-driven |
| Cloud Scheduler | Invoking batch, streaming, or infrastructure operations on intervals, including triggering Workflows and Cloud Run jobs | Time-driven |
Workflows (opens in a new tab) executes an ordered chain of HTTP-based steps, Managed Airflow manages end-to-end processes such as extracting from BigQuery, triggering training, and updating Looker, and Dataform schedules runs through workflow configurations attached to a deployment. Assets created in a BigQuery repository, including queries, notebooks, pipelines, and Dataform workflows, cannot be scheduled from Dataform and must use BigQuery execution and scheduling. Other options include Vertex AI Pipelines for container-based machine learning, Apigee Integration for enterprise apps such as Salesforce, and Cloud Data Fusion for code-free pipelines with more than 150 connectors.
A Cloud Scheduler job configuration establishes the identity the scheduler uses, the permission that identity receives on the target, and the schedule and payload it sends. The workflow depends on a service account for authentication, depends on IAM bindings for authorization, and depends on the target API for execution. Enabling APIs requires serviceusage.services.enable through Owner (roles/owner) or Service Usage Admin (roles/serviceusage.serviceUsageAdmin), while the quickstart requires Cloud Scheduler Admin (roles/cloudscheduler.admin) and Pub/Sub Editor (roles/pubsub.editor).
cloud-run-invoker so Cloud Scheduler can call the Workflows API or Cloud Run API, where the name must be 6 to 30 characters of lowercase letters, numbers, and dashes and cannot be changed later.roles/workflows.invoker on the project or roles/run.developer plus roles/iam.serviceAccountTokenCreator when the target is a Cloud Run job.Hello world! to a topic such as cron-topic, and an HTTP target sends POST to the Workflows execution endpoint or to https://run.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/jobs/JOB_NAME:run with body {}.cron-topic-sub or by checking the Workflows execution and call logging configured through the Workflows page.For Dataform (opens in a new tab) deployments, the schedule lives as a trigger on the deployment rather than as a standalone Cloud Scheduler job. Data flows from the deployment schedule configuration to the Dataform run when an operator opens Pipelines and Connections, selects Deployments and a deployment, and creates a workflow configuration under Triggers. The same Triggers section supports Run now for immediate execution and Delete for removal, and failed invocations support alert configuration.
Retry policy in Cloud Scheduler (opens in a new tab) controls what happens after the scheduler sends a request and the attempt fails or exceeds its deadline. The Terraform representation sets attempt_deadline = "320s" as the maximum time for one attempt and a retry_config block with retry_count = 3, so the target can receive the same Pub/Sub message or HTTP request more than once. Because Force run and automatic retry can both deliver duplicates to Workflows, Cloud Run, or Pub/Sub subscribers, downstream logic must be idempotent and produce consistent results when the same payload arrives again.
Advanced native schedules add one-time and calendar-anchored options beyond raw cron, including Run Once for a single future time, Daily for the same time each day, Weekly for specific weekdays, and Monthly for specific month days. A monthly date such as the 29th, 30th, or 31st is skipped in months without that date. For every-X intervals, the starting date anchors the first interval, so a job set for Monday and Wednesday every two weeks but started on a Tuesday runs on Wednesday, skips one week, then runs Monday and Wednesday thereafter. Monitoring connects the scheduler to evidence and alerts when the chain breaks, through Workflows call logging, Dataform alerts for failed invocations, and Pub/Sub subscription checks confirming message arrival.
Event-driven chaining starts when a state change sends a message to a predefined Pub/Sub topic that decouples producers from executors. Triggers include a Cloud Functions invocation, a call through the Pub/Sub API, or a manual publish with the Google Cloud CLI. An agent installed in each VM listens to one or more topics, pulls the next message when it arrives, starts a pipeline in third-party software, waits for completion, then retrieves the next message. The publisher only writes to the topic while the agent controls execution on the VM, so either side can change without rewiring the other. High availability comes from the global Pub/Sub endpoint visible from any Google Cloud location, while a message storage policy can pin persistence to specified regions or use customer-managed encryption keys (CMEK) when data must stay in place. Strict location restriction trades availability for locality, and a subscription can buffer unacknowledged messages for up to 7 days so delayed pipelines can resume with low data loss after an outage.
Dataflow is a fully managed service for running Apache Beam jobs at scale with the same programming model for batch and streaming. Apache Beam provides windowing and session-analysis primitives plus source and sink connectors, including a connector for BigQuery, and supports Java, Python, and Go SDKs with multi-language pipelines. Pipelines are submitted through the command-line interface, Java SDK, or Python SDK, and a portability framework supports running Beam logic on other runners such as Apache Flink or Apache Spark. When a Dataflow job runs, the Dataflow service allocates a pool of worker VMs, distributes data in parallel across them, and automatically deletes the VMs when the job completes or is cancelled. Billing covers compute resources used, while performance, scaling, availability, security, and compliance are handled automatically. Dataflow can autoscale workers up or down and dynamically rebalance work so parallel stages finish efficiently. Typical uses include data movement with ingestion or replication, extract-transform-load (ETL) into BigQuery, backend support for business intelligence dashboards, real-time machine learning on streaming data, and sensor or log processing at scale. Dataflow also unifies processing and orchestration for highly parallel workloads where many independent tasks run as grid computing. One pipeline can perform I/O reads, pre-processing, task distribution across many cores, and post-analysis writes, including very high concurrency reads with large fan-out downstream. Built-in management includes observability in the monitoring interface, centralized logging, fault tolerance, dynamic load balancing, and straggler detection and correction. Existing C++ or other compiled binaries can run as external code inside the Beam DAG, so pre-processing, task farming, and post-processing share one managed system.
Exam tip: Dataflow provides exactly-once processing of every record by default; enable at-least-once mode only for streaming pipelines that can tolerate duplicates to reduce cost and improve latency.
Cloud Data Fusion is a fully managed data integration service built on the open source CDAP project for building pipelines through a graphical interface. Developers connect sources to transformations, sinks, and other nodes to form a DAG in the Cloud Data Fusion UI. When deployed, the planner transforms that DAG into parallel computations executed as an Apache Spark job on Managed Service for Apache Spark. Cloud Data Fusion supports both batch and streaming pipelines and exposes logs and metrics so administrators can operate workflows without custom tooling. Sources can include databases accessed through Java Database Connectivity (JDBC) drivers, which are uploaded to the instance and configured for use, with data read, transformed, and loaded into destinations such as BigQuery without writing code. Behavior is extended through plugins for sources, transforms, aggregates, sinks, error collectors, alert publishers, actions, and post-run actions, using prebuilt plugins or custom plugins built with plugin APIs. Choose Cloud Data Fusion when rewriting is justified because existing pipelines use deprecated technology or would be impractical and costly to port unchanged.
Parameterized workflows separate pipeline definition from per-run values so the same logic executes dynamically with different data, dependencies, and targets. Scheduling tools enforce dependency and parameter management to ensure tasks run in the correct order with the correct data. Dataflow templates implement this by letting a developer create a predefined pipeline once, after which others deploy it on demand with different parameters, including Google-provided templates that require no Beam programming. Development can iterate in JupyterLab notebooks before promoting code to a repeatable template or SDK job.
Dataform (opens in a new tab) orchestration with Workflows executes in two ordered steps: first it pulls repository code from the Git provider and compiles it into a compilation result, then it creates and executes a workflow invocation from that result at the scheduled frequency. Managed Airflow uses the same dependency in DAG code, where one task creates a compilation result and a downstream task creates the workflow invocation from the first task's result name passed through XCom. For production reliability, schedule with release configurations rather than passing gitCommitish on every run, because cloning the remote Git repository on every frequent or concurrent compilation can fail. If gitCommitish is required, configure automated retries with exponential backoff, and grant the orchestration identity the Dataform Editor role, Service Account User on the Dataform service account, and minimum workflow permissions.
Scheduling method selection starts by identifying whether workloads are event-driven, time-driven, or both. An event is a state change such as a database change or a file arriving in Cloud Storage, so an object landing in a bucket can trigger immediate processing. Time-driven scheduling loads or aggregates on a clock, such as once per day or hourly for reports, and both methods can combine when objects load into a data lake in real time while reports generate daily. Ephemeral batch orchestration shows how time and event signals combine with containerized compute. Managed Airflow validates that new files arrived in the Cloud Storage ingestion bucket, starts an ephemeral Managed Service for Apache Spark cluster, starts the Apache Spark ETL job that produces business metrics, and deletes the cluster when the job ends. DAG files live in a Cloud Storage bucket with the same multi-region, dual-region, and encryption locality considerations as ingestion data, while processed data is stored in columnar formats such as Parquet and ORC and metadata is stored in the Hive metastore from Dataproc Metastore. Tool choice depends on focus, complexity, user profile, and latency:
| Dataform | Workflows | Managed Airflow | Vertex AI Pipelines | |
|---|---|---|---|---|
| Focus | Data transformation | Microservices | ETL or ELT | Machine learning |
| Complexity | * | ** | *** | ** |
| Code type | JavaScript, SQL, Python notebooks | YAML or JSON | Python | Python |
| Serverless model | Yes, serverless | Yes, serverless with very low latency HTTP chaining | Fully managed | Yes, serverless |
| Not suitable for | Chains of external services | Data transformation and processing | Low latency or event-driven pipelines | Infrastructure tasks |
The simplest time-driven option is scheduled queries in BigQuery (opens in a new tab), recommended only for straightforward GoogleSQL chains with no external dependencies, including DDL and DML statements. Dataform is a free SQL-based framework that schedules complex BigQuery transformations as tested, version-controlled collections, while Workflows is best for chaining HTTP microservices, automating infrastructure, integrating external systems, and running multiple BigQuery jobs in parallel. Assets created in a BigQuery repository, such as queries, notebooks, pipelines, or Dataform workflows, cannot be scheduled from Dataform and must use BigQuery execution and scheduling (opens in a new tab).
>> and << in Python code.Managed Service for Apache Airflow is best for complex ETL or ELT and MLOps across Google Cloud and external systems with many operator types and time-driven and event-driven scheduling, while Dataform is best for organized, tested, version-controlled SQL transformations inside BigQuery and Workflows is best for chaining HTTP-based microservices with very low latency. Choose Managed Service for Apache Airflow when the workflow spans heterogeneous systems and needs diverse operators and dependencies, while Dataform fits SQL-only transformations that remain strictly inside BigQuery.
Cloud Scheduler evaluates each job schedule in a configured time zone that defaults to UTC and runs on wall clock time, so daylight saving time can cause a job to run twice or not at all when a local time repeats as clocks go backward. When exact cadence matters, choose a time zone without daylight saving time, with UTC as the recommended choice.
Cloud Scheduler retry policy controls what happens after an attempt fails or exceeds its deadline and can deliver the same Pub/Sub message or HTTP request more than once through automatic retry or forced runs. Because targets such as Workflows, Cloud Run, or Pub/Sub subscribers can therefore receive duplicates, downstream logic must be idempotent and produce consistent results when the same payload arrives again.
An enterprise data engineering team is building an event-driven, automated data processing pipeline on Google Cloud. The workflow must execute sequentially whenever new files arrive in Cloud Storage:
The entire orchestration layer must be completely serverless, scale to zero when idle with no persistent compute infrastructure, and provide built-in retry and state-handling capabilities.
Which orchestration approach should the team implement?
Last updated