NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Towards Database-Free Text-to-SQL Evaluation: A Graph-Based Metric for Functional Correctness

Yi Zhan, Longjie Cui, Han Weng, Guifeng Wang, Yu Tian, Boyi Liu, Yingxiang Yang, Xiaoming Yin, Jiajun Xie, Yang SunCOLING 2025

Abstract

Execution Accuracy and Exact Set Match are two predominant metrics for evaluating the functional correctness of SQL queries in modern Text-to-SQL tasks. However, both metrics have notable limitations: Exact Set Match fails when queries are functionally equivalent but syntactically different, while Execution Accuracy is prone to false positives due to inadequately prepared test databases, which can be costly to create, particularly in large-scale industrial applications. To overcome these challenges, we propose a novel graph-based metric, FuncEvalGMN, that effectively overcomes the deficiencies of the aforementioned metric designs. Our method utilizes a relational operator tree (ROT), referred to as RelNode, to extract rich semantic information from the logical execution plan of SQL queries, and embed it into a graph. We then train a graph neural network (GNN) to perform graph matching on pairs of SQL queries through graph contrastive learning. FuncEvalGMN offers two highly desired advantages: (i) it requires only the database schema to derive logical execution plans, eliminating the need for extensive test database preparation, and (ii) it demonstrates strong generalization capabilities on unseen datasets. These properties highlight FuncEvalGMN’s robustness as a reliable metric for assessing functional correctness across a wide range of Text-to-SQL applications.

Introduction

Evaluating Text-to-SQL models—which translate natural language into executable SQL—is a critical yet challenging task. Currently, researchers rely on two main metrics: Exact Set Match and Execution Accuracy. Exact Set Match is often too rigid, failing when two queries are written differently but perform the same logical operation (false negatives). Conversely, Execution Accuracy, while the current "gold standard," is susceptible to false positives. As illustrated in Figure 1, a poorly constructed test database can lead to semantically different queries returning identical results by chance. Furthermore, maintaining high-quality test databases for every new domain is expensive and slow.

Figure 1: An example of a false positive where redundant JOINs lead to identical outputs despite semantic differences in the SQL queries.

Methodology: FuncEvalGMN

We propose FuncEvalGMN, a database-free metric that treats SQL evaluation as a graph-matching problem. The pipeline consists of four main stages:

  1. Graph Construction (RelNode): Instead of using a standard Abstract Syntax Tree (AST), we parse SQL into a Relational Operator Tree (ROT), which we call a RelNode. This representation is based on the logical execution plan, making it much more robust to syntactic variations.
  2. Node Embedding: Nodes are categorized into Computing Nodes (operators like SELECT, JOIN) and Content Nodes (table/column names). We use a string-aware embedding for content nodes to distinguish between similar entities.
  3. Positional Encoding: To capture query hierarchy, we use Random Walk Positional Encoding (RWPE). We calculate positional embeddings by connecting predicted and gold graphs at "seed nodes," allowing the model to compare local substructures across queries.
  4. Graph Matching Network (GMN): The model uses a GMN with inner-graph attention (local context) and cross-graph attention (alignment between predicted and gold queries).
Figure 2: Overview of the FuncEvalGMN approach, from graph construction and node embedding to contrastive learning and graph matching.

Experimental Results

FuncEvalGMN was trained and evaluated on Spider-pair, a new dataset containing ~18K SQL pairs. The model consistently outperformed existing metrics like CodeBLEU and specialized verifiers like SPES. On the Spider-pair dev set, FuncEvalGMN achieved an AUC of 0.9750, significantly higher than other non-execution metrics.

Crucially, FuncEvalGMN demonstrated strong generalization capabilities. Despite being trained only on Spider, the model performed well on the BIRD and WikiSQL datasets. It also maintained high performance on complex queries involving JOIN, GROUP BY, and nested subqueries, often matching or exceeding the reliability of traditional test suite evaluations in these categories.

Conclusion

FuncEvalGMN provides a robust, scalable, and database-free alternative for evaluating Text-to-SQL models. By focusing on the relational algebra of the query rather than surface syntax or specific data outputs, it avoids the common pitfalls of existing metrics. Future work will involve incorporating more schema metadata, such as foreign keys and data types, to further enhance the model's semantic understanding.

Summary updated

BibTeX
@inproceedings{zhan2025towards,
  author = {Yi Zhan and Longjie Cui and Han Weng and Guifeng Wang and Yu Tian and Boyi Liu and Yingxiang Yang and Xiaoming Yin and Jiajun Xie and Yang Sun},
  title = {{Towards Database-Free Text-to-SQL Evaluation: A Graph-Based Metric for Functional Correctness}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=AzcvASg2id},
}
Figure