Data Engineering · 4 min read

Spark Declarative Pipelines Rewind Rolls Back Whole Pipelines, Not Just Tables

SDP's new beta rewind feature restores entire pipelines — tables, streaming state and Auto Loader ingestion — to consistent snapshots, replacing the ad hoc backfills that Delta Lake RESTORE leaves behind.

By Rebecca Stone702 words

Key takeaways

  1. Spark Declarative Pipelines beta adds pipeline-level rewind via periodic metadata snapshots called rewind points
  2. Delta Lake RESTORE reverts table contents but leaves processes treating data as processed, forcing ad hoc backfills
  3. A new control batch type on replay skips already-consumed data ranges to prevent duplication
  4. Auto Loader integration relies on a new rewind log indexing archived checkpoint files for fast replay lookup
  5. Roadmap includes rewinding pipeline definitions and a consumer protocol for detecting rewinds
Spark Declarative Pipelines Rewind Rolls Back Whole Pipelines, Not Just Tables
lawrence_monk / pixabay

Spark Declarative Pipelines (SDP) now offers a rewind feature that rolls an entire dataflow graph — table data and operational state — back to a consistent snapshot, then replays the stream from that point. The beta, detailed in an engineering post by Databricks engineer Jose Torres, targets a recovery problem that Delta Lake's existing RESTORE command leaves half-solved.

What does the rewind actually change?

Delta Lake's transaction log already supports time travel on a per-table basis. A user can inspect a table's history, see which operations ran, when, and who ran them, and even RESTORE the table to a previous version. But RESTORE only reverts the data. The processes that performed the write still consider the data processed. Recovery then requires ad hoc backfills, and in a pipeline managing hundreds or thousands of tables, the post calls that range "from annoying to outright infeasible."

The new rewind closes that gap. As the graph executes, the pipeline periodically generates "rewind points" — consistent metadata snapshots holding information for each flow and dataset. When something breaks, an engineer picks a snapshot, executes the rewind, applies whatever fix the incoming data or transformation logic needs, and resumes processing as though nothing went wrong. No backfills, no out-of-band coordination.

How does it handle streaming offsets?

Two hard problems sit under the hood. First, identifying which version to rewind to for each dataset and flow. Triggered execution makes this straightforward: snapshots between updates suffice. Continuous execution is harder, because dependent flows and datasets can run in parallel and out of alignment.

SDP solves this in two steps. When computing a rewind point, the system maintains a set of graph invariants that guarantee naive reprocessing produces a superset of the rewound data. On replay, extra streaming logic — a new batch type called a control batch — instructs each flow to skip the data range it already consumed, preventing duplication.

Second, implementing the rewind on the Structured Streaming process behind each flow. Structured Streaming already keeps a metadata log with incrementing versions, originally built for failure recovery and idempotent, repeatable batches. The SDP team extended the checkpoint layer with new functionality, including a read_state_metadata lookup analogous to DESCRIBE HISTORY in Delta Lake, to support pinning the stream back to a prior version.

What about Auto Loader?

Auto Loader (the file-ingestion source that consumes transient cloud file notifications) posed a distinct obstacle: consumed notifications cannot be restored, so rewinding the stream alone cannot reconstruct the original source state. The team's answer is a new component called the rewind log, which stores metadata for archived checkpoint files and enables fast lookup of the files holding relevant replay information. The same log supports on-demand checkpoint loading during normal execution, keeping disk usage in check as retention grows.

What should a data team do with this?

The immediate answer: evaluate the beta if you run declarative pipelines where bad rows propagate across many tables or corrupt operational state, such as an improperly advanced watermark or a poisoned intermediate aggregate buffer. To pick a rewind point, use the data preview in the rewind interface or plain Delta Lake time travel to inspect each dataset's historical state, then choose a snapshot from before the issue started. Faulty transformation logic gets fixed before replay; out-of-band data corrections can be filtered out of the stream while awaiting a separate backfill.

Two caveats for planners. Rewind works with both triggered and continuous pipelines, but continuous mode relies on the superset-replay guarantee rather than precise alignment. And downstream automated consumers currently cannot distinguish a rewind from any other update.

What is still on the roadmap?

The team plans three follow-on efforts. First, rewinding the pipeline definition itself, enabling one-step recovery from code changes that produced invalid data; the abstract definition spans several components the team is still investigating. Second, a protocol letting platform-wide consumers detect that a rewind occurred and react accordingly. Third, continued refinement of Auto Loader integration.

For now, the feature is in beta, and Databricks positions it as a starting point. Analysts should note what it replaces: manual, script-driven correction work that declarative pipelines were meant to eliminate in the first place.

docs.databricks.com (Original)

Price tags

Share this article:

More from Rebecca Stone

Rebecca Stone

Show full bio

Senior reporter covering regulation, policy and their impact on Analytics Digest is a professional daily at Analytics Digest.

72 articles

Read also

« Previous articleNext article »