TraceSQL: Traceable Answerability Estimation for Reference-Free Text-to-SQL Verification
Organizations: Oracle Corporation India · Oracle Corporation United States
Abstract
Text-to-SQL systems are commonly evaluated using ground-truth SQL queries or reference execution results, but such supervision is unavailable at inference time in real-world deployments. This creates a critical verification problem: given only a user question, database context, and generated SQL, can a system estimate whether the generated query is likely to correctly answer the question? Recent approaches use LLMs as judge or specialized agents to inspect generated SQL, but their decisions can be difficult to trace. Outcome Reward Models (ORMs) address this by learning from execution-labeled candidate SQLs and assigning correctness scores to unseen queries, yet they still provide limited visibility into the signals behind each verification. To address this limitation, we propose TraceSQL, a lightweight and traceable verification model built on explicit diagnostic features. TraceSQL combines 67 features capturing question ambiguity, question requirements, question-schema-SQL consistency, SQL structure, and intent alignment. These signals remain available for examining which factors influence each prediction and for tracing decisions back to diagnostic evidence. On BIRD development databases, TraceSQL achieves 66.47% F1 and 64.48% ROC-AUC, compared with 61.87% F1 and 58.26% ROC-AUC for the GradeSQL-7B ORM baseline on the same generated-SQL evaluation. Feature attribution further shows that the model relies on both semantic grounding and deterministic SQL-structure signals. These results show that SQL verification can be performed with a lightweight learned model while retaining feature-level evidence for inspecting and diagnosing its predictions.
Figures & tables
| Feature Family | # | Representative Features | Captured Evidence |
| Ambiguity | 10 | Ambiguity Overall Status; Metric Clarity; Time-Scope Clarity | Whether the question is sufficiently specified with respect to the requested metric, entities, temporal scope, constraints, references, and analytical intent. |
| Question Planning | 5 | Question Planner: Analytical Operation; Question Planner: Output Structure; Question Planner: Grouping | Whether the candidate SQL reflects the analytical operation, expected output structure, grouping, ordering, and SQL operations required by the question. |
| Pair Analysis | 32 | Join-Key Support; Data-Validity Rule Support; Additional Grounding Check | Whether tables, columns, joins, identifiers, data types, temporal semantics, metrics, validity rules, and business concepts are grounded in the available database context. |
| SQL Structure | 10 | SQL Aggregation Usage; SQL LIMIT Usage; SQL DISTINCT Usage | Deterministic structural properties of the candidate SQL extracted from its SQLGlot abstract syntax tree. |
| Intent Alignment | 10 | Intent Alignment: Evaluation Score; Intent Alignment: Grouping; Intent Alignment: Business Term | Whether the candidate SQL aligns with the requested metric, filters, scope, grouping, ranking, and business terminology. |
| Total | 67 |
| Feature | Perm. | Mean |
| SQL DISTINCT Usage | 0.0344 | 0.0074 |
| SQL LIMIT Usage | 0.0335 | 0.0147 |
| SQL Aggregation Usage | 0.0327 | 0.0073 |
| Additional Grounding Check | 0.0317 | 0.0199 |
| Pattern-Based Business Meaning Support | 0.0219 | 0.0117 |
| Data-Validity Rule Support | 0.0165 | 0.0070 |
| Model | Acc. | Prec. | Rec. | F1 | AUC |
| GradeSQL-7B | 57.46 | 63.64 | 60.21 | 61.87 | 58.26 |
| TraceSQL | 62.46 | 68.11 | 64.91 | 66.47 | 64.48 |
| Database | GradeSQL-7B | TraceSQL | ||||||||
| Acc. | Prec. | Rec. | F1 | AUC | Acc. | Prec. | Rec. | F1 | AUC | |
| California Schools | 45.45 | 64.86 | 40.68 | 50.00 | 58.33 | 51.14 | 69.05 | 49.15 | 57.43 | 56.25 |
| Card Games | 55.26 | 50.47 | 62.79 | 55.96 | 53.98 | 61.05 | 56.82 | 58.14 | 57.47 | 64.73 |
| Codebase Community | 61.83 | 73.45 | 66.94 | 70.04 | 59.31 | 65.59 | 75.00 | 72.58 | 73.77 | 66.03 |
| Debit Card Specializing | 48.33 | 44.19 | 73.08 | 55.07 | 46.27 | 60.00 | 55.00 | 42.31 | 47.83 | 60.35 |
| European Football 2 | 57.14 | 71.43 | 55.56 | 62.50 | 59.48 | 61.90 | 75.38 | 60.49 | 67.12 | 69.36 |
| Model | Acc./Rec. | Prec. | F1 | AUC |
| GradeSQL-7B | 62.84 | 100.00 | 77.18 | N/A |
| TraceSQL | 60.17 | 100.00 | 75.13 | N/A |
Appendix figures & tables14 assets
Supplementary material from the paper’s appendix.
Appendix
| Feature |
| Versioning Rule Support |
| Name and Alias Support |
| Effective Date Meaning |
| User Context Mapping Support |
| User Context Resolution Support |
| Feature family | Count | Extraction |
| Ambiguity | 10 | Question-level ambiguity status, probability, and eight probe verdicts. |
| Question Planning | 5 | Probe verdicts comparing planned question requirements with candidate SQL support. |
| Pair Analysis | 32 | Direct projection of canonical Pair Analyzer rule statuses. |
| SQL Structure | 10 | Deterministic binary indicators extracted from the SQL AST. |
| Intent Alignment | 10 | Four evaluator fields and six probe-based alignment verdicts. |
| Total | 67 | Fixed candidate-level representation supplied to FLAML. |
| Probe ID | Feature Name | Meaning |
| – | Ambiguity_Overall_Status | Overall Boolean assessment indicating whether the user question is considered ambiguous. |
| – | Ambiguity_Assessment_Probability | Estimated degree of ambiguity assigned by the Ambiguity Detector on a 0–100 scale. |
| AQ001 | Ambiguity_Metric_Clarity | Captures uncertainty concerning the metric, measure, quantitative value, or derived calculation requested by the question. |
| AQ002 | Ambiguity_Entity_Clarity | Captures uncertainty concerning the entity, subject, record, or target referenced by the question. |
| AQ003 | Ambiguity_Time_Scope_Clarity | Captures uncertainty concerning the time period or temporal scope required by the question. |
| AQ004 | Ambiguity_Constraint_Clarity | Captures uncertainty concerning filters, thresholds, limits, or other logical constraints expressed in the question. |
| Probe ID | Feature Name | Meaning |
| QP001 | Question_Planner_Analytical_Operation_Support | Whether the candidate SQL supports the analytical operation required by the question, such as lookup, aggregation, comparison, ranking, or trend analysis. |
| QP002 | Question_Planner_Output_Structure_Support | Whether the candidate SQL supports the expected output columns, answer structure, and result granularity required by the question. |
| QP003 | Question_Planner_Grouping_Support | Whether the candidate SQL supports the grouping requirements and aggregation dimensions required by the question. |
| QP004 | Question_Planner_Ordering_or_Ranking_Support | Whether the candidate SQL supports ordering, ranking, top- , sort direction, or extremum requirements expressed by the question. |
| QP005 | Question_Planner_SQL_Operations_Support | Whether the candidate SQL contains the operations required to answer the question, such as joins, filters, aggregation, window functions, DISTINCT , or set operations. |
| Rule ID | Feature Name | Meaning |
| schema_reference _verification | Pair_Analyzer_Schema_Reference_Support | Whether referenced schemas are present and supported by the catalog. |
| table_reference _verification | Pair_Analyzer_Table_Reference_Support | Whether referenced tables are present and supported by the catalog. |
| column_reference _verification | Pair_Analyzer_Column_Reference_Support | Whether referenced columns are present and supported by the catalog. |
| schema_scope_description _verification | Pair_Analyzer_Schema_Scope_Support | Whether schema-level descriptions support the question and SQL intent. |
| table_scope_description _verification | Pair_Analyzer_Table_Scope_Support | Whether table descriptions support the question and SQL intent. |
| column_scope_description _verification | Pair_Analyzer_Column_Scope_Support | Whether column descriptions support the question and SQL intent. |
| Rule ID | Feature Name | Meaning |
| temporal_fields _verification | Pair_Analyzer_Date_Time_Field_Distinction | Whether similar date/time fields are clearly distinguished so that the intended field can be identified. |
| temporal_queries _verification | Pair_Analyzer_Temporal_Analysis_Support | Whether temporal metadata supports historical, period-based, fiscal, or as-of analysis requested by the question. |
| timezone_semantics _verification | Pair_Analyzer_Timezone_Handling_Support | Whether timezone handling is documented sufficiently to interpret operational timestamps correctly. |
| effective_date_semantics _verification | Pair_Analyzer_Effective_Date_Meaning | Whether effective dates and validity periods clearly indicate when records become active, expire, or apply. |
| metric_definition _verification | Pair_Analyzer_Metric_Definition_Support | Whether a metric is documented sufficiently to validate the metric requested by the question. |
| metric_aggregation_logic _verification | Pair_Analyzer_Metric_Calculation_Support | Whether aggregations, ratios, and rollups follow the documented meaning of the metric. |
| Feature Name | Meaning |
| SQL Aggregation Usage | Whether the candidate contains an aggregate operation. |
| SQL Grouping Usage | Whether the candidate contains a GROUP BY operation. |
| SQL Join Usage | Whether the candidate joins multiple relations. |
| SQL Filtering Usage | Whether the candidate contains WHERE or HAVING filtering. |
| SQL Temporal Filter Usage | Whether the candidate contains a temporal/date-related filter. |
| SQL ORDER BY Usage | Whether the candidate contains an ORDER BY clause. |
| Feature Name | Meaning |
| Intent Alignment Overall Score | Reference-free evaluator score for overall alignment between the question and candidate SQL. |
| Intent Alignment Confidence | Confidence associated with the reference-free alignment evaluation. |
| Intent Alignment Gate Decision | Evaluator gate decision, such as accepting or requesting intervention. |
| Intent Alignment Intervention Reason | Categorized reason for intervention when the evaluator does not accept the candidate. |
| Intent Alignment: Requested Metric | Whether the metric or measure requested by the question is aligned with the candidate SQL. |
| Intent Alignment: Filter Conditions | Whether filtering constraints in the question are represented by the candidate SQL. |
| Feature | SHAP | Perm. | Native |
| Additional Grounding Check | 1 | 4 | 2 |
| SQL LIMIT Usage | 2 | 2 | 5 |
| Pattern-Based Business Meaning Support | 3 | 5 | 3 |
| SQL DISTINCT Usage | 4 | 1 | 14 |
| SQL Aggregation Usage | 5 | 3 | 1 |
| Data-Validity Rule Support | 6 | 6 | 4 |
| Feature Family | SHAP | Perm. | Native |
| Ambiguity | 0 | 0 | 0 |
| Question Planning | 1 | 1 | 1 |
| Pair Analysis | 3 | 3 | 4 |
| SQL Structure | 4 | 5 | 3 |
| Intent Alignment | 2 | 1 | 2 |
| Database | GradeSQL-7B | TraceSQL |
| California Schools | 41.57 | 67.42 |
| Card Games | 59.16 | 43.98 |
| Codebase Community | 65.59 | 66.13 |
| Debit Card Specializing | 68.75 | 29.69 |
| European Football 2 | 65.12 | 62.79 |
| Financial | 60.38 | 75.47 |
Text-to-SQL
Text-to-SQL translates natural-language questions into executable database queries, linking user intent to schemas, values, and SQL logic.
See all 169 papers