AI_SENTIMENT

Applies to: ✅ Data 360 SQL ❌ Tableau Hyper API

Performs sentiment analysis on text input and returns a sentiment label. This function uses a multilingual sentiment model to analyze customer feedback, support tickets, survey responses, and other unstructured text.

Syntax 

1AI_SENTIMENT(<input_text>)

Arguments 

Required 

  • input_text: The text to analyze for sentiment. The function processes empty input values normally. The text must be a non-NULL value.

Returns 

Returns a text sentiment label. Sentiment labels are:

  • Positive: Text expressing positive sentiment
  • Negative: Text expressing negative sentiment
  • Neutral: Text expressing neutral sentiment
  • Mixed: Text containing conflicting positive and negative signals
  • Unknown: Text with unclear or indeterminate sentiment

Considerations 

  • Input text length: The function supports input text up to 512 tokens (approximately 400-500 words). For longer text such as full call transcripts or lengthy emails, split the content into shorter passages before analyzing.
  • Best for short text: This function works best on short, intent-rich text such as support tickets, CRM notes, social media posts, and chat messages.
  • Performance: Requests to the function time out after 30 seconds.
  • First execution: When executing this function on a large number of rows for the first time, you can encounter timeout or capacity errors. Start with smaller row counts and gradually increase volume to avoid these issues.
  • Non-NULL values: input_text must be a non-NULL value. Add IS NOT NULL to the WHERE clause in your SQL statement to avoid NULL value errors.
  • Multilingual support: The underlying model supports multiple languages.

Examples 

Using Table Data 

Analyzes sentiment for multiple rows from a table.

1SELECT
2  "customerServiceFeedback__c",
3  ai_sentiment("customerServiceFeedback__c") AS sentiment
4FROM "AutomobileServiceFeedback__dll"

Returns the sentiment of the feedback for each row in the AutomobileServiceFeedback__dll.

Filtering Results 

Show only positive feedback in a table.

1WITH AnalyzedFeedback AS (
2  SELECT
3    "customerServiceFeedback__c",
4    ai_sentiment("customerServiceFeedback__c") AS sentiment
5  FROM "AutomobileServiceFeedback__dll"
6)
7SELECT * FROM AnalyzedFeedback
8WHERE sentiment = 'positive';

Returns all positive feedback.

Related Documentation