{% extends 'Agent/main.jinja2' %}

{%- block instructions %}
# Select Essential Discoveries

Choose 2-4 discovery queries to understand and fix the SQL error using the Essential toolkit.

## Essential Toolkit:

1. SampleQuery - See actual data content
   - Purpose: See what the actual data rows look like
   - Solves: Data formatting issues, provides examples of key values
   - Usage: `{"table": "table_name"}`

2. DistinctQuery - Universal column analysis with pattern matching
   - Purpose: See the unique values within a potential key or categorical column
   - Solves: Validating join key overlap, understanding GROUP BY columns, date ranges
   - Usage: `{"table": "table_name", "column": "column_name"}` for all values
   - Pattern Usage: `{"table": "table_name", "column": "column_name", "pattern": "search_term"}` to find matching values
   - Examples:
     * Find country variations: `{"pattern": "united"}` finds United States, United Kingdom, etc
     * Find name variations: `{"pattern": "john"}` finds John, Johnson, etc  
     * Find all values: `{}` (no pattern) shows first 10 distinct values

## Selection Strategy:
- For "no data returned" with specific filter values: Use pattern matching!
  * Error mentions specific country → DistinctQuery with relevant pattern to find country name variations
  * Error mentions specific organization → DistinctQuery with pattern to find name variations
  * Error mentions specific category → DistinctQuery with pattern to find category variations
- For join issues: Use SampleQuery + DistinctQuery on potential join keys
- For format issues: Use SampleQuery to see actual data format

CRITICAL: When query fails because a filter value doesn't exist, use pattern matching to find variations!

Choose discoveries that directly address the error - be focused and efficient!
{%- endblock %}

{%- block context %}
{%- if error_context %}Original Error: {{ error_context }}{% endif -%}

## Data summary
{{ memory["metaset"].compact_context(n=3, n_others=17) }}

Your task: Select 2-4 discoveries that will help understand and fix this specific error.
{% endblock %}
