AI_SENTIMENT
Overview
Extracts sentiment from text, returning a score from -1 (negative) to 1 (positive).
Syntax
AI_SENTIMENT(text)
AI_SENTIMENT(text)
AI_SENTIMENT(text)
Parameters
text (VARCHAR): Text to analyze for sentiment (max 2,048 tokens)
Use Cases
Customer feedback analysis
Social media monitoring
Product review analysis
Brand sentiment tracking
Support ticket prioritization
Code Examples
Example 1: Basic Sentiment Analysis
SELECT 'I love this product!' AS text, AI_SENTIMENT('I love this product!') AS
SELECT 'I love this product!' AS text, AI_SENTIMENT('I love this product!') AS
SELECT 'I love this product!' AS text, AI_SENTIMENT('I love this product!') AS
Output:
text | sentiment_score ------------------------|---------------- I love this product! | 0.89
text | sentiment_score ------------------------|---------------- I love this product! | 0.89
text | sentiment_score ------------------------|---------------- I love this product! | 0.89
Example 2: Analyze Customer Reviews
SELECT review_id, review_text, AI_SENTIMENT(review_text) AS sentiment, CASE WHEN AI_SENTIMENT(review_text) > 0.5 THEN 'Positive' WHEN AI_SENTIMENT(review_text) < -0.5 THEN 'Negative' ELSE 'Neutral' END AS sentiment_category FROM
SELECT review_id, review_text, AI_SENTIMENT(review_text) AS sentiment, CASE WHEN AI_SENTIMENT(review_text) > 0.5 THEN 'Positive' WHEN AI_SENTIMENT(review_text) < -0.5 THEN 'Negative' ELSE 'Neutral' END AS sentiment_category FROM
SELECT review_id, review_text, AI_SENTIMENT(review_text) AS sentiment, CASE WHEN AI_SENTIMENT(review_text) > 0.5 THEN 'Positive' WHEN AI_SENTIMENT(review_text) < -0.5 THEN 'Negative' ELSE 'Neutral' END AS sentiment_category FROM
Example 3: Track Sentiment Over Time
SELECT DATE_TRUNC('week', created_date) AS week, AVG(AI_SENTIMENT(review_text)) AS avg_sentiment, COUNT(*) AS review_count FROM product_reviews WHERE created_date >= CURRENT_DATE - 90 GROUP BY week ORDER BY
SELECT DATE_TRUNC('week', created_date) AS week, AVG(AI_SENTIMENT(review_text)) AS avg_sentiment, COUNT(*) AS review_count FROM product_reviews WHERE created_date >= CURRENT_DATE - 90 GROUP BY week ORDER BY
SELECT DATE_TRUNC('week', created_date) AS week, AVG(AI_SENTIMENT(review_text)) AS avg_sentiment, COUNT(*) AS review_count FROM product_reviews WHERE created_date >= CURRENT_DATE - 90 GROUP BY week ORDER BY
Example 4: Compare Sentiment by Product
SELECT product_id, product_name, AVG(AI_SENTIMENT(review_text)) AS avg_sentiment, COUNT(CASE WHEN AI_SENTIMENT(review_text) > 0.5 THEN 1 END) AS positive_reviews, COUNT(CASE WHEN AI_SENTIMENT(review_text) < -0.5 THEN 1 END) AS negative_reviews FROM reviews GROUP BY product_id, product_name ORDER BY avg_sentiment DESC
SELECT product_id, product_name, AVG(AI_SENTIMENT(review_text)) AS avg_sentiment, COUNT(CASE WHEN AI_SENTIMENT(review_text) > 0.5 THEN 1 END) AS positive_reviews, COUNT(CASE WHEN AI_SENTIMENT(review_text) < -0.5 THEN 1 END) AS negative_reviews FROM reviews GROUP BY product_id, product_name ORDER BY avg_sentiment DESC
SELECT product_id, product_name, AVG(AI_SENTIMENT(review_text)) AS avg_sentiment, COUNT(CASE WHEN AI_SENTIMENT(review_text) > 0.5 THEN 1 END) AS positive_reviews, COUNT(CASE WHEN AI_SENTIMENT(review_text) < -0.5 THEN 1 END) AS negative_reviews FROM reviews GROUP BY product_id, product_name ORDER BY avg_sentiment DESC
Example 5: Filter Negative Feedback
SELECT ticket_id, customer_message, AI_SENTIMENT(customer_message) AS sentiment_score FROM support_tickets WHERE AI_SENTIMENT(customer_message) < -0.3 AND status = 'Open' ORDER BY sentiment_score ASC
SELECT ticket_id, customer_message, AI_SENTIMENT(customer_message) AS sentiment_score FROM support_tickets WHERE AI_SENTIMENT(customer_message) < -0.3 AND status = 'Open' ORDER BY sentiment_score ASC
SELECT ticket_id, customer_message, AI_SENTIMENT(customer_message) AS sentiment_score FROM support_tickets WHERE AI_SENTIMENT(customer_message) < -0.3 AND status = 'Open' ORDER BY sentiment_score ASC
Data Output Examples
Sentiment Scores
Text: "This is the best product I've ever used!" Score: 0.95 (very positive) Text: "The product is okay, nothing special." Score: 0.15 (slightly positive/neutral) Text: "Terrible experience, would not recommend." Score: -0.87 (very negative)
Text: "This is the best product I've ever used!" Score: 0.95 (very positive) Text: "The product is okay, nothing special." Score: 0.15 (slightly positive/neutral) Text: "Terrible experience, would not recommend." Score: -0.87 (very negative)
Text: "This is the best product I've ever used!" Score: 0.95 (very positive) Text: "The product is okay, nothing special." Score: 0.15 (slightly positive/neutral) Text: "Terrible experience, would not recommend." Score: -0.87 (very negative)
Sentiment Distribution
Product: Laptop Model X Positive Reviews (>0.5): 245 (68%) Neutral Reviews (-0.5 to 0.5): 85 (24%) Negative Reviews (<
Product: Laptop Model X Positive Reviews (>0.5): 245 (68%) Neutral Reviews (-0.5 to 0.5): 85 (24%) Negative Reviews (<
Product: Laptop Model X Positive Reviews (>0.5): 245 (68%) Neutral Reviews (-0.5 to 0.5): 85 (24%) Negative Reviews (<
Model Information
Model Used: Snowflake managed model
Context Window: 2,048 tokens
Output Range: -1.0 to 1.0
Supported Languages: Primarily English (check docs for multilingual support)
Limitations & Considerations
Input Size
Maximum 2,048 tokens per text
Longer texts will be truncated
Use AI_COUNT_TOKENS to verify length
Cost
Input tokens are billable
Additional prompt overhead added automatically
Use sparingly on very large datasets
Accuracy
Works best on clear, straightforward sentiment
May struggle with sarcasm or complex emotions
Context matters for accurate scoring
Regional Availability
AWS US West/East: ✓
Azure East US: ✓
EU regions: ✓
Cross-region inference: ✓
Best Practices
1. Categorize Sentiment Scores
-- Create meaningful categories SELECT CASE WHEN AI_SENTIMENT(text) >= 0.6 THEN 'Very Positive' WHEN AI_SENTIMENT(text) >= 0.2 THEN 'Positive' WHEN AI_SENTIMENT(text) >= -0.2 THEN 'Neutral' WHEN AI_SENTIMENT(text) >= -0.6 THEN 'Negative' ELSE 'Very Negative' END AS sentiment_category, COUNT(*) AS count FROM feedback GROUP BY
-- Create meaningful categories SELECT CASE WHEN AI_SENTIMENT(text) >= 0.6 THEN 'Very Positive' WHEN AI_SENTIMENT(text) >= 0.2 THEN 'Positive' WHEN AI_SENTIMENT(text) >= -0.2 THEN 'Neutral' WHEN AI_SENTIMENT(text) >= -0.6 THEN 'Negative' ELSE 'Very Negative' END AS sentiment_category, COUNT(*) AS count FROM feedback GROUP BY
-- Create meaningful categories SELECT CASE WHEN AI_SENTIMENT(text) >= 0.6 THEN 'Very Positive' WHEN AI_SENTIMENT(text) >= 0.2 THEN 'Positive' WHEN AI_SENTIMENT(text) >= -0.2 THEN 'Neutral' WHEN AI_SENTIMENT(text) >= -0.6 THEN 'Negative' ELSE 'Very Negative' END AS sentiment_category, COUNT(*) AS count FROM feedback GROUP BY
2. Combine with Other Metrics
SELECT product_id, AVG(rating) AS avg_rating, AVG(AI_SENTIMENT(review_text)) AS avg_sentiment, CORR(rating, AI_SENTIMENT(review_text)) AS rating_sentiment_correlation FROM reviews GROUP BY
SELECT product_id, AVG(rating) AS avg_rating, AVG(AI_SENTIMENT(review_text)) AS avg_sentiment, CORR(rating, AI_SENTIMENT(review_text)) AS rating_sentiment_correlation FROM reviews GROUP BY
SELECT product_id, AVG(rating) AS avg_rating, AVG(AI_SENTIMENT(review_text)) AS avg_sentiment, CORR(rating, AI_SENTIMENT(review_text)) AS rating_sentiment_correlation FROM reviews GROUP BY
3. Monitor Sentiment Trends
CREATE VIEW sentiment_trends AS SELECT DATE_TRUNC('day', created_at) AS date, product_category, AVG(AI_SENTIMENT(feedback_text)) AS avg_sentiment, STDDEV(AI_SENTIMENT(feedback_text)) AS sentiment_volatility FROM customer_feedback GROUP BY date,
CREATE VIEW sentiment_trends AS SELECT DATE_TRUNC('day', created_at) AS date, product_category, AVG(AI_SENTIMENT(feedback_text)) AS avg_sentiment, STDDEV(AI_SENTIMENT(feedback_text)) AS sentiment_volatility FROM customer_feedback GROUP BY date,
CREATE VIEW sentiment_trends AS SELECT DATE_TRUNC('day', created_at) AS date, product_category, AVG(AI_SENTIMENT(feedback_text)) AS avg_sentiment, STDDEV(AI_SENTIMENT(feedback_text)) AS sentiment_volatility FROM customer_feedback GROUP BY date,
4. Alert on Negative Sentiment Spikes
WITH daily_sentiment AS ( SELECT DATE(created_at) AS date, AVG(AI_SENTIMENT(comment)) AS avg_sentiment FROM social_media_mentions WHERE brand = 'OurBrand' GROUP BY date ) SELECT * FROM daily_sentiment WHERE avg_sentiment < -0.3 AND date >= CURRENT_DATE - 7 ORDER BY date DESC
WITH daily_sentiment AS ( SELECT DATE(created_at) AS date, AVG(AI_SENTIMENT(comment)) AS avg_sentiment FROM social_media_mentions WHERE brand = 'OurBrand' GROUP BY date ) SELECT * FROM daily_sentiment WHERE avg_sentiment < -0.3 AND date >= CURRENT_DATE - 7 ORDER BY date DESC
WITH daily_sentiment AS ( SELECT DATE(created_at) AS date, AVG(AI_SENTIMENT(comment)) AS avg_sentiment FROM social_media_mentions WHERE brand = 'OurBrand' GROUP BY date ) SELECT * FROM daily_sentiment WHERE avg_sentiment < -0.3 AND date >= CURRENT_DATE - 7 ORDER BY date DESC
Common Use Cases
Customer Service Prioritization
SELECT ticket_id, customer_email, AI_SENTIMENT(ticket_description) AS sentiment, CASE WHEN AI_SENTIMENT(ticket_description) < -0.6 THEN 'High Priority' WHEN AI_SENTIMENT(ticket_description) < -0.2 THEN 'Medium Priority' ELSE 'Normal Priority' END AS priority FROM support_tickets WHERE status = 'Open'
SELECT ticket_id, customer_email, AI_SENTIMENT(ticket_description) AS sentiment, CASE WHEN AI_SENTIMENT(ticket_description) < -0.6 THEN 'High Priority' WHEN AI_SENTIMENT(ticket_description) < -0.2 THEN 'Medium Priority' ELSE 'Normal Priority' END AS priority FROM support_tickets WHERE status = 'Open'
SELECT ticket_id, customer_email, AI_SENTIMENT(ticket_description) AS sentiment, CASE WHEN AI_SENTIMENT(ticket_description) < -0.6 THEN 'High Priority' WHEN AI_SENTIMENT(ticket_description) < -0.2 THEN 'Medium Priority' ELSE 'Normal Priority' END AS priority FROM support_tickets WHERE status = 'Open'
Product Launch Monitoring
SELECT launch_date, product_name, AVG(AI_SENTIMENT(social_mention)) AS avg_sentiment, COUNT(*) AS mention_count FROM social_media_monitoring WHERE product_name = 'New Product X' AND mention_date BETWEEN launch_date AND launch_date + 30 GROUP BY launch_date,
SELECT launch_date, product_name, AVG(AI_SENTIMENT(social_mention)) AS avg_sentiment, COUNT(*) AS mention_count FROM social_media_monitoring WHERE product_name = 'New Product X' AND mention_date BETWEEN launch_date AND launch_date + 30 GROUP BY launch_date,
SELECT launch_date, product_name, AVG(AI_SENTIMENT(social_mention)) AS avg_sentiment, COUNT(*) AS mention_count FROM social_media_monitoring WHERE product_name = 'New Product X' AND mention_date BETWEEN launch_date AND launch_date + 30 GROUP BY launch_date,
Related Functions
AI_CLASSIFY - For categorical sentiment classification
AI_COMPLETE - For detailed sentiment analysis with reasoning
AI_AGG - For aggregating sentiment insights
More Articles

Learn
·
Feb 18, 2026
BigQuery Global Queries: How to Run Cross-Region SQL in 2026

Analytics
·
Feb 18, 2026
Context Engineering and AI Quality for Data Teams

Product
·
Feb 18, 2026
Accelerate Analytics Development with Paradime and Tableau

Product
·
Feb 18, 2026
Accelerate Analytics Development with Paradime and Tableau
Experience Analytics for the AI-Era
Start your 14-day trial today - it's free and no credit card needed
Experience Analytics for the AI-Era
Start your 14-day trial today - it's free and no credit card needed
Experience Analytics for the AI-Era
Start your 14-day trial today - it's free and no credit card needed
Platform
Resources
ADD-ONs
Industries
Copyright © 2026 Paradime Labs, Inc.
Made with ❤️ in San Francisco ・ London
*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.
Platform
Resources
ADD-ONs
Industries


Copyright © 2026 Paradime Labs, Inc.
Made with ❤️ in San Francisco ・ London
*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.
Platform
Resources
ADD-ONs
Industries


Copyright © 2026 Paradime Labs, Inc.
Made with ❤️ in San Francisco ・ London
*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.
