The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
To run generative AI on SQL table data in Snowflake, call AI_COMPLETE in a SELECT statement, build its prompt from the row’s columns, and return a stable key with each result. Choose a task-specific Cortex function when you need classification, filtering, or aggregation instead of open-ended text generation. Check access and regional availability before running the query.
Run AI_COMPLETE over table rows
AI_COMPLETE is Snowflake’s general-purpose SQL function for generating text from a prompt, and Snowflake recommends it for most generative AI tasks. A basic pattern is:
SELECT
id,
AI_COMPLETE(
'<supported_model>',
'Summarize this review in one sentence: ' || review_text
) AS summary
FROM reviews;
This is an illustrative template, not tested SQL. Replace the model placeholder with a model supported for your account and region, and verify the current argument form in Snowflake’s AI_COMPLETE reference. Keep a stable key such as id in the output so you can trace each generated result to its source row. The function reference documents scalar AI calls in table queries.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteChoose a function for the job
Not every AI task needs free-form generation. Snowflake provides functions for specific operations; availability and Preview status can vary by function. Check the current Cortex AI Functions overview before designing a deployed workflow.
#1 Best Overall
| Task | Function or approach | What it does |
|---|---|---|
| Generate or transform text from row fields | AI_COMPLETE |
Generates text from a prompt assembled from input data. |
| Assign user-defined labels | AI_CLASSIFY |
Classifies input into categories you specify. Snowflake cautions that more than 20 categories might reduce accuracy in practice. |
| Filter by a natural-language condition | AI_FILTER |
Returns a Boolean that can be used in SQL filtering expressions. |
| Find insights across multiple text rows | AI_AGG |
Produces insights across rows using a prompt you define. |
| Process documents in stages | AI_PARSE_DOCUMENT, AI_EXTRACT, and related functions |
Supports workflows that combine document parsing, extraction, classification, Cortex Search, and AI_COMPLETE. |
For classification, use clear category names and descriptions suited to the task. Snowflake notes that descriptions and examples can help, but they also add input tokens. See the AI_CLASSIFY reference for its guidance.
For document-oriented workflows, Snowflake describes combining parsing and extraction with classification and retrieval in its Cortex AI Functions: Documents guide.
Check access and regional availability
Cortex AI Functions are available only in select regions, and some functions are Preview Features. The overview lists the account-level USE AI FUNCTIONS privilege and either the CORTEX_USER or AI_FUNCTIONS_USER database role. The individual AI_COMPLETE reference specifies SNOWFLAKE.CORTEX_USER. Because requirements are documented at different scopes, confirm the current requirements for the function you plan to use and the configuration of your account before running it.
Handle row-level failures
By default, AI_COMPLETE returns NULL for an input it cannot process. An error on one row does not prevent the rest of a multirow query from completing. If you need diagnostics, use the optional return_error_details argument; the result includes value and error fields. Keep the row key in your results so failed inputs can be identified and reviewed. See Snowflake’s AI_COMPLETE reference for the argument details.
Rank #3
Plan for batch workloads and interactive use
Snowflake says AI Functions are optimized for throughput and that “Batch processing is typically better suited for AI Functions.” For numerous table rows, treat the function call as a batch workload rather than assuming it will behave like a low-latency interactive request. Snowflake points to REST APIs when interactive latency is the priority. The Cortex AI Functions overview provides the workload guidance.
There is no general runtime, output-quality result, or task-specific price established for an arbitrary table query. Assess those characteristics against your own data and workload rather than inferring them from the SQL pattern.
Rank #4
Package a reusable call with CREATE AI FUNCTION
If several queries need the same scalar AI logic, CREATE AI FUNCTION can package it as a named SQL function that is then called per row. The command is marked Preview Feature in Snowflake’s documentation, so check its current status before relying on it in a deployed workflow. Snowflake also states that each invocation meters the underlying Cortex AI inference separately from query compute. See the CREATE AI FUNCTION reference for the definition and metering details.
For a one-off query, a direct AI_COMPLETE expression is simpler. A reusable function can centralize shared logic, but it brings a Preview-status consideration and does not combine inference metering with query compute.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

