What you will be able to do
- Design a chunk table row with a stable primary key, the chunk text, source identifiers and metadata, and explain what each field does downstream
- Create the chunk table as a managed Delta table under a three-level catalog.schema.table name with the required privileges
- Choose between overwrite, append and MERGE for a first load and for re-ingested documents
- Enable Change Data Feed so a Delta Sync index can follow the chunk table, and put the whole write sequence in order
Key concept
Chunk table as a Delta Sync source — The chunk table is a managed Unity Catalog Delta table with one row per chunk. Each row is identified by a unique primary-key column, and Change Data Feed is turned on so that an index can pick up inserts, updates and deletes incrementally instead of re-reading the whole table.
1.Where the chunk write sits in a RAG data pipeline
The chunk table is the handoff point between data preparation and retrieval. Upstream, raw documents are ingested, parsed and split into chunks. Downstream, those chunks are embedded and indexed for similarity search. The pipeline lists chunking and then indexing and storage as separate steps. A Delta table in Unity Catalog sits between them: the chunker writes to it, and the index reads from it.
How you split the text is a separate decision, covered under chunking strategy. This lesson starts from a DataFrame of chunks that already exists. The question here is what each row must contain, where the table lives, which write operation to use on each run, and which table property lets an index keep up with changes.
The full sequence for turning parsed PDFs into a queryable index looks like this:
- Split the parsed text into chunks and give each chunk a unique identifier plus its source metadata.
- Write the chunk records to a managed Delta table with a three-level
catalog.schema.tablename, including the primary-key column. - Enable Change Data Feed on that table with
delta.enableChangeDataFeed = true. - Create an AI Search endpoint and a Delta Sync index that points at the table and names the primary key and the embedding source column.
Step 4 is the subject of creating a Delta Sync index. The first three steps are what decide whether step 4 works. Databricks AI Search is the product formerly called Databricks Vector Search, and it accepts Delta Lake tables, streaming tables and Iceberg v3 managed tables as sources.
Checkpoint 1 of 9· Put it in order
Put these RAG data-pipeline stages in order, from raw PDFs to a searchable index.
- 1.Ingest the raw source documents into a target table
- 2.Convert the chunks to embeddings and index them for similarity search
- 3.Split the parsed text into chunks and write them to the Unity Catalog Delta table
- 4.Parse the raw documents to extract clean text
The chunk table is the handoff point. The chunker writes parsed text to the table as chunks, and the embedding and indexing step reads those chunks from it. Embedding works on chunked text, so it comes after chunking.
“Embedding: Convert the chunked text data into a numerical vector representation that captures its semantic meaning.”Source: docs.databricks.com
Checkpoint 2 of 9· Exam question
An engineer has parsed raw PDF documents into plain text and needs to end up with a queryable AI Search index built on chunks stored in Unity Catalog. Order the following operations into the correct sequence.(Select 4)
Correct answers: A, B, C, D — Split the parsed document text into chunks using a chosen chunking strategy (e.g., recursive character splitting) and attach a unique identifier and source metadata to each chunk.; Write the chunk records to a managed Delta table in Unity Catalog using a three-level catalog.schema.table name, including a primary-key column.; Enable Change Data Feed on the Delta table by setting delta.enableChangeDataFeed = true in the table properties.; Create an AI Search endpoint and a Delta Sync Index that references the Delta table as its source, specifying the primary key and embedding source column.
- A. Chunking must happen first, since the raw parsed text has to be segmented into retrieval-sized units with identifiers and metadata before anything can be written to a table.
- B. Once chunks exist as structured records, they are written into a Unity Catalog managed Delta table so they persist and are governed under the catalog's access controls before any indexing occurs.
- C. Change Data Feed must be enabled on the Delta table before a Delta Sync Index is created against it, since the index relies on the change feed to perform incremental syncs from that point forward.
- D. Only after the table exists with Change Data Feed enabled can the endpoint and Delta Sync Index be created, since the index creation step requires a valid, sync-ready source table to reference.
2.What a chunk row must hold
A chunk row needs five kinds of field, and each one is there for something that happens later. A typical row has chunk_id, document_id, chunk_index, chunk_text and source_uri, plus any extra metadata.
- A stable primary key (
chunk_id). The index uses it to identify each row. It must be unique and must come out the same every time the same chunk is produced. A value built from the document ID and chunk position meets both conditions. A random UUID created on each run does not. - The chunk text (
chunk_text). This is the embedding source column. The index embeds it and returns it to the retriever. - The source document ID and path (
document_id,source_uri). With these, an answer can cite where it came from, and a re-ingestion run can find every existing chunk of one document. - Position (
chunk_index). This keeps the chunk's order within its document. It also makes the primary key deterministic, because the same document position always produces the same ID. - Metadata such as title, section or date. You can filter on these fields at query time.
Metadata has to be stored with the chunk itself, not kept somewhere else. Storing metadata next to the chunk improves retrieval accuracy, and it lets you combine vector similarity with keyword filtering in hybrid search. The index can only filter on columns it has, and by default it syncs every column of the source table. The primary key column and the embedding source column are always included.
The stable key also protects against a quieter failure: redundant chunks. If the same document gets chunked twice and each copy gets a fresh ID, both copies stay in the table. Duplicate chunks in the final index make the application perform worse. A deterministic key is what lets a later write recognise a chunk it has already stored.
Checkpoint 3 of 9· Check yourself
A chunker gives every chunk a fresh random UUID as its chunk_id each time it runs. A later run chunks the same PDF again and writes the result to the chunk table. What happens?
A random ID is different on every run, so a later write cannot tell it already stored that chunk. Both copies stay in the table, and duplicate chunks in the final index make the application perform worse. A key built from the document ID and chunk position avoids this.
“you can end up with highly redundant chunks in your final index that can decrease the performance of your application.”Source: docs.databricks.com
3.Creating the chunk table as a managed table in Unity Catalog
Create the chunk table as a Unity Catalog managed Delta table. Managed tables are the default and recommended table type. Unity Catalog handles their storage and optimisation, and they cost less to store and query than external tables. Delta is also the default format: Databricks creates a Delta Lake table unless you write USING iceberg.
Always use the full name. Every read and write against a managed table must use the three-level catalog.schema.table name. Path-based access is not supported, because it bypasses Unity Catalog access controls. Two shortcuts fail for this reason. One is writing Parquet files into a volume and registering an external table on top. The other is calling saveAsTable("chunks") with no catalog or schema.
Creating the table takes three privileges, granted on the table's parents:
USE CATALOGon the parent catalog.USE SCHEMAon the parent schema.CREATE TABLEon the parent schema.
The index also needs CREATE TABLE on whichever schema it will be created in.
You can create the table empty before the first load, and doing so lets you set its properties up front. The DeltaTableBuilder API supports Delta-specific options such as table properties, which saveAsTable() does not offer. That makes it a natural place to declare the chunk table's columns together with its properties.
from delta.tables import DeltaTable
DeltaTable.create(spark) \
.tableName("<catalog-name>.<schema-name>.<table-name>") \
.addColumn("<column-name>", "<data-type>") \
.property("<key>", "<value>") \
.execute()Checkpoint 4 of 9· Fill the gap
This builder call creates the empty chunk table as a Unity Catalog managed Delta table before the first load. Which builder method belongs in the blank?
from delta.tables import DeltaTable
DeltaTable.create(spark) \
. ? ("<catalog-name>.<schema-name>.<table-name>") \
.addColumn("<column-name>", "<data-type>") \
.property("<key>", "<value>") \
.execute()A managed table is identified by its three-level catalog.schema.table name, so the builder is given a table name. Pointing it at a storage location or path would be path-based access, which managed tables do not support because it bypasses Unity Catalog access controls.
Source: docs.databricks.com4.First load versus re-ingestion: overwrite, append and MERGE
Delta tables offer three write operations, and each one fits a different run of the pipeline. Overwrite replaces all the data in the table. Append adds rows. MERGE (an upsert) updates the rows that match a key and inserts the rows that don't.
| Operation | What it does | When it fits a chunk table |
|---|---|---|
| mode("overwrite") | Replaces all the data in the table | A deliberate full rebuild, for example after changing chunk size. It rewrites every row, even unchanged ones. |
| mode("append") | Adds new rows without checking for duplicates | The first load into an empty table, or a batch you know contains only new documents |
| MERGE INTO / DeltaTable.merge | Updates matched rows and inserts unmatched ones, keyed on a condition | Every run after the first, when some documents may already be in the table |
Append is right for the first load and wrong for re-ingestion. On an empty table, df.write.format("delta").mode("append").saveAsTable("catalog.schema.chunks") is a correct way to land the chunks. Once a document can come back, though, every append adds another copy. MERGE keyed on the chunk ID fixes this. A chunk that already exists is updated in place, and a new chunk is inserted. Delta allows only one source row to match a given target row, so the key must be unique within each incoming batch too.
MERGE INTO workspace.default.people_10k AS people_10k
USING workspace.default.people_10k_updates AS people_10k_updates
ON people_10k.id = people_10k_updates.id
WHEN MATCHED THEN
UPDATE SET *
WHEN NOT MATCHED THEN
INSERT *;For a chunk table, swap id for the chunk ID. UPDATE SET * and INSERT * only work when the source and target have the same columns. If they don't, the query throws an analysis error, so build the chunk DataFrame to match the table's schema exactly.
A document that gets shorter leaves stale chunks behind. Say a manual used to produce 12 chunks and now produces 9. A plain MERGE updates chunks 0 through 8 and leaves the old 9, 10 and 11 in the table, where the retriever can still return outdated text. The WHEN NOT MATCHED BY SOURCE clause can delete target rows that have no matching source row.
(targetDF.alias("target")
.merge(sourceDF.alias("source"), "source.key = target.key")
.whenMatchedUpdateAll()
.whenNotMatchedInsertAll()
.whenNotMatchedBySourceDelete()
.execute()
)Never run that delete without a condition. A re-ingestion batch usually holds only the documents that changed, so an unconditioned WHEN NOT MATCHED BY SOURCE DELETE would remove the chunks of every other document. Limit the delete to the document IDs in the current batch. Databricks recommends adding a condition anyway, so that the merge does not rewrite the entire target table.
Checkpoint 5 of 9· Match them up
Match each Delta write operation to the pipeline run where it fits the chunk table
Tap a term, then the definition that fits it.
Overwrite replaces all the data, so it suits a full rebuild. Append adds rows without checking for duplicates, so it is only safe when nothing in the batch is already stored. MERGE updates matching chunks in place and inserts new ones, which is what re-ingestion needs.
“Unlike upserting, writing to a table does not check for duplicate records.”Source: docs.databricks.com
Checkpoint 6 of 9· Check yourself
Your nightly re-ingestion batch holds the re-chunked versions of 5 edited manuals. The chunk table holds chunks for 200 manuals. To clear out stale chunks, you add an unconditioned whenNotMatchedBySourceDelete() to the MERGE keyed on chunk_id. What does the MERGE do?
Without a condition, the clause deletes every target row that has no corresponding source row, and that includes the chunks of all documents that were not re-ingested. Limit the delete to the document IDs in the current batch.
“use the WHEN NOT MATCHED BY SOURCE clause to UPDATE or DELETE records in the target table that do not have corresponding records”Source: docs.databricks.com
5.Enabling Change Data Feed so a Delta Sync index can follow the table
A Delta Sync index updates itself by reading the changes made to its source table, so that table must have a change data feed. Delta Sync indexes on standard endpoints refuse a source table without one. A typical error says the table cannot be synced incrementally, and the fix is a single table property.
ALTER TABLE myDeltaTable
SET TBLPROPERTIES (delta.enableChangeDataFeed = true)Run it on the chunk table by its full name, for example ALTER TABLE catalog.schema.chunks SET TBLPROPERTIES (delta.enableChangeDataFeed = true), before you create the index. You can also set the same property when you create the table, using the builder's .property() call. Tables with row tracking enabled get a change data feed automatically, but setting delta.enableChangeDataFeed yourself is the standard step. With the feed in place, each MERGE from the previous section reaches the index as row-level inserts, updates and deletes, keyed on the primary-key column.
The other prerequisites for an AI Search index have nothing to do with how the table was filled:
- A Unity Catalog-enabled workspace.
- Serverless compute enabled.
CREATE TABLEon the schema where the index will be created.
Neither SQL warehouses nor Z-ordering appear among those requirements. How the rows arrived doesn't matter either. A streaming write to a Delta table is an ordinary way to fill it (by default a stream appends new records), so Auto Loader is no more a problem than a batch write. When index creation fails on a table that otherwise looks correct, check whether Change Data Feed is enabled before anything else.
Checkpoint 7 of 9· Check yourself
An Auto Loader stream fills a managed chunk table, main.rag.chunks, which has a unique chunk_id column. Creating a Delta Sync index on it fails with an error saying the table cannot be synced incrementally. A colleague blames the streaming write. What should you do?
By default a streaming write just appends records to a Delta table, so it causes no more trouble than a batch append. The error means the table has no change data feed, so set delta.enableChangeDataFeed = true. Overwriting the table on every run, a SQL warehouse and Z-ordering are not required.
“By default, streams run in append mode and only add new records to the table.”Source: docs.databricks.com
Checkpoint 8 of 9· Exam question
A generative AI engineer has produced a Spark DataFrame of chunked text records, each with document_id, chunk_index, chunk_text, and source_uri columns. The chunks need to land in Unity Catalog in a form that a Delta Sync Index can later consume. Which operation correctly persists the data for this purpose?
Correct answer: A — Write the DataFrame using df.write.format("delta").mode("append").saveAsTable("catalog.schema.chunks"), ensuring the table has a unique primary-key column, then enable delta.enableChangeDataFeed on the table so a Delta Sync Index can track incremental updates.
- A. A managed Delta table written to a three-level
catalog.schema.tablename with a primary-key column and Change Data Feed enabled is exactly what a Delta Sync Index needs to incrementally track and embed new rows. This is the standard sequence for landing chunks in Unity Catalog ahead of indexing. - B. AI Search indexes sync from Delta tables, not directly from raw Parquet files in a volume; volumes store unstructured files, not queryable table data that Delta Sync can track for incremental changes. Writing to a volume skips the transaction log that the sync mechanism relies on.
- C. Unity Catalog table references require an explicit three-level namespace; an unqualified table name resolves relative to the current session catalog and schema rather than being auto-resolved by the index, which can point the index at the wrong table or fail outright.
- D. Overwriting the table on every run destroys the table's history and defeats the purpose of Change Data Feed, which is designed to let the index sync only the incremental rows added since the last sync rather than requiring a full table replacement.
Checkpoint 9 of 9· Exam question
A team created an AI Search endpoint and attempted to create a Delta Sync Index pointing at catalog.schema.chunks, but index creation fails with an error stating the source table cannot be synced incrementally. What is the most likely cause and correct fix?
Correct answer: A — The Delta table was created without Change Data Feed enabled; run ALTER TABLE catalog.schema.chunks SET TBLPROPERTIES (delta.enableChangeDataFeed = true) and then create the index.
- A. A Delta Sync Index relies on Change Data Feed to identify which rows were added, updated, or deleted since the last sync; without
delta.enableChangeDataFeed = trueset on the source table, incremental sync cannot function and index creation fails with exactly this kind of error. - B. Z-ordering is a file-layout optimization for query performance and has no bearing on whether a Delta Sync Index can track incremental changes, so it would not resolve a sync-capability error.
- C. The write pattern used to populate the table (Auto Loader streaming versus batch inserts) is irrelevant to Delta Sync Index compatibility; what matters is whether Change Data Feed is enabled on the resulting Delta table, not how rows were written.
- D. Delta Sync Index sync operations are managed by the vector search service reading the Delta table's change feed directly, not by polling through a SQL warehouse, so attaching a warehouse would not address an incremental-sync failure.
Practise it for real
Build a chunk table that a Delta Sync index can follow, then re-ingest a document without creating duplicates.
1.Create an empty managed table with CREATE TABLE <catalog-name>.<schema-name>.chunks and columns for the chunk ID, document ID, chunk index, chunk text and source URI.
Why: A managed table must be addressed by its three-level name, and the schema fixes the columns that MERGE will later match against.
You should see: The table appears in Catalog Explorer under your catalog and schema with no rows.
2.Load the first batch of chunks with df.write.mode("append").saveAsTable("<catalog-name>.<schema-name>.chunks").
Why: On an empty table there is nothing to duplicate, so a plain append is enough for the first load.
You should see: SELECT COUNT(*) returns the number of chunks in the DataFrame, and every chunk ID appears once.
3.Run ALTER TABLE <catalog-name>.<schema-name>.chunks SET TBLPROPERTIES (delta.enableChangeDataFeed = true).
Why: Delta Sync indexes on standard endpoints need the source table to have a change data feed.
You should see: SHOW TBLPROPERTIES on the table lists delta.enableChangeDataFeed as true.
4.Re-chunk one document, register the result as a view, and MERGE it into the table ON the chunk ID with WHEN MATCHED THEN UPDATE SET * and WHEN NOT MATCHED THEN INSERT *.
Why: MERGE updates the chunks that already exist and inserts the new ones, where an append would add a second copy.
You should see: Grouping by chunk ID shows a count of 1 for every ID, and the edited chunk text has replaced the old text.
Stuck? Get a nudge
If a chunk ID shows a count of 2 after step 4, check whether the incoming batch itself contained that ID twice. Only one source row may match a given target row.
Sources
(8)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/quality-data-pipeline-ragOfficial docs
“Chunking: Break down the parsed data into smaller, manageable chunks for efficient retrieval.”
↩︎ Where the chunk write sits in a RAG data pipeline“Indexing and storage: Create efficient vector indices for optimized search performance.”
↩︎ Where the chunk write sits in a RAG data pipeline“Storing metadata alongside chunked documents or their corresponding embeddings is essential for optimal performance.”
↩︎ What a chunk row must hold“combining vector similarity search with keyword-based filtering, can enhance relevance”
↩︎ What a chunk row must hold“you can end up with highly redundant chunks in your final index that can decrease the performance of your application.”
↩︎ What a chunk row must hold“Embedding: Convert the chunked text data into a numerical vector representation that captures its semantic meaning.”
↩︎ Checkpoint - 2.
“Databricks AI Search was formerly known as Databricks Vector Search.”
↩︎ Where the chunk write sits in a RAG data pipeline“Supported source types include Delta Lake tables, streaming tables, or managed tables using Iceberg v3 or above.”
↩︎ Where the chunk write sits in a RAG data pipeline“To create an AI Search index, you must have CREATE TABLE privileges on the catalog schema where the index will be created.”
↩︎ Creating the chunk table as a managed table in Unity Catalog“For standard endpoints, the source table must use a change data feed.”
↩︎ Enabling Change Data Feed so a Delta Sync index can follow the table“Tables with row tracking enabled use a change data feed automatically, without requiring manual configuration.”
↩︎ Enabling Change Data Feed so a Delta Sync index can follow the table“Serverless compute enabled.”
↩︎ Enabling Change Data Feed so a Delta Sync index can follow the table“For standard endpoints, the source table must use a change data feed.”
↩︎ Key concept“For standard endpoints, the source table must use a change data feed.”
↩︎ Exam trap 3 - 3.
“The primary key column and embedding source column or embedding vector column are always synced.”
↩︎ What a chunk row must hold - 4.https://docs.databricks.com/aws/en/tables/managedOfficial docs
“Unity Catalog managed tables are the default and recommended table type in Databricks for Delta Lake and Apache Iceberg.”
↩︎ Creating the chunk table as a managed table in Unity Catalog“Otherwise, Databricks creates a Delta Lake table by default.”
↩︎ Creating the chunk table as a managed table in Unity Catalog“All reads and writes to managed tables must use table names and catalog and schema names where they exist.”
↩︎ Creating the chunk table as a managed table in Unity Catalog“CREATE TABLE on the table's parent schema.”
↩︎ Creating the chunk table as a managed table in Unity Catalog“use the DeltaTableBuilder API for Delta-specific options like generated columns and table properties”
↩︎ Creating the chunk table as a managed table in Unity Catalog“All reads and writes to managed tables must use table names and catalog and schema names where they exist.”
↩︎ Exam trap 1 - 5.https://docs.databricks.com/aws/en/delta/tutorialOfficial docs
“To replace all the data in a table, use the overwrite mode.”
↩︎ First load versus re-ingestion: overwrite, append and MERGE“Unlike upserting, writing to a table does not check for duplicate records.”
↩︎ First load versus re-ingestion: overwrite, append and MERGE“If the target table does not have the same columns, the query throws an analysis error.”
↩︎ First load versus re-ingestion: overwrite, append and MERGE“Unlike upserting, writing to a table does not check for duplicate records.”
↩︎ Exam trap 2 - 6.https://docs.databricks.com/aws/en/delta/mergeOfficial docs
“Only a single row from the source table can match a given row in the target table.”
↩︎ First load versus re-ingestion: overwrite, append and MERGE“use the WHEN NOT MATCHED BY SOURCE clause to UPDATE or DELETE records in the target table that do not have corresponding records”
↩︎ First load versus re-ingestion: overwrite, append and MERGE“Databricks recommends adding an optional conditional clause to avoid fully rewriting the target table.”
↩︎ First load versus re-ingestion: overwrite, append and MERGE“Databricks recommends adding an optional conditional clause to avoid fully rewriting the target table.”
↩︎ Exam trap 4 - 7.
“Set the table property delta.enableChangeDataFeed = true in the ALTER TABLE command.”
↩︎ Enabling Change Data Feed so a Delta Sync index can follow the table - 8.
“By default, streams run in append mode and only add new records to the table.”
↩︎ Enabling Change Data Feed so a Delta Sync index can follow the table