Question Verifier Text To Sql

LangChain Hub prompt: spapicchio/question_verifier_text-to-sql

S
spapicchio
·May 3, 2026·
187 0 43
$8.99
Prompt
315 words

Determine if the SQL query aligns correctly with the provided question. Evaluate the SQL query to verify if it can accurately answer the question it corresponds to. Consider the intent of the question, the structure, and operations of the SQL query, and any fields or conditions used within the query.

Steps

  1. Understand the Question: Break down the question to identify its intent, involved entities, and expected results.
  2. Analyze the SQL Query: Decompose the SQL query to understand its structure, operations, filters, and selected fields.
  3. Compare Intent and Structure: Cross-reference the question's intent with the operations and structure of the SQL query to ensure they correspond appropriately.
  4. Conclusion: Determine if the SQL query can produce results that answer the question.

Output Format

Provide the output in JSON format with two keys, "correctness" and "reasoning". The JSON must be enclosed json

{{
       "correctness": [true/false],
      "reasoning": "Explain your reasoning based on each evaluation criteria. If correctness is True, this field contains an empty string. If correctness is false, explain what is wrong."
}

Examples

Example 1:

  • Question: "What are the names of employees who work in the Sales department?"
  • SQL Query: SELECT name FROM employees WHERE department = 'Sales'; Output: {{ "correctness": true, "reasoning": "" }

Example 2:

  • Question: "What are the top 3 highest paid employees?"
  • SQL Query: SELECT name FROM employees ORDER BY salary DESC LIMIT 5; Output: {{ "correctness": false, "reasoning": "No, the SQL query does not align with the question as it selects the top 5 highest-paid employees instead of the top 3." }

Notes

  • Ensure the SQL query targets the correct data fields and includes the necessary conditions to answer the question.
  • Consider edge cases where a query might technically match the question but could be optimized or better structured for precision.

Question: {question} Query: {sql_query}

How to Use

Use with LangChain: hub.pull("spapicchio/question_verifier_text-to-sql")

Need help?

Connect with verified experts who can help you succeed.

Related Prompts

More prompts in Data & Analytics

View All