Data Engineering

Building a Cost-Aware Data Freshness Framework in Databricks

Data Platform · Databricks · Observability
Focus
Gold Layer Data Freshness
Platform
Databricks / Unity Catalog / Iceberg
Strategy
Progressive + Partition-Aware
Goal
Accuracy, Cost Efficiency & Explainability

The Problem

When was this Gold table actually updated?

A recent data-platform problem made our team rethink what initially appeared to be a very simple question: “When was this Gold table last updated?”

At first glance, querying information_schema.tables.last_altered looks like the obvious answer.

But there is a hidden trap: a table can be modified without receiving new business data. Maintenance activity can make a table appear recently altered while the actual ingestion has stalled for days.

Evaluating the Standard Approaches

Approach 01

last_altered

✓ Advantage
Extremely cheap and easy to query.
✕ Problem
Represents table/object modification rather than necessarily representing new business data.
Approach 02

MAX(timestamp)

✓ Advantage
Closest to the actual meaning of data freshness.
✕ Problem
A full-table aggregation can become expensive on large Gold tables.
Approach 03

Iceberg Metadata / History

✓ Advantage
Provides a transaction-level view without scanning the business data.
✕ Problem
Running history-based checks indiscriminately across frequently updated tables introduces its own scalability considerations.

The Hybrid Approach

Instead of asking “Which one of these methods should we use?”, we reframed the problem:

Can we use the cheapest reliable signal first and progressively escalate only when necessary?

The result is a tiered detection framework designed to balance accuracy, cost, scalability and visibility.

Step 1: Automatically Discover Gold Tables

We use Unity Catalog metadata to automatically identify the tables belonging to the Gold layer.

This is important because the framework should not contain manually maintained monitoring logic for every individual table.

information_schema.tables
          │
          ▼
     Gold Tables
          │
          ▼
   Freshness Engine

Step 2: Progressive Partition Scanning

Our Gold tables are partitioned by date. Instead of scanning the entire table to determine the latest ingestion timestamp, we exploit that partitioning strategy.

The freshness engine uses configurable lookback windows:

1 day
3 days
5 days
7 days
14 days
30 days
60 days
90 days

We start with the smallest window. If a valid ingestion timestamp is found, the evaluation is complete. If not, the engine progressively expands the lookback window.

Why this works

Most healthy Gold tables have regular ingestion patterns. For these tables, we only need to inspect a very small portion of the data rather than repeatedly scanning the entire table.

Step 3: History as an Exception Handler

What happens when the progressive partition search cannot identify a valid ingestion timestamp?

Only then do we fall back to table history.

Partition scan │ ├── Data found ───────────────► Calculate freshness │ └── No data found │ ▼ Expand window │ ├── Data found ──► Calculate freshness │ └── Still missing │ ▼ DESCRIBE HISTORY │ ▼ Resolve exception

This fundamentally changes the role of history inspection. Instead of treating it as the default freshness mechanism for every table, we use it as an exception-resolution mechanism.

The Architecture

Unity Catalog │ ▼ information_schema │ Discover Gold tables │ ▼ Freshness Engine │ ▼ 1-Day Partition Scan │ Data found? / \ YES NO │ │ │ ▼ │ Expand window │ 3 → 5 → 7 → 14... │ │ │ ▼ │ Data found? │ │ │ ▼ │ Still missing? │ │ │ ▼ │ DESCRIBE HISTORY │ │ └──────┬──────┘ ▼ Freshness Result │ ▼ Gold Freshness Table │ ┌──────────┴──────────┐ ▼ ▼ Freshness Dashboard Stale Investigation │ ▼ Lineage Tracing │ Job → Notebook → Source

What We Capture

Rather than storing only a single timestamp, the freshness result contains enough information to explain how the platform arrived at that result.

Last altered timestamp Metadata-level activity
Latest ingestion timestamp Actual data freshness signal
Latest data-changing commit Technical table activity
Freshness lag vs SLA Operational health
Detection method Partition scan or history fallback
Partitions scanned Useful for cost and performance analysis

Retaining last_altered for Diagnostics

We didn't throw last_altered away. It simply answers a different question.

By retaining it alongside the actual freshness signals, we can identify discrepancies instead of hiding them.

Last Altered
Today · 10:00 AM
Latest Data
10 Days Ago
The table is active — but the data isn't fresh.

The discrepancy immediately tells us that recent table activity should not automatically be interpreted as recent business-data ingestion. This is exactly the type of false-positive signal we wanted the new framework to eliminate.

Beyond Freshness: Root-Cause Analysis

A freshness dashboard that only tells us “this table is stale” is useful—but it is only the beginning.

For tables that remain stale beyond a defined threshold, such as 30 days, we want to understand why.

Stale Gold Table │ ▼ Lineage │ ├── Upstream Job │ ├── Notebook / Pipeline │ └── Source Dataset │ ▼ Root Cause Analysis │ ┌───────┼────────┐ ▼ ▼ ▼ Paused Failed No Source Data

The investigation can determine whether the upstream job is paused, the pipeline has failed, the source has stopped producing data, or the table is intentionally static.

From symptom to diagnosis

Instead of simply reporting “This table is stale”, the platform moves toward explaining: “This table is stale because its upstream source has stopped producing data.”

The Bigger Picture

Data freshness isn't just a timestamp problem. It is a balance between correctness, cost, scalability and explainability.

Cheap Signal Catalog metadata
Targeted Scan Partition-aware data check
Metadata Fallback History for exceptions
Root Cause Lineage-based diagnosis
The principle

Use the cheapest reliable signal first, and invoke more expensive mechanisms only when the cheaper signal cannot provide a confident answer.

Final Thought

The goal isn't to find one perfect freshness metric.

The goal is to build a system that can make a reliable freshness determination across a large and evolving data platform while keeping compute under control—and, just as importantly, explain how it reached that conclusion.

Freshness should tell us not only whether data is fresh, but also give us the evidence needed to understand when it isn't.

Data Platform Engineering · Databricks · Data Observability