AI.GENERATE_BOOL
Category: General-Purpose AI Function (Preview)
Description
Generates a boolean (true/false) value for each row based on a natural language prompt and data analysis. Provides full control over prompts and models while returning a simple BOOL output. Useful for row-by-row validation, filtering logic, or conditional checks.
Use Cases
Data Validation: Check if records meet specific criteria
Content Moderation: Determine if content is appropriate
Business Rules: Apply complex conditional logic
Quality Checks: Validate data quality or completeness
Compliance: Check if content meets regulatory requirements
Syntax
AI.GENERATE_BOOL(
prompt => 'PROMPT',
[, data => INPUT_DATA ]
[, model => 'MODEL_ENDPOINT' ]
[, parameters => STRUCT(...) ]
[, connection_id => 'CONNECTION' ]
)Parameters
prompt: Natural language instruction/question (required)
data: Text or ObjectRefRuntime values to analyze
model: Gemini model endpoint (e.g., 'gemini-2.0-flash-exp')
parameters: Generation config (temperature, max_tokens, etc.)
connection_id: Vertex AI connection
Code Examples
Example 1: Validate Product Descriptions
SELECT
product_id,
product_name,
description,
AI.GENERATE_BOOL(
prompt => 'Does this product description mention the materials used?',
data => description,
connection_id => 'us.my_vertex_connection'
) AS mentions_materials
FROM products
WHERE category = 'furniture';Example 2: Content Appropriateness Check
SELECT
post_id,
content,
AI.GENERATE_BOOL(
prompt => 'Is this social media post appropriate for a professional business audience?',
data => content,
connection_id => 'us.my_vertex_connection'
) AS is_appropriate
FROM social_media_posts
WHERE reviewed = FALSE;Example 3: Multi-Field Validation
SELECT
application_id,
AI.GENERATE_BOOL(
prompt => 'Based on this application, does the candidate meet the minimum requirements: 5+ years experience, Bachelor degree, and expertise in Python?',
data => STRUCT(
years_experience,
education_level,
skills,
work_history
),
connection_id => 'us.my_vertex_connection'
) AS meets_requirements
FROM job_applications;Example 4: Image Validation
SELECT
image_id,
AI.GENERATE_BOOL(
prompt => 'Does this image show a product with clear visibility and professional lighting?',
data => OBJ.GET_ACCESS_URL(image_ref, 'r'),
connection_id => 'us.my_vertex_connection'
) AS is_high_quality
FROM product_photos
WHERE status = 'pending_review';Data Output Examples
Product Description Validation
product_name | mentions_materials |
|---|---|
"Oak Dining Table" | true |
"Modern Coffee Table" | false |
"Leather Office Chair" | true |
Content Appropriateness
post_id | content_preview | is_appropriate |
|---|---|---|
P001 | "Excited to announce our new product launch..." | true |
P002 | "This is the worst day ever..." | false |
P003 | "Great meeting with the team today..." | true |
Best Practices
Ask clear yes/no questions: Frame prompts for binary outcomes
Provide context: Include relevant data fields for better accuracy
Test edge cases: Validate behavior with ambiguous inputs
Consider AI.IF for filtering: Use AI.IF in WHERE clauses for better optimization
Monitor false positives/negatives: Validate results periodically
When to Use
✅ Use when you need custom boolean logic beyond AI.IF
✅ Use for row-by-row validation or checks
✅ Use when you need full control over the prompt
✅ Use for complex multi-field validation
Alternatives
AI.IF: For filtering with managed optimization
Traditional CASE WHEN: For rule-based logic (cheaper)
AI.GENERATE: For structured output with multiple fields
Platform Support
Regions: All Gemini-supported regions + US/EU multi-regions
Models: Gemini 2.0 Flash, Gemini 1.5 Pro, Gemini 1.5 Flash
Preview Status: Currently in Preview (Pre-GA)
Cost: Charged per Vertex AI API call
Returns
BOOL value (true/false). Returns NULL if the Vertex AI call fails.
Interested to Learn More? Try Out the Free 14-Days Trial
One AI-native workspace to build, ship, and monitor dbt™ — without the tool sprawl.