CertSafari
    Databricks Certified Context Engineer Associate· Lessons

    Domain 3 · Lesson 15/45

    RAG pipeline design over a Unity Catalog document corpus

    Design a RAG pipeline that retrieves chunks from a Unity Catalog-governed document corpus and injects them into agent context.

    17 min read
    2.22% of exam
    7 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Order the stages of a RAG data pipeline that turns files in a Unity Catalog volume into a queryable AI Search index
    • Choose between Databricks-managed and self-managed embeddings for a Delta Sync index, and identify the change data feed prerequisite for syncing
    • Trace a request through the RAG chain from query embedding to generation
    • Wrap an AI Search index in a VectorSearchRetrieverTool so retrieved chunks enter agent context as a tool result, under a specific identity's grants

    Key concept

    The chunk table as the hinge of RAG — Every step of a governed RAG system meets at one Delta table of chunks. The data pipeline writes that table, the AI Search index syncs from it, and at request time the query is embedded with the same model that embedded the chunks so the two vectors can be compared.

    1.Two halves of a RAG system: the data pipeline and the chain

    Retrieval-augmented generation gives an agent knowledge the model was never trained on, such as internal memos, product manuals and policies, by fetching relevant text and putting it into the prompt. It does this in three moves. Retrieval queries a knowledge base with the request. Augmentation combines what came back with the request, usually through a template. Generation passes that augmented prompt to the LLM.

    These three moves happen at request time, but they depend on work done long before any user asks anything. A RAG application therefore splits into a data pipeline, which pre-processes and indexes the corpus, and a RAG chain, which runs per request. Evaluation, monitoring and governance sit around both. Most design mistakes come from putting a step in the wrong half: chunking at query time, or embedding with a model that differs from the one the chain uses.

    Building the corpus on Unity Catalog adds something an ad-hoc vector store lacks. Because the raw files, the parsed table, the chunk table and the index are all governed objects, the retrieval step can be limited by who is asking. The Databricks RAG overview lists access control as a core benefit: retrieval can be designed to return personal or proprietary information only to the credentials allowed to see it.

    Checkpoint 1 of 9· Check yourself

    A team's design waits for a user's question to arrive, then splits the relevant documents into chunks and retrieves from those chunks. Based on how a RAG application is split, what is wrong with this design?

    Sources1

    2.The data pipeline: from volume files to a chunk table

    The pipeline is a fixed sequence, and each stage writes the input the next stage reads:

    1. Ingest the raw sources and store them in a target table, so the original data stays preserved, traceable and auditable.
    2. Parse the files into clean text. On Databricks, ai_parse_document produces structured output from documents, and parsing is also where headers, footers and other noise are stripped.
    3. Chunk the parsed content into rows. ai_prep_search accepts either ai_parse_document output or plain text and markdown, splits it into semantic chunks, and adds document-level context such as the title, section headers and page references to each chunk.
    4. Embed each chunk with an embedding model, which turns the text into a vector that captures its meaning.
    5. Index the chunk table in AI Search so the chain can run similarity search against it.

    How to split a document is a separate decision; see Chunking strategy matched to document structure. What matters for pipeline design is what chunking produces: rows in a governed Delta table, each with a primary key, the chunk text, and metadata columns such as source document name or section heading. Those rows are the only thing the index ever sees. Metadata that is not stored on the chunk row cannot be filtered on or returned at retrieval time. That is why metadata belongs alongside the chunks themselves and not in a separate lookup.

    The embedding step has one constraint that the RAG chain depends on later. Whatever model embeds the chunks must also embed every query. Its token limit matters as well: a chunk longer than the model's maximum is truncated before embedding. bge-large-en-v1.5, for example, stops at 512 tokens, and anything past that never reaches the vector.

    Checkpoint 2 of 9· Put it in order

    Your raw PDFs have just landed in a Unity Catalog volume. Put the data pipeline stages in the order that turns them into something the RAG chain can search.

    1. 1.Ingest the raw source files and store them in a target table so the originals stay traceable and auditable
    2. 2.Embed each chunk with an embedding model to get a vector that captures its meaning
    3. 3.Build the AI Search index on the chunk table so the chain can run similarity search against it
    4. 4.Split the parsed text into chunks, stored as rows of a Delta table with a primary key and metadata columns
    5. 5.Parse the files into clean text, removing noise such as headers and footers

    Checkpoint 3 of 9· Exam question

    A context engineer is designing a RAG pipeline that must retrieve chunks from a Unity Catalog-governed document corpus and inject them into an agent's context. The source PDF files already exist in a Unity Catalog volume and have been parsed into plain text. What is the correct order of the remaining pipeline stages?

    Sources23

    3.Creating the index: Delta Sync, embeddings and the change data feed

    An AI Search index serves real-time similarity search over a source table, which can be a Delta Lake table, a streaming table, or a managed Iceberg v3+ table. For a governed RAG corpus, that source is the chunk table, and a Delta Sync index keeps the index aligned with it. A Direct Vector Access index is the other type. It does not sync from a source table, so it is not the way to make new chunk rows appear.

    A Delta Sync index on a standard endpoint has a prerequisite that is easy to miss: the source table must use a change data feed. Tables with row tracking enabled get one automatically, and both Delta Lake and Iceberg v3+ managed tables qualify. Without it, a team can enable continuous sync, insert new chunk rows, and see none of them in the index. The fix is the table property. Changing the index type or moving data into a volume does not help. Creating the index also requires CREATE TABLE on the schema where the index will live.

    The embedding decision splits Delta Sync indexes in two. With Databricks-managed embeddings, you point the index at a text column and an embedding endpoint, either a pre-configured Foundation Model APIs endpoint or your own model serving endpoint, and Databricks computes the vectors. With self-managed embeddings, you compute the vectors yourself and store them in a column of the source table, and the index uses them as they are. A team with a proprietary in-house embedding model that wants those exact vectors indexed should choose self-managed embeddings on a Delta Sync index. Choosing managed embeddings would recompute the vectors with a different model.

    Embedding options for an AI Search index
    OptionIndex typesWhere vectors come fromWhat the retriever must be told
    Databricks-managed embeddingsDelta SyncDatabricks computes them from a text column using an embedding endpointIndex name only; embeddings are handled for you
    Self-managed embeddingsDelta Sync or Direct Vector AccessPrecomputed vectors you supply, held in an embedding columntext_column plus the embedding model (embedding or embedding_model_name)

    Checkpoint 4 of 9· Check yourself

    Continuous sync is turned on for a Delta Sync index on a standard endpoint, but chunk rows inserted into the source table never appear in search results. What fixes this?

    Checkpoint 5 of 9· Check yourself

    Your in-house embedding model has already written a vector for every chunk into a column of the chunk table. You want exactly those vectors searched, and you want the index to follow the table. Which setup is correct?

    Checkpoint 6 of 9· Exam question

    A data science team already computes embeddings for their documents using a proprietary in-house model and wants the RAG pipeline's AI Search index to use those exact vectors, without Databricks recomputing them from a specified embedding model. Which index configuration should they use?

    Checkpoint 7 of 9· Exam question

    A team configures an AI Search index in Delta Sync (continuous) mode on a standard endpoint so the index automatically reflects new rows added to the source Delta table. After enabling sync, newly inserted rows are not appearing in the index. What is the most likely missing prerequisite?

    Sources456

    4.The RAG chain at request time

    Once the index exists, every user request runs through the same chain of steps. The chain is where the pipeline's choices either pay off or break.

    The steps run in this order:

    1. Optional query preprocessing rewrites the request, wraps it in a template or extracts keywords, producing a retrieval query.
    2. Retrieval embeds that query with the same model that embedded the chunks, compares it against the chunk vectors by a measure such as cosine similarity, and returns the top-ranked chunks.
    3. Prompt augmentation places the retrieved chunks next to the request in a template that tells the model how to use each part.
    4. Generation runs the LLM on the augmented prompt, so the answer is grounded in the retrieved text.
    5. Optional post-processing adds citations or applies business rules to the output.

    Two settings in this chain directly shape what enters the model's context: how many chunks retrieval returns, and how the template combines them with the query. Too few chunks and the answer is missing facts. Too many and the prompt fills with loosely related text. Guardrails can be applied at any step, including a permission check before a data source is touched, and that check is what keeps a governed corpus governed at request time.

    Checkpoint 8 of 9· Match them up

    Each action below happens while one user request runs through the RAG chain. Match each step of the chain to the action that belongs to it.

    Tap a term, then the definition that fits it.

    Sources7

    5.Exposing the index to an agent as a retriever tool

    In a fixed RAG chain, retrieval always runs. An agent instead calls retrieval as a tool when it decides it needs to. Databricks recommends AI Bridge for new Python agents: VectorSearchRetrieverTool, from databricks-langchain or databricks-openai, wraps an AI Search index as a tool. The tool's name and description are what the model reads to decide when to search, so the description should say what the corpus covers.

    Wrapping an AI Search index as a retriever tool and giving it to a LangGraph agentpython
    from databricks_langchain import VectorSearchRetrieverTool, ChatDatabricks
    from langgraph.prebuilt import create_react_agent
    
    vs_tool = VectorSearchRetrieverTool(
        index_name="catalog.schema.my_databricks_docs_index",
        tool_name="databricks_docs_retriever",
        tool_description="Search Databricks documentation to answer product questions.",
    )
    print(vs_tool.invoke("What is Databricks Agent Framework?"))
    
    agent = create_react_agent(
        ChatDatabricks(endpoint="databricks-claude-sonnet-4-5"),
        tools=[vs_tool],
    )

    Injection into context happens through the tool result. When the model emits a tool call, the agent loop runs the retriever and appends the returned documents to the message history as a tool message tied to that call's ID. The model then sees the chunks on its next turn. Without a framework, the loop does this explicitly:

    Retrieved documents enter the conversation as a tool messagepython
            args = json.loads(call.function.arguments)
            documents = dbvs_tool.execute(**args, openai_client=client)
            print(documents)
            messages.append({
                "role": "tool",
                "tool_call_id": call.id,
                "content": json.dumps(documents),
            })

    The tool's parameters control how much of each chunk row reaches context and how the search runs:

    VectorSearchRetrieverTool parameters and what each one controls
    ParameterWhat it controls
    index_nameThree-part name catalog.schema.index of the index to query
    num_resultsMaximum number of documents returned into context
    columnsWhich chunk-table columns come back with each result
    filtersConditions applied to the query, such as on metadata columns
    query_type"ANN" or "HYBRID"
    tool_name / tool_descriptionWhat the LLM reads to understand the purpose of the tool
    text_column / embeddingRequired for direct-access indexes or Delta Sync with self-managed embeddings

    A custom retriever, for example one that queries an external index through a Unity Catalog connection, should return a list of MLflow Document objects with page_content and metadata. That shape follows the MLflow retriever span schema, so evaluation and review tools can recognise which chunks were retrieved for each request.

    The retriever always runs as some identity, and that identity's grants decide which chunks it can reach. Querying an index owned by another user requires additional privileges. A tool that reads files directly from a volume needs USE CATALOG, USE SCHEMA and READ VOLUME granted to the agent's identity. The full design of that boundary is covered in UC privileges as the agent's retrieval boundary. For pipeline design, the consequence is concrete: an agent can only retrieve and inject what the identity it runs as is allowed to read.

    Checkpoint 9 of 9· Fill the gap

    In this agent loop, written without a framework, the model has just asked to search the index. Which role must the appended message have so the retrieved chunks reach the model's context as the result of that call?

            args = json.loads(call.function.arguments)
            documents = dbvs_tool.execute(**args, openai_client=client)
            print(documents)
            messages.append({
                "role": " ? ",
                "tool_call_id": call.id,
                "content": json.dumps(documents),
            })

    Sources64

    Sources

    (7)

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

    1. 1.
      “Data pipeline: Pre-process and index documents, tables, or other data for fast and accurate retrieval.”
      ↩︎ Two halves of a RAG system: the data pipeline and the chain
      “The retrieval step can be designed to selectively retrieve personal or proprietary information based on user credentials.”
      ↩︎ Two halves of a RAG system: the data pipeline and the chain
    2. 2.
      “As a best practice, raw source data should be ingested and stored in a target table.”
      ↩︎ The data pipeline: from volume files to a chunk table
      “Storing metadata alongside chunked documents or their corresponding embeddings is essential for optimal performance.”
      ↩︎ The data pipeline: from volume files to a chunk table
      “For example, bge-large-en-v1.5 has a maximum token limit of 512.”
      ↩︎ The data pipeline: from volume files to a chunk table
      “The retrieval query will be transformed at query time using the same embedding model used to embed chunks in the data pipeline.”
      ↩︎ Key concept
      “After chunking your data, the next step is to convert the text chunks into a vector representation using an embedding model.”
      ↩︎ Checkpoint
    3. 3.
      “It accepts either the structured output of ai_parse_document or plain text and markdown STRING content.”
      ↩︎ The data pipeline: from volume files to a chunk table
      “the function splits content into semantic chunks, enriches each chunk with document-level context such as the document title, section headers, page references”
      ↩︎ The data pipeline: from volume files to a chunk table
    4. 4.
      “For standard endpoints, the source table must use a change data feed.”
      ↩︎ Creating the index: Delta Sync, embeddings and the change data feed
      “Tables with row tracking enabled use a change data feed automatically, without requiring manual configuration.”
      ↩︎ Creating the index: Delta Sync, embeddings and the change data feed
      “To create an AI Search index, you must have CREATE TABLE privileges on the catalog schema where the index will be created.”
      ↩︎ Creating the index: Delta Sync, embeddings and the change data feed
      “If you choose to have Databricks compute the embeddings, you can use a pre-configured Foundation Model APIs endpoint”
      ↩︎ Creating the index: Delta Sync, embeddings and the change data feed
      “To query an index that is owned by another user, you must have additional privileges.”
      ↩︎ Exposing the index to an agent as a retriever tool
      “Supported source types include Delta Lake tables, streaming tables, or managed tables using Iceberg v3 or above.”
      ↩︎ Exam trap 1
      “For standard endpoints, the source table must use a change data feed.”
      ↩︎ Exam trap 2
      “Supported source types include Delta Lake tables, streaming tables, or managed tables using Iceberg v3 or above.”
      ↩︎ Prediction
    5. 5.
      “self-managed embeddings (where you pass precomputed vectors directly)”
      ↩︎ Creating the index: Delta Sync, embeddings and the change data feed
      “the column containing precomputed embedding vectors”
      ↩︎ Creating the index: Delta Sync, embeddings and the change data feed
      “Self-managed embeddings (Delta Sync or Direct Vector Access index with precomputed vectors)”
      ↩︎ Exam trap 3
    6. 6.
      “Use the same embedding model that created the index vectors.”
      ↩︎ Creating the index: Delta Sync, embeddings and the change data feed
      “Use VectorSearchRetrieverTool from databricks-langchain or databricks-openai to expose an index as an agent tool.”
      ↩︎ Exposing the index to an agent as a retriever tool
      “Create a retriever tool and give it a description that tells the agent when to search.”
      ↩︎ Exposing the index to an agent as a retriever tool
      “Return a list of Document objects with page_content and metadata”
      ↩︎ Exposing the index to an agent as a retriever tool
      “USE CATALOG, USE SCHEMA, and READ VOLUME”
      ↩︎ Exposing the index to an agent as a retriever tool
      “Use the same embedding model that created the index vectors.”
      ↩︎ Exam trap 4
      “Delta Sync indexes using self-managed embeddings, you must configure the VectorSearchRetrieverTool and specify a custom embedding model and text column”
      ↩︎ Checkpoint
    7. 7.
      “the retrieval query is translated into an embedding using the same embedding model that was used to embed the document chunks during data preparation.”
      ↩︎ The RAG chain at request time
      “determining how many chunks to retrieve in step 2”
      ↩︎ The RAG chain at request time
      “checking user permissions before accessing data sources”
      ↩︎ The RAG chain at request time
      “the retrieval query is translated into an embedding using the same embedding model that was used to embed the document chunks during data preparation”
      ↩︎ Checkpoint

    Ready to test yourself?

    Practise Databricks Certified Context Engineer Associate in quiz mode.

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