Learning Objectives
By the end of this chapter, you will be able to:
- Implement control flows (retries and conditional tasks such as branching and looping) using Lakeflow Jobs for orchestration.
- Configure common tasks (notebook, SQL query, dashboard, pipeline) and their dependencies using the Lakeflow Jobs DAG-based task graph.
- Implement job schedules using Lakeflow Jobs with an understanding of trigger types (scheduled, file arrival, table update).
- Choose between time-based and data-driven triggers based on data availability and pipeline dependencies.
Executive Summary
- Lakeflow Jobs is the native orchestrator on the Databricks Data Intelligence Platform. A job is a directed acyclic graph of tasks with shared parameters, shared compute pools, and a single owner and run history.
- Control flow is expressed declaratively through three primitives: per-task retry policies (max retries, retry on timeout, minimum interval), conditional dependency rules through
run_ifand the dedicated If/else condition task, and bounded iteration through the For each task. - Task types include Notebook, SQL (query, alert, dashboard, file), Lakeflow Spark Declarative Pipelines, dbt, JAR, Python wheel, Python script, Spark Submit, Run job, If/else condition, and For each, with dependencies declared per task through
depends_on. - A job can be started by four trigger families: manual, scheduled (cron with Quartz syntax in a chosen time zone), file arrival (polling a Unity Catalog external location), and table update (polling a Unity Catalog table version), plus continuous mode for long-running pipelines.
- Time-based triggers are correct when freshness is measured in clock time and the producer is opaque. Data-driven triggers (file arrival, table update, downstream Run job) are correct when freshness is measured in data, when the producer is irregular, or when you must avoid empty runs.
Assumptions
- Unity Catalog is the active metastore for the workspace. References to catalogs and schemas use the three-level namespace established in earlier chapters.
- Code examples are in SQL where the task type is SQL and in PySpark where the task type is Notebook, following the platform convention.
- All examples use fictional naming under the catalog
acme_prod, schemasbronze,silver,gold, and the workspace userdata_eng@acme.example. - References to managed pipelines use the current name Lakeflow Spark Declarative Pipelines (the rename of the prior Delta Live Tables / DLT product). The orchestrator product is referred to throughout as Lakeflow Jobs (the rename of the prior Workflows product).
