Every RAG tutorial starts the same way. Load some PDFs, split them, embed them, put them in a vector store.
So RAG starts to feel like a synonym for “vector database”.
It isn’t. Retrieval-Augmented Generation is generation with data retrieval. Nothing in that name says where the data comes from. A vector store is one source. A SQL database is another. So is an API, a search engine, or a folder of markdown files.
And for a data engineer, that’s the exciting part. The data I already deliver can feed these systems.
I just finished Pluralsight’s LangChain: Working with Data, the follow-up to the course behind my previous LangChain post. Here’s what’s worth knowing, and where I’d push back.
The Familiar Part
The course opens with the ingestion pipeline:
- Load the documents
- Split them into chunks
- Embed each chunk into a vector
- Store the vectors in a vector store
For a data engineer this is home turf. Extract, transform, load. Batch loading, lazy loading for big collections, chunk size and overlap as tuning knobs. It’s ETL with a vector store as the target.
The one abstraction I liked is LangChain’s Document: page content plus metadata, whatever the source. A PDF, a web page and a CSV row all become the same object.
But I’m not convinced it’s as source-agnostic as it looks. The content is uniform. The metadata isn’t. A PDF gives you page numbers, a web page a URL, a database row whatever columns you mapped. Anything downstream that filters on metadata still has to know where the document came from.
Then a Question Comes In
The indexing happens once. Everything else happens per question:
- Embed the question, with the same embedding model as the chunks
- Search the vector store for the closest chunks
- Give those chunks plus the question to the LLM
- Generate the answer
The first step is the one most diagrams skip. The search compares vectors with vectors, so the question has to become a vector too, in the same space. Use a different embedding model for the question and the search returns nonsense.
Retrieval Is Where the Engineering Is
The basic flow is the demo. The course gets interesting once it starts fixing its weaknesses, and LangChain makes that composable: strategy retrievers wrap the base retriever, and each one fixes one problem.
- Multi-query lets an LLM rewrite the question into several versions. A chunk that’s worded differently from the question still gets found. Better recall, at the cost of an extra LLM call.
- Contextual compression runs an LLM over every retrieved chunk and keeps only the relevant part. Better precision and a smaller final prompt. But it adds one LLM call per chunk, so it only pays off when chunks are long and mostly noise.
- MMR (maximal marginal relevance) fetches more candidates than you need and picks the final set one at a time: relevant to the question, but different from what’s already picked. Three near-duplicate chunks become three chunks that each add something.
- Metadata filtering and hybrid search cover what embeddings are bad at: exact terms like error codes, and hard constraints like “only the current policy”. BM25 keyword search alongside vector search handles the first, metadata filters the second.
Every one of these trades speed and cost for quality. The system always balances the three.
Measure Before You Tune
The most useful part of the course was how to evaluate a retriever. You need a set of questions where you know which documents are relevant. Then you can measure three things:
- Recall: did we find the relevant documents?
- Precision: is what we found actually relevant?
- Ranking: is the best document at the top? Mean Reciprocal Rank scores that: full points if the right document is first, half if it’s second, a third if it’s third.
And then the diagnosis is almost mechanical:
| Symptom | Fix |
|---|---|
| Low recall | Increase k, or use multi-query |
| Low precision | Contextual compression, or a similarity threshold |
| Poor ranking | MMR, a reranker, hybrid search, or better chunks and embeddings |
That table is what turns RAG from “it seems to work” into engineering.
Then the Course Adds SQL
The last module is about structured data. The idea: the LLM turns a question into SQL, the database runs it, and the LLM turns the result back into an answer.
The course builds it twice:
- As an explicit LCEL chain. A prompt with the database schema generates the SQL, a tool executes it, and a second prompt answers the question using the query and its result. Every step is visible.
- As an agent.
create_agentgets an LLM, a system prompt and the tools fromSQLDatabaseToolkit: list tables, inspect the schema, check a query, run it. The agent decides the order itself.
The chain is controlled. The agent is flexible. That’s the trade-off with every agent, and here it’s very concrete: the chain always does the same four steps, while the agent might look at three tables first, or at none.
The common problems will sound familiar to anyone who has ever written documentation for a data warehouse:
- Unclear questions. “Which product is best?” Best by revenue, margin or rating?
- Schemas that don’t explain themselves. Column names that mean nothing to an outsider, and documentation that doesn’t exist.
- Schemas that are too big. You can’t put 400 tables in a prompt. Only the relevant ones, with descriptions.
The model needs the same thing a new analyst needs: good names, good descriptions, and only the tables that matter.
Two Places Where I’d Do It Differently
Asking the LLM to check its own SQL. The course validates a generated query by asking an LLM whether it’s correct. I’m not convinced. If the model wrote the wrong query, why would it spot the mistake on the second look? And the checker can just as well reject a query that was fine. Checking the result is more useful: is it empty, full of NULLs, or suspiciously large?
Safety through a wrapper. The course makes the agent safe by replacing the execute tool with a safe_execute that checks the SQL before running it. Fine as a demo. But the real wall is much simpler: give the agent’s database user SELECT rights only. Then it doesn’t matter what SQL the model writes.
Same lesson as in my MCP server: the prompt describes the rules, the permissions enforce them.
Real Questions Are Hybrid
The course ends with a hybrid system. A router prompt classifies each question as structured, unstructured or hybrid, and is only allowed to answer with one word. A RunnableBranch, LangChain’s if/elif/else, then runs the matching path. For hybrid questions it runs both: the SQL result and the retrieved documents go into one final prompt.
The example is “what’s our top-selling product, and what do customers say about it?” Sales figures from the database, reviews from the vector store.
That’s where it clicks why the vector-store framing is too narrow. Real questions don’t respect your storage layer. “Why did sales drop in Q2?” needs the numbers and the context around them.
And structured versus unstructured is still a simplification. In practice there are APIs, search indexes, graph databases and data products, each with its own way to query it. The router pattern scales to all of them: classify the question, fetch from the right sources, answer with what came back.
Why This Excites Me as a Data Engineer
Most of my work is making data available to other people. Pipelines, models, documentation, access.
Until now, the people who got the most out of that were the ones who could write SQL. With retrieval in front of an LLM, that changes. Someone who has never seen the schema can ask a question in plain language and get an answer based on the real data.
But only if the data underneath is good. Clear names, good descriptions, sensible access rights, data that’s actually up to date. Exactly the things data engineers already care about.
RAG doesn’t replace the data platform. It’s a new consumer of it.
What I’m Taking With Me
RAG is retrieval plus generation, not a vector database. The vector store is one source. Your warehouse, your APIs and your documents are the others, and real questions need more than one.
Measure, then tune. Recall, precision and ranking each have their own fix. Without a test set, you’re just changing settings and hoping.
The model is only as good as what you retrieve.
And retrieving data well is the job I already do.
Evert