Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

Snowflake Cortex AI on SQL Tables: Run Generative AI Row by Row

Use Snowflake Cortex AI functions in SQL to generate or process results from table rows. Learn the function choices, query pattern, access checks, and error handling.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run generative AI on Snowflake table data by calling Cortex AI functions in a SQL query. For general-purpose text generation, Snowflake recommends AI_COMPLETE: build a prompt from each row’s columns, select the result with a stable key, and review any rows that fail. The example below is a template, not tested SQL; confirm the model and syntax supported for your account and region.

Choose the Cortex function for the job

Use a task-specific function where it fits rather than treating every AI operation as free-form generation. Snowflake’s Cortex AI Functions guide lists functions for generation, classification, filtering, aggregation, extraction, translation, embeddings, summarization, and document processing; availability and Preview status vary by function.

As an Amazon Associate I earn from qualifying purchases.

Task Function direction What it does
Generate or transform text from row fields AI_COMPLETE Creates a response from a prompt; Snowflake recommends it for most generative AI tasks. Snowflake
Assign one or more labels you define AI_CLASSIFY Classifies input against user-specified categories. More than 20 categories may reduce accuracy in practice. Snowflake
Keep rows that meet a natural-language condition AI_FILTER Returns a Boolean that can be used in SQL filtering expressions. Snowflake
Find insights across multiple text rows AI_AGG Produces insights across multiple rows in response to a user-defined prompt. Snowflake
Process document content in stages AI_PARSE_DOCUMENT, AI_EXTRACT, and related functions Document parsing and extraction can be combined with classification, Cortex Search, and AI_COMPLETE in document analytics and retrieval-augmented generation workflows. Snowflake

Run a generation query over table rows

A scalar AI call in a SELECT can use column values to build a prompt for each row. Keep a stable identifier in the result so you can match generated text back to its input.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
SELECT
  id,
  AI_COMPLETE(
    '<supported_model>',
    'Summarize this review in one sentence: ' || review_text
  ) AS summary
FROM reviews;

This illustrates the pattern, not a guaranteed drop-in query. Check the current AI_COMPLETE reference for supported models and argument forms available to your account.

Check access and regional availability

Before running a query, confirm access for the function you chose. Snowflake’s Cortex overview describes the account-level USE AI FUNCTIONS privilege and either the CORTEX_USER or AI_FUNCTIONS_USER database role. The individual AI_COMPLETE reference specifically lists SNOWFLAKE.CORTEX_USER. Consult the applicable function reference and your account configuration rather than assuming one role requirement covers every function. Cortex AI Functions are available only in select regions, and some functions are Preview Features. Snowflake’s overview describes these access and availability conditions.

Handle failed rows explicitly

By default, AI_COMPLETE returns NULL for an input it cannot process. In a multirow query, an error on one row does not necessarily prevent other rows from completing. If you need diagnostics, use the optional return_error_details argument: the result includes value and error fields. Retain the row key and inspect failures instead of treating every returned row as a successful generation. Snowflake documents the error behavior and argument.

Plan the workload and cost

For numerous inputs, Snowflake says batch processing is typically better suited to AI Functions; its guide points to REST APIs when interactive latency is the priority. That is workload guidance, not a runtime or quality guarantee for a particular table. Benchmark the query with your data and prompt before setting expectations. Snowflake’s guide

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There is no task-specific cost figure established here. For reusable CREATE AI FUNCTION calls, Snowflake says Cortex inference is metered separately from query compute. The command is labeled a Preview Feature in the CREATE AI FUNCTION reference, so assess preview status and deployment readiness alongside governance, error handling, and expected inference use.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Package repeated logic as a SQL function

If the same scalar AI expression should be shared across queries, CREATE AI FUNCTION packages it under a named SQL function that can be invoked per row. The command reference includes a row-invocation example, but labels the feature Preview; check its current status and suitability for your account before relying on it in production. Its inference metering is separate from query compute, as described in the command reference.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.