RAG, where a model answers from documents it first searches, usually meant an application you built and ran on Databricks: Python code that searched a vector index, a prompt, a model, and a serving endpoint to deploy. Now one SQL function, ai_search, does the search and writes the answer inside a single query. It's in Beta, and its own docs say its citations are "the model's best-effort picks of supporting chunks, not proof of any specific claim."
We think the instructions are the part a team has to get right, so at TechFabric we wanted to see what that means for a real assistant. We put ai_search over a fictitious IT service desk with four sources and one outdated article, ran 150 calls and graded every answer by hand. On the 40 answers to questions our data could answer, one instruction took the confidently wrong answers from 6 to 0.

RAG in one SQL call
ai_search runs the search and the answer inside one SELECT on a SQL warehouse. It writes its own search queries, searches the sources, drops duplicates, reranks the chunks and writes the answer with citations. Nothing to deploy, and you can run it over a whole column of tickets in one query.

The function in 30 seconds

ai_search takes the question, up to 10 sources, free-text instructions of up to 4,000 characters, and options that switch the answer and the citations on or off. Citations are off by default. It returns the retrieved chunks, the answer and the citations.
You can't pick the model or the number of chunks, and the docs don't say which model runs inside. The one lever you get is the instructions, which the docs say guide query generation, metadata filters and reranking. The function is in Beta.
Why does the old article win?
Take an employee who asks the IT assistant:
Where in the VPN client do I change my password?
The assistant answers with confidence and links a real help article, one that stopped being true when the company moved to single sign-on.

Our fictitious desk has four sources, each an AI Search index. It holds 8 helpdesk articles, 6 past tickets, 5 security policies and 5 user profiles, 24 chunks in all. The helpdesk keeps two versions of the VPN password article, the current one and the old one from before single sign-on, marked as superseded. We wrote 25 questions with known right answers, including traps like this one.

The old article ranked first, and the model answered from it with the old steps in the client. In both runs the citation pointed at the article the answer came from, and the answer was still wrong.
One instruction, two steps
We didn't want a rule per question, so we wrote rules for the whole service desk. The first version had three rules. Use the current version of a document, let security policy outrank articles and tickets, and check the person's profile when the answer depends on who asks.
Then we added a short map of what each source holds, and told the function to pick the source that holds the answer. That second step mattered more than we expected.
Here is the whole instruction, 453 characters:
You answer IT support questions for employees. Sources: helpdesk = how-to articles and password rules; policies = security rules; users = employee and contractor profiles; tickets = past cases. Pick the source that holds the answer; use more than one when needed. Use the current version of any document; skip superseded ones. If sources disagree, security policy outranks articles and tickets. If the answer depends on the person, check their profile.

The ranking did not change: the old article still came back first. The instruction changed which chunk the answer trusted, and the citation moved to the current article.
What 150 calls showed

We asked all 25 questions twice for each variant and graded the 40 answers each variant gave to questions the data could answer.
| Variant | Right | Partly right | Confident and wrong | No answer |
|---|---|---|---|---|
| No instructions | 26 | 1 | 6 | 7 |
| Three domain rules | 26 | 1 | 3 | 10 |
| Rules plus a map of the sources | 31 | 0 | 0 | 9 |
The domain rules alone took the wrong answers from 6 to 3, but right answers stayed at 26 and no-answer rose from 7 to 10. Adding the map of the sources brought right answers up to 31, and no-answer cases fell from 10 to 9. For the 5 questions our data can't answer, every variant returned no answer rather than a made-up one.

One limit held in all 150 calls. Each answer drew its chunks from a single source. The docs describe retrieval across sources but don't say how it picks one. Take this question:
I'm Alex Moreno. How do I reset my VPN password?
The right answer needs his contractor profile and the contractor article together, and ai_search got one or the other. With the instruction, it answered nothing instead of answering wrong.
Our corpus is small and fictitious, so these numbers show behaviour, not a benchmark.
How we would build it
With the fix in place, the employee question goes to ai_search, the instruction with a source map steers it to the current article, and the answer comes back with the right citation.
We'd take superseded documents out of the index, because the instruction makes the model skip the old article but never removes it from the results. We'd describe each source in the instructions too.
For answers that depend on the person, we'd fetch the profile with a plain SQL join on the user's ID and put it into the question, instead of hoping the search finds it. And before launch we'd keep 20 to 30 questions with known answers and rerun them after every change to the instructions; each one is a single SQL query.
If you're starting tomorrow, take ten questions where you have an old and a new version of the same document and run them with and without an instruction. Then check which article each answer cites.
FAQ
Does ai_search search every source you pass?
In our 150 calls each answer drew on one source. The docs describe retrieval across sources but don't explain how a source is chosen, so test it on your own data before you count on answers that combine sources.
Can I choose the model ai_search uses?
No, and the docs don't say which model runs inside it. The docs suggest turning off generate_answer and passing the retrieved chunks to ai_query with the model you want.
Do instructions remove outdated documents from the results?
No. In our runs the superseded article stayed first in the list; the instruction changed which chunk the answer used. To remove it, take it out of the index.
Is ai_search ready for production?
It's in Beta. We'd use it for internal tools with a fixed set of test questions rerun after every change, and we wouldn't show its answers to customers as final yet.