SQL Keywords

SQL Keywords

AI_CLASSIFY

Feb 23, 2026

·

5

min read

AI_CLASSIFY

Overview

Classifies text or images into user-defined categories. Supports both single-label and multi-label classification.

Syntax

AI_CLASSIFY(
  input,
  categories,
  [options]
)
AI_CLASSIFY(
  input,
  categories,
  [options]
)
AI_CLASSIFY(
  input,
  categories,
  [options]
)

Parameters

  • input (VARCHAR or FILE): Text string or image file reference

  • categories (ARRAY): List of category names to classify into

  • options (OBJECT): Optional settings like multi_label, examples, descriptions

Use Cases

  • Customer feedback categorization

  • Content moderation

  • Email routing and prioritization

  • Product categorization

  • Image classification

  • Sentiment classification

Code Examples

Example 1: Simple Text Classification

SELECT AI_CLASSIFY(
  'I dream of backpacking across South America.',
  ['travel', 'cooking', 'technology', 'sports']
) AS

SELECT AI_CLASSIFY(
  'I dream of backpacking across South America.',
  ['travel', 'cooking', 'technology', 'sports']
) AS

SELECT AI_CLASSIFY(
  'I dream of backpacking across South America.',
  ['travel', 'cooking', 'technology', 'sports']
) AS

Output:

travel
travel
travel

Example 2: Multi-Label Classification

SELECT AI_CLASSIFY(
  'This laptop has amazing battery life and a beautiful display.',
  ['performance', 'design', 'battery', 'price'],
  {'multi_label': true}
) AS

SELECT AI_CLASSIFY(
  'This laptop has amazing battery life and a beautiful display.',
  ['performance', 'design', 'battery', 'price'],
  {'multi_label': true}
) AS

SELECT AI_CLASSIFY(
  'This laptop has amazing battery life and a beautiful display.',
  ['performance', 'design', 'battery', 'price'],
  {'multi_label': true}
) AS

Output:

["performance", "design", "battery"]
["performance", "design", "battery"]
["performance", "design", "battery"]

Example 3: Classification with Descriptions

SELECT AI_CLASSIFY(
  customer_feedback,
  ['bug', 'feature_request', 'complaint', 'praise'],
  {
    'descriptions': {
      'bug': 'Technical issue or error',
      'feature_request': 'Request for new functionality',
      'complaint': 'Negative feedback about existing features',
      'praise': 'Positive feedback'
    }
  }
) AS feedback_type
FROM

SELECT AI_CLASSIFY(
  customer_feedback,
  ['bug', 'feature_request', 'complaint', 'praise'],
  {
    'descriptions': {
      'bug': 'Technical issue or error',
      'feature_request': 'Request for new functionality',
      'complaint': 'Negative feedback about existing features',
      'praise': 'Positive feedback'
    }
  }
) AS feedback_type
FROM

SELECT AI_CLASSIFY(
  customer_feedback,
  ['bug', 'feature_request', 'complaint', 'praise'],
  {
    'descriptions': {
      'bug': 'Technical issue or error',
      'feature_request': 'Request for new functionality',
      'complaint': 'Negative feedback about existing features',
      'praise': 'Positive feedback'
    }
  }
) AS feedback_type
FROM

Example 4: Classification with Examples

SELECT AI_CLASSIFY(
  review_text,
  ['positive', 'negative', 'neutral'],
  {
    'examples': {
      'positive': ['Great product!', 'Love it!'],
      'negative': ['Terrible experience', 'Do not buy'],
      'neutral': ['It works', 'As expected']
    }
  }
) AS sentiment
FROM

SELECT AI_CLASSIFY(
  review_text,
  ['positive', 'negative', 'neutral'],
  {
    'examples': {
      'positive': ['Great product!', 'Love it!'],
      'negative': ['Terrible experience', 'Do not buy'],
      'neutral': ['It works', 'As expected']
    }
  }
) AS sentiment
FROM

SELECT AI_CLASSIFY(
  review_text,
  ['positive', 'negative', 'neutral'],
  {
    'examples': {
      'positive': ['Great product!', 'Love it!'],
      'negative': ['Terrible experience', 'Do not buy'],
      'neutral': ['It works', 'As expected']
    }
  }
) AS sentiment
FROM

Example 5: Image Classification

SELECT 
    file_name,
    AI_CLASSIFY(
        TO_FILE('@image_stage/' || file_name),
        ['indoor', 'outdoor', 'portrait', 'landscape']
    ) AS image_category
FROM DIRECTORY('@image_stage')
WHERE file_name LIKE '%.jpg'

SELECT 
    file_name,
    AI_CLASSIFY(
        TO_FILE('@image_stage/' || file_name),
        ['indoor', 'outdoor', 'portrait', 'landscape']
    ) AS image_category
FROM DIRECTORY('@image_stage')
WHERE file_name LIKE '%.jpg'

SELECT 
    file_name,
    AI_CLASSIFY(
        TO_FILE('@image_stage/' || file_name),
        ['indoor', 'outdoor', 'portrait', 'landscape']
    ) AS image_category
