Snowflake Gen AI Functions · Topic 14 of 26

Data Analysis Use Cases with Fully Managed LLMs, RAG and Text-to-SQL

Match a data analysis use case to the right Snowflake managed service: AI functions, Cortex Search for RAG, or Cortex Analyst for text-to-SQL.

  • 4 min
In a nutshell
  • Structured data and plain English questions: Cortex Analyst, which generates SQL from a semantic view.
  • Documents and unstructured text: Cortex Search for retrieval, then an LLM such as AI_COMPLETE for the answer (RAG).
  • Per row classification, extraction, summary and sentiment: the AI functions in a SQL query.

What it is

Most exam scenarios in this area start with a business question and ask which Snowflake service fits. Snowflake offers three fully managed building blocks, and each one fits a different kind of question.

  • Managed LLMs run inside Snowflake through the Cortex AI functions such as AI_COMPLETE, AI_CLASSIFY and AI_SUMMARIZE. You call them from SQL on rows of data.
  • RAG (retrieval augmented generation) finds the relevant text first, then gives it to an LLM. In Snowflake the retrieval half is Cortex Search.
  • Text-to-SQL turns a business question into a SQL query over structured tables. In Snowflake that is Cortex Analyst.

Because the models run inside the Snowflake service boundary, the data does not leave Snowflake to be analyzed.

Business questionstructured dataCortex Analysttext to SQLrunsSQL on tablesBusiness questiondocuments or textCortex SearchretrievalcontextAI_COMPLETEanswerBusiness questionper row workAI functionsclassify, extract, summarize

How it works

Pick the service from the data and the question

Use caseDataService
"What were sales by region last quarter?"Structured tablesCortex Analyst (semantic view)
"What does our policy say about refunds?"Documents, tickets, wiki textCortex Search plus AI_COMPLETE (RAG)
Label 2 million reviews as positive or negativeRows of textAI_CLASSIFY or AI_SENTIMENT in SQL
Pull invoice number and total from PDFsFiles on a stageAI_EXTRACT or AI_PARSE_DOCUMENT
Keep a conversation that mixes tables and documentsBothCortex Agents or Snowflake Intelligence

The deciding question is whether the answer is computed or found. A number that must be calculated from rows comes from SQL, so use Cortex Analyst. A passage that already exists in a document is found, so use Cortex Search.

Why not just ask an LLM

An LLM with no retrieval step answers from its training data. It does not know your tables and can invent a plausible answer. RAG fixes this by retrieving real text and placing it in the prompt. Text-to-SQL fixes it by running a real query, so numbers come from the data and not from the model.

Fully managed means little to operate

  • No model hosting, GPU sizing or container build for Snowflake hosted models.
  • Cortex Search builds and refreshes its own index from a table or view, using a warehouse and a target lag.
  • Cortex Analyst generates SQL that runs in your own warehouse, so existing role based access control and masking still apply.
  • If you need a model Snowflake does not host, that is the Snowpark Container Services path covered later in this chapter.

A small RAG pattern in SQL

SELECT AI_COMPLETE(
  'claude-sonnet-4-5',
  'Answer using only this context: ' || context || ' Question: ' || question
) AS answer
FROM (SELECT 'Refunds are issued within 14 days.' AS context,
             'How long do refunds take?' AS question);

The retrieved text goes in the prompt, and the instruction to use only that context lowers the chance of a made up answer. In production the context comes from a Cortex Search query, not from a literal.

Exam tip

When a scenario says "business users ask questions in plain English about sales numbers," think Cortex Analyst. When it says "answer from our PDFs and manuals," think Cortex Search and RAG.

Common mistakes

Using Cortex Search for numeric questions. Search returns text chunks. It does not sum or group rows.

Using Cortex Analyst for documents. Analyst reads a semantic view over tables. It does not read PDFs.

Skipping the retrieval step and relying on the model alone. This is the classic cause of hallucination in the scenarios.

Calling a row level AI function when a service is meant. AI_COMPLETE over a table is fine for batch labeling, but it is not a chat interface over your data.

Watch out

Do not assume one service does everything. A question that needs both a number and a policy quote needs both retrieval paths, which is what Cortex Agents orchestrates.

What to remember for the exam

  • Structured data and plain English questions: Cortex Analyst, which generates SQL from a semantic view.
  • Documents and unstructured text: Cortex Search for retrieval, then an LLM such as AI_COMPLETE for the answer (RAG).
  • Per row classification, extraction, summary and sentiment: the AI functions in a SQL query.
  • Models run inside Snowflake, so data is not sent to an outside provider for these services.
  • Cortex Analyst SQL runs in your warehouse under your role, so access controls still apply.

Check yourself

  • Which service turns a plain English sales question into SQL?

    Cortex Analyst, using a semantic view.

  • What is the retrieval half of RAG in Snowflake?

    Cortex Search, which finds relevant chunks to place in the LLM prompt.

  • Why does RAG reduce hallucination?

    The model answers from retrieved real text instead of only its training data.

Topic 14 of 26 in Snowflake Gen AI Functions

Test yourself on Snowflake Gen AI Functions

The full Snowflake GES-C02 question bank has 585 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.