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 bydelta.deletedFileRetentionDuration(7 days, the VACUUM threshold). - Compare results with
VERSION AS OF,TIMESTAMP AS OFor@v; EXCEPT lists changed rows;table_changesneeds change data feed. RESTORE TABLE ... TO VERSION AS OFundoes 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?
- ARun
RESTORE TABLE workspace.finance.invoices TO VERSION AS OF 56and then rerun the report - BQuery
table_changes('workspace.finance.invoices', 57), which is available on any Delta table - CRun the report against
workspace.finance.invoices VERSION AS OF 56and compare it with today's total - 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
- Understand the Features, Benefits, and Supported Workloads of Photon.
- Identify poorly performing queries in the Databricks Intelligence platform, such as Query Insights, Query Profiler log, etc.
- Utilize query history and caching to reduce development time and query latency
- Apply Liquid Clustering to improve query speed when filtering large tables on specific columns.
- Fix a query to achieve the desired results.