← Blog

RAG retrieval belongs in SQL next to the joins, not only in app code

Snowflake put Retrieve Cortex Search into Public Preview — CORTEX_SEARCH_RETRIEVE runs low-latency Cortex Search from SQL (including LATERAL per-row queries) so RAG, chatbots, and in-app search can combine hits with joins and aggregations.

Generative AIData EngineeringLakehouse

Retrieval-augmented generation often strands vector search in a sidecar service while the warehouse does the joins. That split makes latency, lineage, and access control three different problems — and agents that need both unstructured hits and structured facts feel the glue.

Snowflake made Retrieve Cortex Search available in Public Preview on October 23, 2026. The `CORTEX_SEARCH_RETRIEVE` table function runs low-latency Cortex Search queries directly from SQL — one query at a time, or one query per input row with a `LATERAL` join. Intended for real-time workloads such as RAG, chatbots, and in-app search. Queries reuse the search service’s existing serving resources, and as a table function the results compose with joins, aggregations, and the rest of SQL under the same privilege model as other Snowflake data access.

What data and GenAI platform owners should change for production RAG:

  • Prefer SQL-callable retrieval next to governed tables over a separate search microservice that re-implements auth and joins in the app
  • Use LATERAL patterns when each row (ticket, account, document id) needs its own retrieval set before scoring or generation
  • Keep RAG pipelines auditable as ordinary SQL: same roles, same warehouses, same query history as the analytics estate

Agents that ground answers in enterprise knowledge need retrieval as a first-class query operator. If search only lives outside SQL, the lakehouse is half the story.