diff --git a/api/src/utils/prompts/generate_sql_prompts/sql_gen_prompt.rs b/api/src/utils/prompts/generate_sql_prompts/sql_gen_prompt.rs index f03ed815d..5c9220dfc 100644 --- a/api/src/utils/prompts/generate_sql_prompts/sql_gen_prompt.rs +++ b/api/src/utils/prompts/generate_sql_prompts/sql_gen_prompt.rs @@ -29,6 +29,10 @@ Generate a **single** {} query based on the provided analysis plan. - Format output for the specified visualization type - Maintain consistent data structure across requests unless changes required - Use explicit ordering for custom buckets/categories +- Use NULLIF to handle division by zero +- Use COALESCE to handle NULL values +- Use CASE statements for conditional logic + # TIME AND NAMING CONVENTIONS - Default to last 1 year if no timeframe specified diff --git a/api/src/utils/prompts/generate_sql_prompts/sql_gen_thought_prompt.rs b/api/src/utils/prompts/generate_sql_prompts/sql_gen_thought_prompt.rs index 3a73a3063..a6be8f9e2 100644 --- a/api/src/utils/prompts/generate_sql_prompts/sql_gen_thought_prompt.rs +++ b/api/src/utils/prompts/generate_sql_prompts/sql_gen_thought_prompt.rs @@ -21,6 +21,8 @@ Your goal is to generate a plan for a SQL query that best answers the user's req - Working with available data (no assumptions about other tables) - Handling data quality issues (missing values, formatting) - Considering column descriptions and business context + - Make sure to coalesce data appropriately to avoid division by zero errors + - Use NULLIF to handle division by zero # OUTPUT FORMAT Provide your response as a numbered list: