AI_ANALYZE_SENTIMENT

Sentiment per row via a registered chat model: positive, negative, neutral, or mixed.

Category: aiReturns: STRINGDialect: DeltaForgeDeltaForge extension

Syntax

AI_ANALYZE_SENTIMENT(model_name, text)
AI_ANALYZE_SENTIMENT(text USE MODEL model_name)

Description

## 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.

Parameters

NameTypeDescription
model_nameThe registry name of a MODEL_TYPE = CHAT model. Must be constant within a query.
textThe text to analyze. NULL produces NULL without calling the provider.

Examples

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;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →