Databricks Data Analyst Associate · Section 4 · 20% of the exam
Use Delta Lake's time travel to access and query historical data versions.
One of the objectives of the Databricks Certified Data Analyst Associate exam, in the section “Executing queries using Databricks SQL and Databricks SQL Warehouses”. Here is what it covers, the points to remember and a question to try.
What it covers
Unity Catalog has two kinds of tables: managed tables, where Unity Catalog owns the files, and external tables, where you own them. This lesson covers how to create each, what DROP does, how one CREATE TABLE AS SELECT can unify CSV, Parquet and Delta sources, and how Delta time travel lets you audit, query and restore earlier versions of a table.
Points to remember
- Managed tables are the default and recommended type: no
LOCATION, Delta (or Iceberg), files in Unity Catalog managed storage, eligible for predictive optimization. - External tables use
LOCATIONinside a Unity Catalog external location and needCREATE EXTERNAL TABLE; they support Delta, CSV, JSON, Avro, Parquet, ORC and text. - Dropping a managed table purges its data after a recovery period (7 days by default;
UNDROP TABLE); dropping an external table leaves the files in place. - CTAS derives the schema from the query (no column list);
CREATE OR REPLACEkeeps history and grants;IF NOT EXISTSandOR REPLACEcannot be combined. read_filesreads CSV, Parquet, JSON and other formats from volumes; joining it with Delta tables in one CTAS builds a unified table; it needsREAD VOLUME.
Try a question
An analyst builds workspace.daa_lab.customers_unified with a CTAS that reads CSV files from a volume through read_files. Auditors require every row of the new table to record the file it was loaded from. What should she add to the query?
- ASelect
_metadata.file_pathfrom theread_filessource as an extra column - BAdd a
LOCATIONclause so that Unity Catalog tracks each row's source file - CEnable change data feed on the new table to record where each row came from
- DRun
DESCRIBE HISTORYafter the CTAS and store its output next to the table
Show the answer
A. File-based sources such as read_files expose a hidden _metadata column. Selecting _metadata.file_path, for example AS source_file, stores the path of the file each row came from. Table history and change data feed record table versions and row changes, not the source file of each row.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Managed and External Tables, CTAS and Delta Time Travel teaches this objective (about 45 minutes), and 9 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
- Utilize Databricks Assistant within a Notebook or SQL Editor to facilitate query writing and debugging.
- Explain the role a SQL Warehouse plays in query execution.
- Querying cross-system analytics by joining data from a Delta table and a federated data source.
- Create a materialized view, including knowing when to use Streaming Tables and Materialized Views, and differentiate between dynamic and materialized views.
- Perform aggregate operations such as count, approximate count distinct, mean, and summary statistics.
- Write queries to combine tables using various join operations (inner, left, right, and so on) with single or multiple keys, as well as set operations like union and union all, including the differences between the joins (inner, left, right, and so on).
- Perform sorting and filtering operations on a table.
- Create managed tables and external tables, including creating tables by joining data from multiple sources (e.g., CSV, Parquet, Delta tables) to create unified datasets, including Unity Catalog.