SQL Keywords
AI_FILTER
·
AI_FILTER
Overview
Returns True or False for a given text or image input based on a natural language condition. Use in SELECT, WHERE, or JOIN clauses to filter results.
Syntax
AI_FILTER( condition, input )
AI_FILTER( condition, input )
AI_FILTER( condition, input )
Parameters
condition (VARCHAR): Natural language description of the filter condition
input (VARCHAR or FILE): Text string or file reference to evaluate
Use Cases
Content moderation and filtering
Data quality checks
Conditional data processing
Smart data filtering
Policy compliance checking
Image content filtering
Code Examples
Example 1: Simple Text Filtering
SELECT country, AI_FILTER('Is this country in Asia?', country) AS is_in_asia FROM
SELECT country, AI_FILTER('Is this country in Asia?', country) AS is_in_asia FROM
SELECT country, AI_FILTER('Is this country in Asia?', country) AS is_in_asia FROM
Output:
country | is_in_asia ----------|------------ Japan | true Germany | false Thailand | true Canada | false
country | is_in_asia ----------|------------ Japan | true Germany | false Thailand | true Canada | false
country | is_in_asia ----------|------------ Japan | true Germany | false Thailand | true Canada | false
Example 2: Filter in WHERE Clause
SELECT product_name, description, price FROM products WHERE AI_FILTER( 'Does this product description mention eco-friendly or sustainable materials?', description ) = true
SELECT product_name, description, price FROM products WHERE AI_FILTER( 'Does this product description mention eco-friendly or sustainable materials?', description ) = true
SELECT product_name, description, price FROM products WHERE AI_FILTER( 'Does this product description mention eco-friendly or sustainable materials?', description ) = true
Example 3: Customer Review Filtering
SELECT review_id, review_text, AI_FILTER( 'Does this review contain complaints about shipping or delivery?', review_text ) AS has_shipping_complaint FROM customer_reviews WHERE created_date >= CURRENT_DATE - 30
SELECT review_id, review_text, AI_FILTER( 'Does this review contain complaints about shipping or delivery?', review_text ) AS has_shipping_complaint FROM customer_reviews WHERE created_date >= CURRENT_DATE - 30
SELECT review_id, review_text, AI_FILTER( 'Does this review contain complaints about shipping or delivery?', review_text ) AS has_shipping_complaint FROM customer_reviews WHERE created_date >= CURRENT_DATE - 30
Example 4: Multi-Condition Filtering
SELECT email_id, subject, body FROM emails WHERE AI_FILTER('Is this email urgent or high priority?', subject || ' ' || body) = true AND AI_FILTER('Does this email require immediate action?', body) = true
SELECT email_id, subject, body FROM emails WHERE AI_FILTER('Is this email urgent or high priority?', subject || ' ' || body) = true AND AI_FILTER('Does this email require immediate action?', body) = true
SELECT email_id, subject, body FROM emails WHERE AI_FILTER('Is this email urgent or high priority?', subject || ' ' || body) = true AND AI_FILTER('Does this email require immediate action?', body) = true
Example 5: Image Content Filtering
SELECT file_name, AI_FILTER( 'Does this image contain people?', TO_FILE('@images/' || file_name) ) AS contains_people FROM DIRECTORY('@images') WHERE file_name LIKE '%.jpg'
SELECT file_name, AI_FILTER( 'Does this image contain people?', TO_FILE('@images/' || file_name) ) AS contains_people FROM DIRECTORY('@images') WHERE file_name LIKE '%.jpg'
SELECT file_name, AI_FILTER( 'Does this image contain people?', TO_FILE('@images/' || file_name) ) AS contains_people FROM DIRECTORY('@images') WHERE file_name LIKE '%.jpg'
Example 6: Dynamic Filtering with PROMPT
SELECT product_category, AI_FILTER( PROMPT('Is {0} a category related to technology?', product_category), product_category ) AS is_tech_related FROM
SELECT product_category, AI_FILTER( PROMPT('Is {0} a category related to technology?', product_category), product_category ) AS is_tech_related FROM
SELECT product_category, AI_FILTER( PROMPT('Is {0} a category related to technology?', product_category), product_category ) AS is_tech_related FROM
Data Output Examples
Policy Compliance
Input: "This document contains confidential financial information" Condition: "Does this text indicate confidential or sensitive information?" Output: true
Input: "This document contains confidential financial information" Condition: "Does this text indicate confidential or sensitive information?" Output: true
Input: "This document contains confidential financial information" Condition: "Does this text indicate confidential or sensitive information?" Output: true
Quality Checks
Input: "This product is made from 100% recycled materials" Condition: "Does this mention environmental sustainability?" Output: true
Input: "This product is made from 100% recycled materials" Condition: "Does this mention environmental sustainability?" Output: true
Input: "This product is made from 100% recycled materials" Condition: "Does this mention environmental sustainability?" Output: true
Model Information
Model Used: Snowflake managed model
Context Window: 128,000 tokens
Output: Boolean (true/false)
Limitations & Considerations
Performance
Best for batch processing, not real-time filtering
Use MEDIUM warehouse or smaller
Consider caching results for repeated filters
Cost
Billed per input processed
Condition text counts as input tokens for each row
Use concise, clear conditions
Accuracy
Works best with specific, unambiguous conditions
May struggle with highly subjective criteria
Test with sample data before large-scale use
Regional Availability
AWS US West/East: ✓
Azure East US: ✓
EU regions: ✓
Cross-region inference: ✓
Best Practices
1. Write Clear Conditions
-- Good: Specific and unambiguous AI_FILTER('Does this text contain profanity or offensive language?', text) -- Less effective: Vague AI_FILTER('Is this bad?', text)
-- Good: Specific and unambiguous AI_FILTER('Does this text contain profanity or offensive language?', text) -- Less effective: Vague AI_FILTER('Is this bad?', text)
-- Good: Specific and unambiguous AI_FILTER('Does this text contain profanity or offensive language?', text) -- Less effective: Vague AI_FILTER('Is this bad?', text)
2. Use PROMPT for Dynamic Conditions
-- Build dynamic conditions SELECT product_name, AI_FILTER( PROMPT('Does {0} contain the keyword {1}?', product_name, 'organic'), product_name ) AS matches FROM
-- Build dynamic conditions SELECT product_name, AI_FILTER( PROMPT('Does {0} contain the keyword {1}?', product_name, 'organic'), product_name ) AS matches FROM
-- Build dynamic conditions SELECT product_name, AI_FILTER( PROMPT('Does {0} contain the keyword {1}?', product_name, 'organic'), product_name ) AS matches FROM
3. Combine with Traditional Filters
-- Use AI_FILTER for complex logic, traditional WHERE for simple filters SELECT * FROM reviews WHERE rating <= 2 -- Traditional filter AND AI_FILTER('Does this mention product defects or quality issues?', review_text) = true
-- Use AI_FILTER for complex logic, traditional WHERE for simple filters SELECT * FROM reviews WHERE rating <= 2 -- Traditional filter AND AI_FILTER('Does this mention product defects or quality issues?', review_text) = true
-- Use AI_FILTER for complex logic, traditional WHERE for simple filters SELECT * FROM reviews WHERE rating <= 2 -- Traditional filter AND AI_FILTER('Does this mention product defects or quality issues?', review_text) = true
4. Consider Materialized Views
-- For frequently used filters, materialize results CREATE MATERIALIZED VIEW eco_products AS SELECT product_id, product_name, AI_FILTER('Is this product environmentally friendly?', description) AS is_eco_friendly FROM
-- For frequently used filters, materialize results CREATE MATERIALIZED VIEW eco_products AS SELECT product_id, product_name, AI_FILTER('Is this product environmentally friendly?', description) AS is_eco_friendly FROM
-- For frequently used filters, materialize results CREATE MATERIALIZED VIEW eco_products AS SELECT product_id, product_name, AI_FILTER('Is this product environmentally friendly?', description) AS is_eco_friendly FROM
Common Use Cases
Content Moderation
SELECT comment_id, comment_text FROM user_comments WHERE AI_FILTER('Does this contain hate speech or harassment?', comment_text) = false
SELECT comment_id, comment_text FROM user_comments WHERE AI_FILTER('Does this contain hate speech or harassment?', comment_text) = false
SELECT comment_id, comment_text FROM user_comments WHERE AI_FILTER('Does this contain hate speech or harassment?', comment_text) = false
Compliance Checking
SELECT document_id FROM legal_documents WHERE AI_FILTER('Does this document comply with GDPR requirements?', content) = true
SELECT document_id FROM legal_documents WHERE AI_FILTER('Does this document comply with GDPR requirements?', content) = true
SELECT document_id FROM legal_documents WHERE AI_FILTER('Does this document comply with GDPR requirements?', content) = true
Smart Tagging
SELECT article_id, title, AI_FILTER('Is this article about artificial intelligence?', title || ' ' || content) AS is_ai_topic FROM
SELECT article_id, title, AI_FILTER('Is this article about artificial intelligence?', title || ' ' || content) AS is_ai_topic FROM
SELECT article_id, title, AI_FILTER('Is this article about artificial intelligence?', title || ' ' || content) AS is_ai_topic FROM
Related Functions
AI_CLASSIFY - For multi-category classification
AI_SENTIMENT - For sentiment analysis
PROMPT - For building dynamic conditions
AI_COMPLETE - For complex evaluations
Stop Managing Pipelines. Start Shipping Them.
Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.
Stop Managing Pipelines. Start Shipping Them.
Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.
Stop Managing Pipelines. Start Shipping Them.
Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.
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.