Databricks - Data Engineer Associate Study Guide

    4: Working with Lakeflow Jobs

    This chapter walks through orchestration on the Databricks Data Intelligence Platform with Lakeflow Jobs, covering control flow primitives (retries, If/else branching, For each loops, Run if dependencies), the full task-type catalog (notebook, SQL query, SQL dashboard, Lakeflow Spark Declarative Pipelines, JAR, Python wheel, dbt, condition, run job), DAG construction with `depends_on`, and the trigger model (scheduled with cron and Quartz, file arrival, table update, continuous). It closes with a selection framework for time-based versus data-driven triggers based on freshness needs, upstream signal availability, and cost behavior.

    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_if and 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, schemas bronze, silver, gold, and the workspace user data_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).

    Sections in this chapter

    1. Free
    2. Free with account
    3. Free with account
    4. Free with account
    5. Free with account