From 1ca1e9c73634dd4e5e868f66d09e9ce0e97d0dfd Mon Sep 17 00:00:00 2001 From: dal Date: Tue, 18 Feb 2025 14:22:21 -0700 Subject: [PATCH] tweak the prompts to cover isseus with div by zero --- api/src/utils/prompts/generate_sql_prompts/sql_gen_prompt.rs | 4 ++++ .../prompts/generate_sql_prompts/sql_gen_thought_prompt.rs | 2 ++ 2 files changed, 6 insertions(+) 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: