Snowflake AI Data Cloud Features & Architecture · Topic 17 of 17

Snowflake Cortex - AI SQL Functions, Cortex Search and Cortex Analyst

Snowflake Cortex for the SnowPro Core exam: AI SQL functions such as AI_COMPLETE, Cortex Search for RAG, Cortex Analyst for text to SQL, and access rules.

  • 6 min
In a nutshell
  • Cortex runs LLMs inside Snowflake; no model hosting or data export.
  • AI SQL functions such as AI_COMPLETE, AI_CLASSIFY, AI_FILTER, AI_SENTIMENT and AI_EXTRACT apply AI per row in SQL and are billed by tokens.
  • Cortex Search is hybrid vector and keyword search with reranking, used for RAG, with a TARGET_LAG and a refresh warehouse.

What it is

Snowflake Cortex is Snowflake's set of managed AI features. Large language models (LLMs) and search run inside the Snowflake service perimeter, so your data is not sent to an outside service you manage, and you do not host or tune models yourself.

The exam focuses on three parts and on picking the right one for a scenario:

PartInputWhat it does
AI SQL functionsText, images, documents, audio in tables or stagesCall an LLM from SQL: generate, classify, filter, extract, summarize, translate, embed
Cortex SearchUnstructured textHybrid search over your text, mainly for RAG and search bars
Cortex AnalystStructured tables plus a semantic modelAnswers natural language questions by generating SQL
Unstructured textdocumentsindexed byCortex Searchhybrid retrievalcontext forAI_COMPLETELLM answerBusiness questionplain Englishsent toCortex Analystsemantic viewgeneratesSQLruns on warehouse

How it works

AI SQL functions

The Cortex AI functions are called in ordinary SQL, so analysts can apply AI to every row of a table in one query. The current functions use an AI_ prefix:

FunctionUse
AI_COMPLETEGenerate a response from a prompt with a chosen LLM; the general-purpose function
AI_CLASSIFYSort text or images into categories you define
AI_FILTERReturn TRUE or FALSE for a condition, usable in WHERE or JOIN
AI_AGG and AI_SUMMARIZE_AGGDerive insights or a summary across many rows of text
AI_SENTIMENTScore the sentiment of text
AI_EXTRACTPull specific information from text, images or documents
AI_TRANSLATETranslate text between supported languages
AI_EMBED and AI_SIMILARITYCreate embedding vectors and compare inputs
AI_PARSE_DOCUMENTExtract text, or text with layout, from staged documents
AI_TRANSCRIBETranscribe audio files in a stage
AI_REDACTRemove personally identifiable information from text

Older functions in the SNOWFLAKE.CORTEX schema, such as COMPLETE, SUMMARIZE, TRANSLATE and SENTIMENT, still work and you may still see them. They do the same kinds of jobs; Snowflake now points users to the AI_ functions.

SELECT ticket_id,
       AI_SENTIMENT(body) AS sentiment,
       AI_CLASSIFY(body, ['billing', 'outage', 'feature request']) AS category
FROM support_tickets;

AI functions are billed in credits based on the number of tokens processed. The SQL query itself still needs a running warehouse.

Access. A role needs the SNOWFLAKE.CORTEX_USER database role (or the narrower AI_FUNCTIONS_USER) together with the USE AI FUNCTIONS account privilege. Both CORTEX_USER and the USE AI FUNCTIONS privilege are granted to the PUBLIC role by default, so every user can reach Cortex unless an administrator (ACCOUNTADMIN) revokes them from PUBLIC and grants them only to chosen roles. Administrators can also limit which LLMs are allowed.

Watch out

A model allowlist does not restrict ACCOUNTADMIN, which always has access to all models. Restrict who holds that role as well.

Cortex Search

Cortex Search is a low-latency hybrid search service over text in Snowflake. Each query combines vector search (meaning), keyword search (exact terms) and semantic reranking of the top results. Its two main uses are retrieval-augmented generation (RAG), where it finds the right passages to give an LLM, and search boxes in apps.

You create it with CREATE CORTEX SEARCH SERVICE:

  • ON names the text column to search.
  • ATTRIBUTES lists columns that can be used as filters.
  • WAREHOUSE names the warehouse that builds and refreshes the index.
  • TARGET_LAG sets how far the service may trail changes to the source data; refreshes work like dynamic tables.
  • EMBEDDING_MODEL optionally chooses the embedding model.
  • AS gives the source query.

Applications query the service through the Python API or REST API, and SEARCH_PREVIEW tests it from SQL. Users need USAGE on the service. Costs include warehouse refreshes, embedding tokens, serving the index and storage.

Source tablechunked textCREATE CORTEX SEARCH SERVICESearch indexvectors + keywordsquery via APITop passagesrerankedpassed toLLMgrounded answer

Cortex Analyst

Cortex Analyst lets business users ask questions about structured data in plain language. It uses an LLM to turn the question into SQL, which runs on your warehouse to produce the answer.

Accuracy comes from a semantic model that describes the business meaning of tables: logical tables, dimensions, facts, metrics and relationships. Semantic views, schema-level objects governed by RBAC, are the recommended way to define it. Older semantic model YAML files on a stage still work.

  • It is offered as a REST API, so it can be built into Streamlit apps, Slack, Teams or other tools.
  • Responses include text and the generated SQL.
  • It is billed per successful message, and the warehouse that runs the SQL is billed separately.
  • Roles need SNOWFLAKE.CORTEX_USER or SNOWFLAKE.CORTEX_ANALYST_USER, plus SELECT on the tables used.

Snowflake now recommends Cortex Agents for new builds. Agents can use Cortex Analyst for structured data and Cortex Search for unstructured data in one conversation.

How the exam asks about this

  • "Classify 2 million product reviews by sentiment with a single SQL statement" -> AI SQL functions such as AI_SENTIMENT or AI_CLASSIFY.
  • "A chatbot must answer questions from internal policy PDFs" -> Cortex Search to retrieve passages, plus AI_COMPLETE to generate the answer (RAG).
  • "Executives want to ask revenue questions in plain English over sales tables" -> Cortex Analyst with a semantic view.

Common mistakes

Using Cortex Analyst for documents. Cortex Analyst generates SQL over structured data. Searching text such as PDFs or tickets is a job for Cortex Search.

Thinking you must deploy a model. Cortex AI functions are managed. You call them from SQL; there is no endpoint or GPU to provision.

Assuming Cortex is off by default. CORTEX_USER and USE AI FUNCTIONS are granted to PUBLIC by default. Administrators who want control must revoke them.

Skipping the semantic model. Cortex Analyst relies on a semantic view or YAML model to map business terms to columns; without it, it cannot answer reliably.

What to remember for the exam

  • Cortex runs LLMs inside Snowflake; no model hosting or data export.
  • AI SQL functions such as AI_COMPLETE, AI_CLASSIFY, AI_FILTER, AI_SENTIMENT and AI_EXTRACT apply AI per row in SQL and are billed by tokens.
  • Cortex Search is hybrid vector and keyword search with reranking, used for RAG, with a TARGET_LAG and a refresh warehouse.
  • Cortex Analyst turns natural language into SQL over structured data using a semantic view or YAML model, through a REST API.
  • SNOWFLAKE.CORTEX_USER is granted to PUBLIC by default.

Check yourself

  • Which Cortex feature answers questions over unstructured documents in a RAG app?

    Cortex Search retrieves the relevant passages, and an LLM function such as AI_COMPLETE writes the answer from them.

  • What does Cortex Analyst need to translate business questions into accurate SQL?

    A semantic model, preferably a semantic view, describing tables, dimensions, facts, metrics and relationships.

  • How are Cortex AI SQL functions billed?

    In credits based on the tokens processed, while the query itself also runs on a warehouse.

Topic 17 of 17 in Snowflake AI Data Cloud Features & Architecture

Test yourself on Snowflake AI Data Cloud Features & Architecture

The full Snowflake SnowPro Core COF-C03 question bank has 845 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.