Unity Catalog lineage is a dependency map, not a replay log for SQL agents
Databricks can preserve the link between permanent tables after a staging table expires. That link does not tell you every statement the agent ran or every table a function read.
If a SQL agent builds a permanent report through a temporary table, the first incident question might be: Which source tables fed this report? The second is different: What did the agent actually run? Databricks’ Unity Catalog lineage documentation explains why the same graph should not be used to answer both.
The temporary table disappears; the dependency can survive
Databricks documents an example where two permanent orders tables feed a session-local staging table, which then feeds a permanent report. Unity Catalog connects the permanent sources directly to the report at the table and column levels. The temporary table does not appear as a node, and the connection remains after that table expires. That is useful for tracking downstream dependencies, but the edge does not reconstruct the staging steps. Databricks lists supported propagation paths including CREATE TEMP TABLE … AS SELECT, INSERT INTO and INSERT OVERWRITE. It also shows a MERGE INTO example in which the merge source does not appear upstream of the final report. Unity Catalog lineage documentation
There is a separate replay trap: when an unqualified table name matches both a session-local temporary table and a permanent table in the current schema, Databricks resolves the temporary table first. The docs recommend a three-part name to refer explicitly to the permanent table. For a replay or regression fixture, record which names were intended to be temporary and fully qualify permanent inputs where possible. Temporary tables documentation
Keep separate evidence for what ran
Databricks says its lineage system tables emit a record only when lineage can be inferred. It also says Unity Catalog UDF lineage is not queryable through those system tables and that tables or functions referenced inside a UDF body are not captured. An empty lookup therefore does not establish that nothing ran or that a function touched no other data. Lineage system tables reference · Unity Catalog UDF lineage
A practical acceptance test is to stage two known permanent sources into a temporary table, write a permanent output, and check two things separately: whether the expected permanent-to-permanent edges appear, and whether your approved execution record can establish the order and outcome of each step. Use a supported environment: the temporary tables documentation applies to Databricks SQL and Databricks Runtime 18.1 and above. For the second check, consider retaining statement identifiers, execution outcomes and a session correlation key under your existing logging and retention controls. Treat a missing edge as a reason to inspect the execution evidence, not as proof that a dependency does not exist. This is a documentation-based test design, not a live Databricks test.
sources
- Databricks: Lineage in Unity Catalogdocs.databricks.com
- Databricks: Lineage system tables referencedocs.databricks.com
- Databricks: Temporary tables in Databricks SQL and Databricks Runtimedocs.databricks.com
comments · 0