Sub topic 1
What a Job, a Task, and a Run Are
Prerequisites
Assume you can use Databricks notebooks, write basic Python or SQL, and understand that clusters provide compute for Spark workloads. You should also know the basic idea of a cron schedule.
Jobs, tasks, and runs
A Databricks Job is a reusable definition of a workflow. It specifies what work should happen, in what order, with which compute, and under which schedule or trigger.
A task is one unit of work in a job. Common task types include:
- Notebook tasks for Python, SQL, or Scala notebooks.
- SQL tasks for queries, dashboards, or alerts.
- Python wheel tasks for packaged Python code.
- Run Job tasks for calling another job.
A run is one execution of a job. Each run has a status, start and end times, logs, and a record of each task attempt. A job can have many runs, including overlapping runs unless you limit concurrency.
Choosing a task type
Use a notebook task when your existing work is organized in a notebook and needs parameters or interactive development. Use a packaged task, such as a Python wheel, when application code needs testing, versioning, and deployment outside notebooks. Choose SQL tasks when the work is primarily SQL and should use Databricks SQL resources.
Compute for job tasks
Tasks can use an existing all-purpose cluster, a new job cluster, or serverless compute when available in your workspace. Job clusters are created for the run and terminated afterward. They usually reduce interference between workflows and avoid leaving interactive clusters running.
A shared job cluster lets several tasks use the same compute. Separate clusters provide stronger isolation but can increase startup time and cost.
{
"name": "daily-sales",
"tasks": [
{
"task_key": "ingest",
"notebook_task": {
"notebook_path": "/Workspace/Shared/ingest"
},
"new_cluster": {
"spark_version": "15.4.x-scala2.12",
"node_type_id": "i3.xlarge",
"num_workers": 2
}
}
]
}Dependencies form a workflow
A multi-task job is a directed acyclic graph, or DAG. Each edge says that one task depends on another. The dependent task normally starts only after its prerequisite succeeds.
Scheduling with cron and time zones
A schedule starts runs automatically. Databricks uses Quartz cron expressions. The expression below runs daily at 06:00 UTC. The time zone determines how the schedule is interpreted, including daylight-saving changes for regional zones.
{
"schedule": {
"quartz_cron_expression": "0 0 6 * * ?",
"timezone_id": "UTC",
"pause_status": "UNPAUSED"
}
}Exercise
If transform depends on ingest, can transform start while ingest is still running?
Show answer
No. The dependency makes Databricks wait for ingest to finish successfully.