CertSafari
    Databricks Certified Data Engineer Professional - October 9 onwards· Lessons

    Domain 5 · Lesson 30/45

    Change Data Feed for incremental Delta processing

    Apply Change Data Feed (CDF) to expose row-level changes (updates/deletes) for efficient incremental downstream processing.

    20 min read
    2.5% of exam
    6 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Enable legacy Change Data Feed on new and existing Delta tables, and predict what happens when it is disabled, re-enabled or set as a session default
    • Interpret the _change_type, _commit_version and _commit_timestamp columns of change records, including update pre- and post-images and deletes
    • Read a bounded range of changes with table_changes or readChangeFeed and tell it apart from time travel and DESCRIBE HISTORY
    • Design a downstream pipeline that applies only changed rows to silver or gold tables and tracks the last processed version

    Key concept

    Change Data Feed (CDF) — A per-version log of row-level changes to a table. Each changed row is returned with its data and with metadata saying whether it was inserted, updated or deleted, and in which commit. Downstream jobs can then read only what changed instead of the whole table.

    1.Why downstream tables need row-level changes

    A silver table built from a 500-million-row bronze table should not have to reread all 500 million rows because forty of them changed overnight. Change Data Feed (CDF) solves this. For every committed version of a Delta table, it can return the rows that version inserted, updated or deleted, and tag each row with the kind of change and the version it came from. Incremental ETL, audit trails and replication to downstream tables or external systems all rely on this.

    Reading the table directly with a plain stream doesn't solve the problem. Structured Streaming reads a Delta table as an append-only source. Once an UPDATE, DELETE, MERGE INTO or overwrite touches the source, a stream reading it fails. The other options each give something up. skipChangeCommits keeps the stream running by ignoring modifications. A full refresh reprocesses everything. A materialized view propagates changes automatically, but with higher latency, and only in Lakeflow pipelines and Databricks SQL. CDF is the only one of these that delivers all three change types to code you control.

    Ways to handle upstream modifications to a streamed Delta source
    ApproachWhat propagatesCost or limitation
    skipChangeCommitsAppends only; updates and deletes are ignoredChanges are not propagated downstream
    Full refreshEverything, by recomputingExpensive for large datasets; requires reprocessing all downstream tables
    Change data feedInserts, updates and deletesYou write logic to handle each change type
    Materialized viewsAutomatic change propagationHigher latency; only in Lakeflow pipelines and Databricks SQL

    Databricks has two ways to produce a change feed. Legacy CDF works only on Delta Lake tables. It records the changes when data is written and must be turned on for each table with delta.enableChangeDataFeed. Automatic CDF works out the changes when you read them, using row tracking on Delta tables or row lineage on Iceberg v3 tables. It needs Databricks Runtime 19 or above and a table registered in Unity Catalog, but no per-table setting. Because automatic CDF does no extra work when MERGE INTO and UPDATE write data, writes are faster and storage costs less. Both use the same read APIs, table_changes() and readChangeFeed, so everything about reading changes on this page applies to both.

    Checkpoint 1 of 8· Match them up

    A streaming job reads a Delta table that upstream jobs sometimes update and delete. Match each way of handling those modifications to what it does.

    Tap a term, then the definition that fits it.

    Sources12

    2.Turning the legacy feed on and off

    Legacy CDF is a table property, and you can set it in either of two places. For a new table, put delta.enableChangeDataFeed = true in the TBLPROPERTIES clause of CREATE TABLE. For a table that already exists, set the same property with ALTER TABLE ... SET TBLPROPERTIES. Neither requires converting the table to another format: legacy CDF is a Delta Lake feature.

    Enabling the legacy change data feed on an existing Delta tablesql
    ALTER TABLE your_catalog.your_schema.your_table
    SET TBLPROPERTIES (delta.enableChangeDataFeed = true)

    A SparkSession setting won't enable CDF on tables that already exist. Session configurations can set default property values for new tables, and those defaults only apply to tables created afterwards. They don't change the properties of tables that already exist. To add CDF to an existing table, you still run ALTER TABLE on that table.

    The feed starts at the commit where you enable it. It is not backfilled. Changes made before CDF was enabled are not recorded, and asking table_changes for a version from before then raises an error. Turning the property off and on again works the same way. Legacy CDF can be disabled with UNSET TBLPROPERTIES, and any commits made while it was off are a permanent gap in the feed. Disabling it is also the first step when you migrate a table to automatic CDF, because you can't run the legacy and automatic feeds on the same table.

    Turning off legacy change data feed, for example before migrating to automatic CDFsql
    ALTER TABLE <table_name> UNSET TBLPROPERTIES ('delta.enableChangeDataFeed');

    The legacy feed affects storage in three ways. First, change data may be written to separate files, which adds a small amount to storage costs. Second, some operations, such as insert-only writes and deletes of whole partitions, write no change files at all; for those, Databricks computes the feed from the transaction log. Third, change files follow the table's retention policy, so VACUUM deletes them. Always read changes through the APIs, never by querying the change files directly.

    Checkpoint 2 of 8· Check yourself

    An existing Delta table is at version 40 when an engineer runs ALTER TABLE ... SET TBLPROPERTIES (delta.enableChangeDataFeed = true). That commit becomes version 41. What does the change feed contain from then on?

    Checkpoint 3 of 8· Exam question

    A platform team is documenting how Change Data Feed can be enabled and what happens if it is toggled off and back on for a Delta table. Which of the following statements are correct?(Select 3)

    0 of 3 selected

    Sources23

    3.Reading a change record

    A change feed returns every column of the table, in the schema of the latest table version, plus three metadata columns. These columns are what downstream logic branches and sorts on.

    Metadata columns added to every change data feed row
    ColumnTypeMeaning
    _change_typeSTRING NOT NULLOne of insert, update_preimage, update_postimage, delete
    _commit_versionBIGINT NOT NULLTable version whose commit contained the change
    _commit_timestampTIMESTAMP NOT NULLTimestamp at which that commit was created

    The example below makes four commits to a small table. Versions 1 and 2 insert rows. Version 3 upper-cases two values. Version 4 deletes a row.

    A CDF-enabled table and four modifying commitssql
    -- Create a Delta table with Change Data Feed;
    > CREATE TABLE myschema.t(c1 INT, c2 STRING) TBLPROPERTIES(delta.enableChangeDataFeed=true);
    
    -- Modify the table
    > INSERT INTO myschema.t VALUES (1, 'Hello'), (2, 'World');
    > INSERT INTO myschema.t VALUES (3, '!');
    > UPDATE myschema.t SET c2 = upper(c2) WHERE c1 < 3;
    > DELETE FROM myschema.t WHERE c1 = 3;
    The change feed from version 2 onward: one insert, two pre/post pairs, one deletesql
    > SELECT * FROM table_changes('`myschema`.`t`', 2);
     c1 c2     _change_type    _commit_version _commit_timestamp
      3 !      insert                        2 2022-09-01T18:32:28.000+0000
      2 WORLD  update_postimage              3 2022-09-01T18:32:32.000+0000
      2 World  update_preimage               3 2022-09-01T18:32:32.000+0000
      1 Hello  update_preimage               3 2022-09-01T18:32:32.000+0000
      1 HELLO  update_postimage              3 2022-09-01T18:32:32.000+0000
      3 !      delete                        4 2022-09-01T18:32:35.000+0000

    The output shows what each change type carries:

    • An insert row holds only the new values, because the row had no earlier state.
    • An update produces a pair in one commit. update_preimage holds the old values (World) and update_postimage holds the new ones (WORLD), so you can compare before and after without a second query.
    • A delete row appears once and carries the row's last values (3, !), so you never have to look up what was removed.

    These four strings are the only values _change_type can take. A MERGE INTO that inserts some rows and updates others still writes insert rows and pre/post-image pairs; there is no upsert type. The commit columns are NOT NULL for every change type, so you can always sort inserts, updates and deletes by _commit_version. The change types are also not SQL clauses: you still have to map them onto WHEN MATCHED and WHEN NOT MATCHED logic yourself.

    Checkpoint 4 of 8· Check yourself

    In one MERGE INTO commit (version 12), 2 source rows match no target row and are inserted, and 3 source rows match existing target rows and update them. What does table_changes return for version 12?

    Checkpoint 5 of 8· Exam question

    A team reads Change Data Feed output from finance.ledger and writes Python logic that branches on the _change_type column to route rows to an audit table. Which statements about the _change_type values are correct?(Select 3)

    0 of 3 selected

    Sources42

    4.Reading a bounded range of versions

    In SQL, batch reads use table_changes(table_str, start [, end]). In Python, they use spark.read with readChangeFeed. A start version is required for batch reads. If you pass an end version, the read stops there; if you leave it out, it reads to the latest commit. Both bounds are inclusive, so table_changes('analytics.orders', 12, 18) returns every change committed in versions 12 through 18. Bounds can also be timestamps, written as strings in the format yyyy-MM-dd[ HH:mm:ss[.SSS]]. Calling the function requires SELECT on the table, ownership of it, or admin privileges.

    Batch read of versions 0 through 10 inclusive in Pythonpython
    spark.read \
      .option("readChangeFeed", "true") \
      .option("startingVersion", 0) \
      .option("endingVersion", 10) \
      .table("myDeltaTable")

    table_changes raises an error for a bound earlier than the earliest available version, and for one later than the latest version or latest commit timestamp. Old versions disappear on schedule. The feed is transient: when the transaction log removes table versions, their change records go with them. A job that falls far enough behind can find that the versions it needs no longer exist. If you need a permanent change history, copy the feed into a table of its own.

    Two other features look like they answer the same question but don't. VERSION AS OF time travel returns the whole table as it was at one version, and comparing two snapshots to work out what changed is exactly the full-scan work CDF avoids. DESCRIBE HISTORY lists one row per commit, with its operation, user, timestamp and parameters, but none of the row data that changed.

    Checkpoint 6 of 8· Fill the gap

    This batch read must return every change committed in versions 0 through 10, with version 10 included and nothing after it. Which value completes the endingVersion option?

    spark.read \
      .option("readChangeFeed", "true") \
      .option("startingVersion", 0) \
      .option("endingVersion",  ? ) \
      .table("myDeltaTable")

    Checkpoint 7 of 8· Exam question

    A downstream job must audit exactly the row-level changes that occurred between Delta version 12 and version 18, inclusive, on analytics.orders, which has Change Data Feed enabled. Which SQL statement retrieves precisely this range of changes?

    Sources245

    5.Applying only changed rows downstream

    For incremental processing, Databricks recommends streaming from a table's change feed rather than from the table itself, wherever possible. Set readChangeFeed to true on spark.readStream. The checkpoint then records which versions have been processed, and Databricks only tracks versions automatically when you use Structured Streaming. Each run picks up from the next unprocessed commit. With trigger(availableNow=True), the stream becomes a scheduled incremental batch that processes the backlog and stops. Checkpoints and triggers themselves are covered in Structured Streaming state and checkpoints.

    Watch the first run. A new CDF stream with no starting version first returns the table's current snapshot as insert records, then the changes after it. That is what a brand-new target needs. If the target already holds the data up to some version, set startingVersion so the snapshot isn't loaded again as duplicate inserts.

    The changed rows still have to be merged into the silver or gold table. A typical MERGE keyed on the business key:

    1. Filters out update_preimage rows, because the postimage already holds the updated row.
    2. Deletes the matched target row when _change_type = 'delete'.
    3. Updates matched rows and inserts unmatched ones from the remaining insert and update_postimage rows.
    4. Keeps only the latest event for each key in the batch, ranked by _commit_version (or _commit_timestamp), so the newest change to a key is the one that wins.

    The same events can instead feed a declarative flow that does this reconciliation for you; see AUTO CDC with SCD types.

    Step 4 matters because one read of the feed can return several events for the same key. A single logical change already produces more than one: moving one product to a new warehouse yields an insert, an update_preimage and an update_postimage for that product across the versions read. A batch that spans several commits can also hold an insert, then two updates, then a delete for one key. Merging all of them as they come leaves the outcome dependent on event order rather than on commit order. Rank the rows within each key before the merge: after dropping preimages, number them with ROW_NUMBER() OVER (PARTITION BY <key> ORDER BY _commit_version DESC) and keep only the rows numbered 1. Run the MERGE from that result, so each key meets the target once. Its _change_type then decides the action: delete the target row for delete, otherwise update or insert.

    Each run touches only the new commits. In a Databricks SQL tutorial, a streaming table built from a product table's change feed was refreshed after two products were deleted with DELETE FROM products WHERE product_id = 9; and the same for product 10. The refresh processed only those two delete events, closed out the two products' records, and left the earlier inserts and updates alone. To track progress yourself in a batch job, record the highest _commit_version written to the target; the next read starts one version later.

    Resuming after a corrupted checkpoint: the target holds changes through version 75, so the new stream starts at 76python
    (spark.readStream
      .option("readChangeFeed", "true")
      .option("startingVersion", 76)
      .table("source_table")
      .writeStream
      .option("checkpointLocation", "<new-checkpoint-path>")
      .toTable("target_table")
    )

    Two conditions must hold for this restart to work. The stream writing to the existing target must use a new checkpoint location, and version 76 must still be in the source history. If that version has already been cleaned up, the stream fails to start. On managed tables, every starting version you might choose is eventually deleted, so recover soon after a checkpoint fails.

    Checkpoint 8 of 8· Fill the gap

    A stream's checkpoint is corrupted. The existing target table already holds every change through version 75 of the source. The replacement stream must not reload the source's current state as duplicate insert records. Which option completes the sample?

    (spark.readStream
      .option("readChangeFeed", "true")
      .option(" ? ", 76)
      .table("source_table")
      .writeStream
      .option("checkpointLocation", "<new-checkpoint-path>")
      .toTable("target_table")
    )

    Sources126

    Practise it for real

    Create a CDF-enabled table, generate inserts, updates and deletes, and read them back by version range

    1. 1.Run CREATE TABLE myschema.t(c1 INT, c2 STRING) TBLPROPERTIES(delta.enableChangeDataFeed=true);

      Why: Turns on legacy CDF at creation, so every later commit is recorded

      You should see: DESCRIBE HISTORY shows version 0, CREATE TABLE, with delta.enableChangeDataFeed true in its properties

    2. 2.Insert (1,'Hello'),(2,'World'), then (3,'!'), then UPDATE myschema.t SET c2 = upper(c2) WHERE c1 < 3, then DELETE FROM myschema.t WHERE c1 = 3

      Why: Produces one commit of each kind of change

      You should see: DESCRIBE HISTORY lists versions 1 to 4 as WRITE, WRITE, UPDATE, DELETE

    3. 3.Run SELECT * FROM table_changes('myschema.t', 2);

      Why: Reads every change from version 2 to the latest

      You should see: Six rows: one insert at version 2, two pre/post pairs at version 3, one delete at version 4

    4. 4.Run SELECT * FROM table_changes('myschema.t', 3, 3);

      Why: Shows that both bounds are inclusive

      You should see: Only the four update_preimage and update_postimage rows from version 3

    Stuck? Get a nudge

    If a read fails with an out-of-range error, check the start and end versions against DESCRIBE HISTORY.

    Sources

    (6)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Structured Streaming only accepts append inputs and throws an exception if any modifications occur on the source Delta Lake table.”
      ↩︎ Why downstream tables need row-level changes
      “Databricks recommends streaming from the CDC feed of a Delta Lake table rather than directly from the table whenever possible.”
      ↩︎ Applying only changed rows downstream
      “Change data feed | Process all change types (inserts, updates, and deletes).”
      ↩︎ Checkpoint
    2. 2.
      “Legacy change data feed: Materializes changes during table writes. Only supports Delta Lake tables. Requires individual table configuration.”
      ↩︎ Why downstream tables need row-level changes
      “Automatic change data feed computes row-level changes at query time rather than at write time”
      ↩︎ Why downstream tables need row-level changes
      “Set the table property delta.enableChangeDataFeed = true in the ALTER TABLE command.”
      ↩︎ Turning the legacy feed on and off
      “If you specify a version before change data feed was enabled, it raises an error.”
      ↩︎ Turning the legacy feed on and off
      “You can't use both legacy and automatic change data feeds together.”
      ↩︎ Turning the legacy feed on and off
      “You might see small increase in storage costs because changes might be recorded in separate files.”
      ↩︎ Turning the legacy feed on and off
      “If the schema contains columns with the same names as these metadata columns, you can't use change data feed on a table.”
      ↩︎ Turning the legacy feed on and off
      “When you read from the change data feed for a table, the query uses the schema for the latest table version.”
      ↩︎ Reading a change record
      “Start and end versions are inclusive. To read from a starting version to the latest version, specify only the starting version.”
      ↩︎ Reading a bounded range of versions
      “Records in the change data feed are transient and only accessible for a specified retention window.”
      ↩︎ Reading a bounded range of versions
      “You must use Structured Streaming for Databricks to automatically track versions for your table's change data feed.”
      ↩︎ Applying only changed rows downstream
      “change data feed returns the latest snapshot of the table as INSERT records and then returns future changes as change data”
      ↩︎ Applying only changed rows downstream
      “When you define the write stream to the existing target table, you must specify a new checkpoint location:”
      ↩︎ Applying only changed rows downstream
      “Because managed tables clean up historic versions automatically, all specified starting versions are eventually deleted.”
      ↩︎ Applying only changed rows downstream
      “Change data feed (CDF) tracks row-level changes between versions of a Delta Lake table or Apache Iceberg v3 table.”
      ↩︎ Key concept
      “It only records changes that occur after change data feed was enabled.”
      ↩︎ Exam trap 2
      “Start and end versions are inclusive.”
      ↩︎ Exam trap 4
      “specify a starting version to avoid processing the source table state as INSERT events.”
      ↩︎ Exam trap 5
      “It only records changes that occur after change data feed was enabled.”
      ↩︎ Checkpoint
      “preimage is the value before the update, postimage is the value after the update.”
      ↩︎ Prediction
      “Contains: insert, update_preimage, update_postimage, delete.preimage is the value before the update, postimage is the value after the update.”
      ↩︎ Checkpoint
    3. 3.
      “These defaults only apply to new tables and don't affect existing table properties.”
      ↩︎ Turning the legacy feed on and off
      “These defaults only apply to new tables and don't affect existing table properties.”
      ↩︎ Exam trap 1
    4. 4.
      “_commit_version BIGINT NOT NULL Specifies the commit version of the table associated with the change.”
      ↩︎ Reading a change record
      “A version earlier than the earliest available version of the table.”
      ↩︎ Reading a bounded range of versions
      “_change_type STRING NOT NULL Specifies the change: delete, insert, update_preimage, or update_postimage”
      ↩︎ Exam trap 3
    5. 5.
      “Delta tables (each table version is effectively a snapshot)”
      ↩︎ Reading a bounded range of versions
    6. 6.
      “WHERE _change_type != 'update_preimage': skips preimages. The postimage already has the updated row.”
      ↩︎ Applying only changed rows downstream
      “a single logical change (for example, moving the Spoon to a different warehouse) produces multiple events: a preimage and a postimage.”
      ↩︎ Applying only changed rows downstream
      “The streaming table only processed the new delete events without reprocessing the inserts and updates from the previous refresh.”
      ↩︎ Applying only changed rows downstream

    Spotted a mistake, or was something unclear? Tell us.