Skip to the page
Tecyfy

Databricks interview question · hard

Lois Lane needs to schedule a Databricks notebook to run daily and send an email notification upon completion. How can this be achieved using Databricks Jobs, and how can she configure email alerts to send to the Daily Planet?

The short answerLois creates a Lakeflow Job with her notebook as a task, adds a scheduled trigger that runs once a day, and adds the Daily Planet's address under the job's notifications for success and failure.

The full answer

Lois creates a Lakeflow Job with her notebook as a task, adds a scheduled trigger that runs once a day, and adds the Daily Planet's address under the job's notifications for success and failure.

1. Create the job

  • In the workspace sidebar open Jobs & Pipelines and create a job.
  • Add a task of type Notebook and choose the notebook. Use serverless compute if the workspace has it; otherwise a jobs cluster, which is created for the run and shut down afterwards and costs less than an all-purpose cluster.
  • Pass any values the notebook needs as task parameters, which arrive as widgets.

2. Schedule it

  • Under Schedules & Triggers, add a Scheduled trigger: every day at, say, 06:00, in the team's time zone, or as a Quartz cron expression such as 0 0 6 * * ?.

3. Add the email alerts

  • Under the job's Job notifications, add newsroom@dailyplanet.example and tick the events: Success and Failure for this case. Start, Duration warning (needs a duration threshold) and Streaming backlog are also available.
  • Job-level notifications are not sent for retried tasks. To hear about every failed attempt, add notifications on the task too; Mute notifications until the last retry keeps them quiet until the final attempt.
  • Skipped and cancelled runs can be muted.
  • For a team channel instead of email, an admin sets up a Slack, Microsoft Teams, PagerDuty or webhook destination, which then appears in the same list.

4. The same job as code

With the Databricks CLI, define the job in JSON:

{
  "name": "Daily Planet report",
  "tasks": [{
    "task_key": "report",
    "notebook_task": { "notebook_path": "/Workspace/Shared/reports/daily" }
  }],
  "schedule": { "quartz_cron_expression": "0 0 6 * * ?", "timezone_id": "America/New_York" },
  "email_notifications": {
    "on_success": ["newsroom@dailyplanet.example"],
    "on_failure": ["newsroom@dailyplanet.example"]
  }
}
databricks jobs create --json @daily-report.json

A task with no compute settings runs on serverless compute, where the workspace has it. For jobs kept in Git, a Databricks Asset Bundle describes the same job in YAML and deploys it with databricks bundle deploy.

Good practice

  • Send alerts to a group address, not to one person.
  • Make the notebook fail loudly on bad data (raise an exception), so the failure email means something.
  • Set a timeout and retries on the task so a hung run does not block the next day's.

Last updated 16 October 2026

Asked next