Sentiment per row via a registered chat model: positive, negative, neutral, or mixed.
AI_ANALYZE_SENTIMENT(model_name, text)
AI_ANALYZE_SENTIMENT(text USE MODEL model_name)
## Overview Task sugar over AI_GENERATE: the instruction demands exactly one word from {positive, negative, neutral, mixed}, composed after the model's SYSTEM_PROMPT. Shares AI_GENERATE's batching, dedup, response memo, and error semantics. The USE MODEL sugar form is accepted and rewritten to the leading-model-argument form.
| Name | Type | Description |
|---|---|---|
model_name | The registry name of a MODEL_TYPE = CHAT model. Must be constant within a query. | |
text | The text to analyze. NULL produces NULL without calling the provider. |
SELECT review_id, AI_ANALYZE_SENTIMENT('gpt5', review_text) AS sentiment
FROM shop.silver.reviews;
-- Sentiment distribution
SELECT AI_ANALYZE_SENTIMENT('gpt5', review_text) AS sentiment, COUNT(*)
FROM shop.silver.reviews GROUP BY 1;