Is SQL
Is SQL checks that the output is a plausible SQL statement, or contains one in a ```sql block: a statement keyword, balanced parentheses and quotes. It mirrors promptfoo's `is-sql` and `contains-sql` as a syntax heuristic rather than a full parser.
Runs in code, free. Mirrors promptfoo is-sql / contains-sql
What the evaluator does
The text (or the fenced block) must start with WITH, SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, MERGE, TRUNCATE, GRANT, REVOKE or EXPLAIN, and have balanced parentheses and an even number of single quotes.
SELECT customer_id FROM orders GROUP BY customer_id HAVING COUNT(*) > 5;
keyword · parens · quotes
When to use it
Reach for it when
- Text-to-SQL pipelines, as a free gate before execution.
- Catching models that answer in prose instead of a query.
Not the right tool when
- You can execute the query; execution is the real test.
- Semantic equivalence to a reference (use sql).
Watch out for
- A heuristic accepts some invalid SQL and could reject unusual dialect constructs; treat it as a smoke test.
What to send
score 0–1 computed in code, label, passed at an evaluator-specific threshold, no probabilities.
{
"evaluators": [
"is_sql"
],
"output": "SELECT customer_id FROM orders GROUP BY customer_id HAVING COUNT(*) > 5;"
}Statement keyword, balanced: pass.
Aggregate with
One result per item is a fact; a dataset of them is a metric. These are the aggregations that fit this evaluator's output shape.
Related evaluators
Questions people ask
- Does is_sql parse the SQL?
- No. It is a conservative syntax heuristic. For correctness use execution, or the sql evaluator for equivalence against a reference.