6.3 Data Retention Policies, Time Travel Security, & Tag Governance
Key Takeaways
- Delta Lake time travel enables querying historical table snapshots by version number or timestamp, powered by immutable JSON commit logs and checkpoint files in the _delta_log directory.
- Table retention is governed by two critical table properties: delta.logRetentionDuration (controls transaction log history; default 30 days) and delta.deletedFileRetentionDuration (controls tombstoned Parquet data file retention before VACUUM eligibility; default 7 days).
- The VACUUM command permanently removes unreferenced, tombstoned Parquet files older than the retention threshold, reclaiming cloud storage and permanently truncating time travel history prior to the vacuum horizon.
- Complying with GDPR/CCPA 'Right to be Forgotten' mandates a two-step hard deletion protocol: executing a DELETE/MERGE operation followed by a VACUUM to physically erase PII from historical Parquet files in ADLS Gen2.
- Unity Catalog tags provide a standardized key-value metadata taxonomy for catalogs, schemas, tables, and columns, enabling automated governance classifications, PII discovery, and tag-based policy enforcement.
6.3 Data Retention Policies, Time Travel Security, & Tag Governance
DP-750 Exam Focus: Understand Delta Lake transaction log retention (
delta.logRetentionDuration), deleted data file retention (delta.deletedFileRetentionDuration), and time travel mechanics. Master the operational and governance consequences ofVACUUM, the required protocol for GDPR/CCPA hard data deletion, and how to apply and query Unity Catalog tags for Attribute-Based Access Control (ABAC) and data classification.
1. Delta Lake Time Travel & Transaction Log Mechanics
Delta Lake brings ACID transactional guarantees to cloud object storage (ADLS Gen2) by pairing immutable Parquet data files with an ordered, serialized transaction log located in the _delta_log/ directory.
Every write operation—whether an INSERT, UPDATE, DELETE, MERGE, or OPTIMIZE—creates a new atomic commit JSON file (000000.json, 000001.json, etc.). When rows are updated or deleted, Delta Lake does not modify existing Parquet files in place. Instead, it writes new Parquet files containing the modified data and records tombstones (metadata markers) in the transaction log indicating that the older Parquet files are logically obsolete for future transactions.
DELTA LAKE SNAPSHOT ISOLATION
_delta_log/
+---------------+ +---------------+ +---------------+
| 000000.json | --> | 000001.json | --> | 000002.json |
| (Add: file_A) | | (Add: file_B) | | (Remove: file_A| <-- Tombstone Marker
+---------------+ +---------------+ | Add: file_C) |
+---------------+
|
+--------------------------------------------+--------------------------------------------+
| Snapshot at Version 1 (file_A, file_B) | Snapshot at Version 2 (file_B, file_C)
v v
[ Query Version 1 ] [ Query Version 2 (Current) ]
Reads: file_A.parquet, file_B.parquet Reads: file_B.parquet, file_C.parquet
Time Travel Query Syntax
Data engineers can query historical states of any Delta table using version numbers or timestamps:
-- 1. Querying table state at a specific commit version
SELECT * FROM prod_sales.curated.orders VERSION AS OF 14;
-- 2. Querying table state at a specific historical timestamp
SELECT * FROM prod_sales.curated.orders TIMESTAMP AS OF '2026-08-01 12:00:00';
-- 3. PySpark DataFrame Time Travel API
df_v14 = spark.read.table("prod_sales.curated.orders").option("versionAsOf", 14).load()
df_ts = spark.read.table("prod_sales.curated.orders").option("timestampAsOf", "2026-08-01T12:00:00Z").load()
Auditing History with DESCRIBE HISTORY
The DESCRIBE HISTORY command displays the complete chronological log of commits, detailing operations, user identities, cluster IDs, and affected file metrics:
DESCRIBE HISTORY prod_sales.curated.orders;
| version | timestamp | userName | operation | operationParameters | job.jobId |
|---|---|---|---|---|---|
| 15 | 2026-08-26 10:15:00 | etl_sp@corp.com | MERGE | {"predicate": "[...id = ...id]"} | 984120 |
| 14 | 2026-08-25 18:30:00 | engineer@corp.com | OPTIMIZE | {"zOrderBy": "["customer_id"]"} | NULL |
| 13 | 2026-08-25 04:00:00 | etl_sp@corp.com | WRITE | {"mode": "Append"} | 984120 |
Restoring Historical Snapshots
If a pipeline erroneously corrupts a table, engineers can roll back the table instantaneously using RESTORE:
RESTORE TABLE prod_sales.curated.orders TO VERSION AS OF 13;
Restoring does not delete transaction history; it appends a new commit (version 16) that resets the active snapshot to match version 13.
2. Table Retention Properties: Log vs. File Retention
Delta Lake data retention is governed by two complementary table properties configured in TBLPROPERTIES:
A data engineer runs the command 'VACUUM prod_dw.finance.transactions RETAIN 168 HOURS;'. What is the immediate operational result of executing this command?
An enterprise lakehouse is subject to GDPR 'Right to be Forgotten' regulations. A consumer submits a data deletion request. The data engineer executes 'DELETE FROM customers WHERE customer_id = 9912;' on a Delta table. Why is this statement alone insufficient to achieve statutory GDPR compliance?
A data governance team wants to classify tables and columns containing Personally Identifiable Information (PII) using Unity Catalog tags. Which SQL statement correctly applies a tag to a column in Unity Catalog?