Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 36 ยท Projects and Practice

Databricks Practice Questions and Exercises

Test yourself on Databricks: scenario questions on jobs, Unity Catalog, MLflow, streaming and production, hands-on Python exercises with solutions, and a study checklist.

You have now seen notebooks, jobs, governance, machine learning, streaming and delivery. This last lesson is practice. It has scenario questions that mix topics the way real work does, short coding exercises you can run here (as plain Python stand-ins, since Databricks cannot run on this site), and a checklist for what to revise.

Try each question before opening the answer in your head: cover the explanation and decide first.

Scenario questions

1. The nightly job overlaps. A job scheduled hourly sometimes takes 80 minutes. What happens by default and what do you change? Answer: with max concurrent runs at 1, the next run is skipped while the previous one is running. Fix the cause (data volume, cluster size, a slow task) or schedule less often; allow concurrency only if runs are independent and idempotent.

2. "Table not found" for an analyst. The table exists and the analyst has SELECT on it. Why can it still fail? Answer: they also need USE CATALOG and USE SCHEMA on the parents; or they are not in the group you granted to.

3. A model must be promoted without code changes in the scoring job. How? Answer: load by alias (models:/prod.ml.price_model@champion) and move the alias to the new version after the checks pass.

4. A stream restarts after a crash and reprocesses all history. What was probably deleted or changed? Answer: the checkpoint folder (or a new location was used). The checkpoint stores progress; keep one stable location per query.

5. A column contains emails and only the privacy team may see them. Which feature fits? Answer: a column mask using is_account_group_member('pii-readers'), plus a pii tag for discovery.

Exercise 1: parse a cron schedule

Write a function that checks whether a Quartz-like expression fires at a given time. The starter code handles *, ? and exact numbers; extend it to support */n steps.

Python Exercise 1: add step support

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Expected: only minutes 0, 15, 30 and 45 print True.

Exercise 2: find who can read a table

Given grants, write readers(table) returning every principal that can read the table (container gates plus SELECT, with inheritance).

Python Exercise 2: who can read it?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Think about the result: analysts qualifies; etl only has MODIFY; auditors have SELECT but never received USE SCHEMA, so they cannot read yet. Adding ("auditors", "USE SCHEMA", "prod.sales") would change the answer.

Exercise 3: a watermark decision

Given events (event_time, key) and a watermark of 2 minutes, decide which events are accepted when processed in arrival order.

Python Exercise 3: which events are dropped?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check by hand: after 13 arrives the cutoff is 11, so 9 is dropped but 12 is kept; after 20 the cutoff is 18, so 15 is dropped.

Exercise 4: choose batch or real time

Classify use cases by freshness need and volume, then say which Databricks tool you would use.

Python Exercise 4: pick the tool

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Rapid-fire quiz

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. A job should run a cleanup task even when an earlier task failed. Which run-if rule?

    All done fires after upstream tasks finish regardless of outcome.
  2. 2. Which Auto Loader feature keeps values that do not fit the schema?

    The rescued data column stores mismatches as JSON.
  3. 3. Why register models in Unity Catalog instead of a workspace registry?

    Models become securable objects like tables.
  4. 4. What should CI use to deploy a bundle to production?

    Machine identities keep deployments auditable.
  5. 5. Which statement about volumes is true?

    Volumes are Unity Catalog objects for files.

Study checklist

  • Notebooks and jobs: magic commands, widgets, triggers, retries, task dependencies, repair runs.
  • Governance: three-level names, grants and inheritance, volumes, external locations, filters, masks, lineage.
  • ML: runs, parameters, metrics, registry aliases, batch versus real-time serving, drift.
  • Streaming and production: checkpoints, triggers, watermarks, Auto Loader, pipelines and expectations, bundles and CI.
  • Habits: idempotent tasks, service principals, small tested functions, cost awareness.

Come back to this page after a few weeks and answer the scenarios again without looking.

Summary

  • Real problems combine several topics: scheduling, access, data quality and cost.
  • Practise by predicting behaviour (what runs, what is dropped, who can read) and then checking it.
  • Keep a short checklist and revisit it.

Next: The Databricks Track