AI (generative)

AI (generative)#

Querona ships seven generative AI scalar functions with the same names and signatures as the Microsoft Fabric AI_* family, so T-SQL written for Fabric ports directly. Unlike Fabric, which runs them only in its own warehouse against its product-managed model, Querona executes them in its own engine against an AI model you register — Anthropic, OpenAI or Azure OpenAI — over data from any connected source.

Getting started#

  1. Register a model with qua_add_external_ai_model. Registered models are listed by the sys.external_models view.

  2. Bind the session’s ambient model — needed only when more than one model is registered; a single registered model is used automatically:

    EXEC sys.sp_set_session_context N'ai_default_model', N'MyClaude';
    
  3. Query — the functions work over columns from any connected source:

    SELECT AI_SUMMARIZE(review_text) AS summary
    FROM   hotel_reviews;
    

Failure semantics#

A row whose call fails — a provider error, a content restriction, or input over the size cap of about 15 KB — yields NULL for that row; a failure never aborts the query. Use ISNULL to fall back to the original value. Statement-level misconfiguration is the exception: an unknown model name, or a model whose credential the provider rejects, raises an error instead of silently returning NULL for every row. The functions are non-deterministic and are re-evaluated on every execution, so materialize results you want to keep rather than recomputing them:

UPDATE hotel_reviews SET review_text = ISNULL(AI_FIX_GRAMMAR(review_text), review_text);

Functions#

Function

Description

AI_ANALYZE_SENTIMENT

Returns the sentiment of the text: positive, negative, mixed or neutral.

AI_CLASSIFY

Classifies the text into exactly one of the supplied labels.

AI_EXTRACT

Extracts the named entities from the text as a flat JSON object.

AI_FIX_GRAMMAR

Corrects the spelling, grammar and punctuation of the text.

AI_GENERATE_RESPONSE

Generates text from a prompt, optionally applied to per-row data.

AI_SUMMARIZE

Summarizes the text.

AI_TRANSLATE

Translates the text into a target language.