FROM DIRECTORY('@image_stage')
WHERE file_name LIKE '%.jpg'

Data Output Examples

Support Ticket Categorization

Input: "The app crashes every time I try to upload a file"
Categories: ['bug', 'feature_request', 'question', 'feedback']
Output: "bug"
Input: "The app crashes every time I try to upload a file"
Categories: ['bug', 'feature_request', 'question', 'feedback']
Output: "bug"
Input: "The app crashes every time I try to upload a file"
Categories: ['bug', 'feature_request', 'question', 'feedback']
Output: "bug"

E-commerce Product Classification

Input: "Wireless Bluetooth headphones with noise cancellation"
Categories: ['electronics', 'clothing', 'home', 'sports']
Output: "electronics"
Input: "Wireless Bluetooth headphones with noise cancellation"
Categories: ['electronics', 'clothing', 'home', 'sports']
Output: "electronics"
Input: "Wireless Bluetooth headphones with noise cancellation"
Categories: ['electronics', 'clothing', 'home', 'sports']
Output: "electronics"

Model Information

  • Model Used: Snowflake managed model

  • Context Window: 128,000 tokens

  • Supported Inputs: Text strings and images

Limitations & Considerations

Category Limits

  • Maximum 500 categories per classification

  • Categories, descriptions, and examples count as input tokens

  • Billed per record processed, not per batch

Cost

  • Input tokens include: text + all categories + descriptions + examples

  • Processed for EACH record, not once per query

  • Use concise category names and descriptions

Accuracy Tips

  • Provide clear, distinct category names

  • Use descriptions for ambiguous categories

  • Add examples for better accuracy (2-3 per category)

  • Avoid overlapping categories

Regional Availability

  • AWS US West/East: ✓

  • Azure East US: ✓

  • EU regions: ✓

  • Cross-region inference: ✓

Best Practices

1. Use Descriptions for Clarity

-- Better with descriptions
AI_CLASSIFY(
  text,
  ['urgent', 'normal', 'low'],
  {'descriptions': {
    'urgent': 'Requires immediate attention within 24 hours',
    'normal': 'Standard processing time 2-5 days',
    'low': 'Can be addressed when convenient'
  }}
)
-- Better with descriptions
AI_CLASSIFY(
  text,
  ['urgent', 'normal', 'low'],
  {'descriptions': {
    'urgent': 'Requires immediate attention within 24 hours',
    'normal': 'Standard processing time 2-5 days',
    'low': 'Can be addressed when convenient'
  }}
)
-- Better with descriptions
AI_CLASSIFY(
  text,
  ['urgent', 'normal', 'low'],
  {'descriptions': {
    'urgent': 'Requires immediate attention within 24 hours',
    'normal': 'Standard processing time 2-5 days',
    'low': 'Can be addressed when convenient'
  }}
)

2. Optimize for Cost

-- Use fewer, well-defined categories
-- Avoid: ['cat1', 'cat2', 'cat3', ... 'cat100']
-- Better: ['primary', 'secondary', 'other']
-- Use fewer, well-defined categories
-- Avoid: ['cat1', 'cat2', 'cat3', ... 'cat100']
-- Better: ['primary', 'secondary', 'other']
-- Use fewer, well-defined categories
-- Avoid: ['cat1', 'cat2', 'cat3', ... 'cat100']
-- Better: ['primary', 'secondary', 'other']

3. Multi-Label When Appropriate

-- For items that can belong to multiple categories
SELECT AI_CLASSIFY(
  'Fitness tracker watch with heart rate monitor',
  ['electronics', 'fitness', 'wearables', 'health'],
  {'multi_label': true}
);
-- Output: ["electronics", "fitness", "wearables", "health"]
-- For items that can belong to multiple categories
SELECT AI_CLASSIFY(
  'Fitness tracker watch with heart rate monitor',
  ['electronics', 'fitness', 'wearables', 'health'],
  {'multi_label': true}
);
-- Output: ["electronics", "fitness", "wearables", "health"]
-- For items that can belong to multiple categories
SELECT AI_CLASSIFY(
  'Fitness tracker watch with heart rate monitor',
  ['electronics', 'fitness', 'wearables', 'health'],
  {'multi_label': true}
);
-- Output: ["electronics", "fitness", "wearables", "health"]

Related Functions

  • AI_FILTER - For binary true/false classification

  • AI_SENTIMENT - Specialized for sentiment analysis

  • AI_COMPLETE - For more complex classification tasks

Interested to Learn More?
Try Out the Free 14-Days Trial

More Articles

decorative icon

Experience Analytics for the AI-Era

Start your 14-day trial today - it's free and no credit card needed

decorative icon

Experience Analytics for the AI-Era

Start your 14-day trial today - it's free and no credit card needed

decorative icon

Experience Analytics for the AI-Era

Start your 14-day trial today - it's free and no credit card needed

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.

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.

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.