CertLumen

Databricks Data Analyst Associate · Section 5 · 15% of the exam

Utilize Delta Lake to audit and view history, validate results, and compare historical results or trends.

One of the objectives of the Databricks Certified Data Analyst Associate exam, in the section “Analyzing Queries”. Here is what it covers, the points to remember and a question to try.

What it covers

Use DESCRIBE HISTORY and time travel to audit who changed a table, validate results and compare versions, then recognize and fix the classic SQL bugs (join filters, NULL logic, fan-out, aggregates) that make a query return the wrong answer.

Points to remember

  • Every Delta write is a new version; DESCRIBE HISTORY (or the Catalog Explorer History tab) lists them newest first; SELECTs create no versions.
  • History columns: version, timestamp, userName, operation, operationParameters (predicates), operationMetrics (row and file counts), job, notebook.
  • History retention = delta.logRetentionDuration (30 days); time travel also needs the data files kept by delta.deletedFileRetentionDuration (7 days, the VACUUM threshold).
  • Compare results with VERSION AS OF, TIMESTAMP AS OF or @v; EXCEPT lists changed rows; table_changes needs change data feed.
  • RESTORE TABLE ... TO VERSION AS OF undoes changes by adding a new version and needs MODIFY.

Try a question

A monthly revenue report changed after last night's MERGE into workspace.finance.invoices. Before anyone touches the table, the analyst wants to compare the report's total with what it would have returned just before the MERGE. DESCRIBE HISTORY shows the MERGE as version 57. What should she do?

  1. ARun RESTORE TABLE workspace.finance.invoices TO VERSION AS OF 56 and then rerun the report
  2. BQuery table_changes('workspace.finance.invoices', 57), which is available on any Delta table
  3. CRun the report against workspace.finance.invoices VERSION AS OF 56 and compare it with today's total
  4. DRerun the report so that the query result cache returns yesterday's total
Show the answer

C. Time travel reads the table as of version 56, the state just before the MERGE, without changing anything, so the two totals can be compared side by side; the MERGE's operationMetrics (rows inserted, updated, deleted) explain the difference. RESTORE would modify the production table, and table_changes requires change data feed.

Written for practice in the style of the exam: never a question from the real exam.

In the course

The lesson Delta history for auditing, and fixing query results teaches this objective (about 40 minutes), and 12 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.

More in this section

← Previous objective · All 39 objectives · Next objective →