Manuscript Offprint
arXiv:2610.38294LASSO: An LLM-Agent Synthesized System for SQL Validation
ABSTRACT
The rise of Large Language Models (LLMs) has significantly advanced text-to-SQL capabilities, but generated queries may have errors. Test datasets are important for catching errors, but having only one or a few test datasets leaves many bugs undetected. Effective testing requires multiple test datasets that can expose subtle semantic bugs and edge cases. Recent work on test data generation and equivalence checking has focused on using constraint solvers. However, constraint-based approaches are slow and not scalable.
In this paper, we introduce LASSO, a framework inspired by XData, but designed to minimize the use of constraint solvers, instead prioritizing use of data generation strategies based on fast heuristics. LASSO deploys a number of "attack strategies", each targeting a specific class of semantic errors.
LASSO code was built using LLM-based agentic coding. We used carefully designed workflows and rules to support effective code generation and to avoid common code generation issues. A large number of internal test cases are included in LASSO to catch errors in generated code, and more are added when we extend LASSO, to avoid subsequent regressions. Our empirical evaluation across multiple benchmarks demonstrates that LASSO outperforms the state of the art, including XData, SpotIT, ParSEval, and Polygon.
PVLDB Reference Format:
Shreyas Jadhav and S. Sudarshan. LASSO: An LLM-Agent Synthesized System for SQL Validation. PVLDB, 20(1): XXX-XXX, 2027. doi:XX.XX/XXX.XX
1 INTRODUCTION
While Large Language Models (LLMs) can generate complex SQL queries from natural language, verifying the correctness of SQL queries remains challenging. Evaluating a query on a single or a few datasets (database instances) is often insufficient, as an incorrect query can coincidentally produce the expected output on those datasets. Validation of correctness requires multiple test datasets designed to expose subtle semantic bugs and corner cases.
Early data generators populated tables using only schemas and statistical distributions, in a query-independent fashion [3, 6, 10].
However, these approaches, as well as query-independent fuzzing-based approaches, do not provide any guarantees related to catching errors, or even generating non-empty results, on specific queries. Reverse Query Processing (RQP) [1] and QAGen [2] provided a symbolic approach to generate datasets on which query results satisfied desired properties. Qex [21] translated SQL predicates into constraints, which are processed by an SMT constraint solver (Z3) to generate a dataset on which the query has a non-empty result. None of these approaches addressed catching of errors.
The XData framework [4, 11, 17, 18] targeted dataset generation to catch errors in queries, and was shown to work well on moderately complex queries. The current XData system generates multiple datasets to catch different types of errors, by generating appropriate constraint sets for each dataset, and solving each constraint set using an SMT solver. Recent work on query equivalence refutation such as [7, 12, 20, 25] is also based on constraint generation. Fuzzing-based approaches such as [26] are inefficient and less effective in catching errors with complex queries.
We observed two main limitations of the existing work on SQL query validation: (1) scalability of time taken with increasing query complexity as well as variety of query features, and (2) efficacy at catching errors. Approaches based on modeling queries as constraints which are then solved using SMT solvers are not very scalable to large query sizes. Further each data type has to be separately handled. Efficacy at catching errors is also limited by human resource availability to model complex query constructs and data types, and to code different approaches for data generation to catch errors.
While LLMs can be used to directly generate test cases, e.g., [24], direct LLM dataset synthesis incurs significant per-query latency and API token costs, as shown in our performance evaluation.
In this paper, we explore the idea of using an LLM to create a system for generating test data for SQL validation that can handle a wide variety of SQL query features, as well as a wide variety of errors. Our goals and contributions include the following:
- Our first goal was to see if using agentic software development can generate a system that can perform better than existing systems, proving its effectiveness on a wide variety of benchmark schemas and queries. In Section 3 we describe how we built LASSO, an evolutionary framework heavily inspired by XData, designed to effectively leverage LLM-based agentic coding given an architectural setup, specific coding rules, and workflow instructions.
LASSO comprises a collection of small imperative functions, called "Attack Strategies", each targeting a specific class of semantic mutations by detecting structural patterns in a given query and synthesizing datasets designed to kill the corresponding mutants.
This work is licensed under the Creative Commons BY-NC-ND 4.0 International License. Visit https://creativecommons.org/licenses/by-nc-nd/4.0/ to view a copy of this license. For any use beyond those covered by this license, obtain permission by emailing info@vldb.org. Copyright is held by the owner/author(s). Publication rights licensed to the VLDB Endowment. Proceedings of the VLDB Endowment, Vol. 20, No. 1 ISSN 2150-8097. doi:XX.XX/XXX.XX
The attack strategy approach of LASSO makes it easy to handle new mutation types as they are discovered, by using an LLM agent to add new strategies or modify an existing strategy.
- Our second goal was to explore efficient execution, by minimizing use of expensive SMT solver calls. There is a tradeoff between the generality of relatively slow SMT solvers, and the efficiency of case-specific data generation approaches that are an alternative. Approaches that do not use SMT solvers, like Agenda [6] and the first version of XData [11] implemented several case-specific techniques such as adding/deleting tuples to ensure non-matching tuples for joins. However, they were later abandoned in favor of constraint-based approaches, which promise greater generality.
We wanted to see if despite avoiding SMT solver usage to a large extent, we can still create effective test cases by agentically creating a large number of case-specific approaches. To create a large pool of case-specific approaches, we relied on creating a large initial query test suite (details are provided in Section 3.2), and iteratively improving our code by prompting the LLM to add code to handle queries from a larger benchmark that were not initially handled.
There were two sub challenges in this task.
-
The first, to avoid regression as the code was iteratively improved, was handled by accepting changes only if they did not break existing successfully handled cases.
-
The second challenge was to ensure that the agent did not hard-code solutions that would not generalize beyond the specific query. We used a variety of instructions in the prompts/workflows to tell the agent to avoid such solutions. We also performed code walkthroughs to understand what was being implemented. We also used LLMs to generate documentation from code, which we could check manually. We rejected changes where we detected hard-coding (although we may have missed some cases).
-
In Section 4 we report on observations from a review of the generated code. Section 4.1 reports our observations on how base data (to generate non-empty results for a given query) is generated. Section 4.2 describes observations on attack strategy generation, after summarizing the initial attack strategies we provided to the agent.
-
Our third goal was to create a comprehensive evaluation benchmark combining queries from existing benchmarks. We observed some limitations of existing approaches, including problems introduced by non-deterministic queries. We describe our evaluation setup in Section 5, including a normalization scheme that rewrites existing benchmark queries, by modifying non-deterministic constructs to make them deterministic and rewriting queries to make them SQLite compatible (Section 5.1), and an execution result comparison setup (Section 5.2).
-
Our fourth goal was to carry out a detailed performance evaluation of our agentically developed system LASSO. Section 6 describes our performance evaluation. We created a unified benchmark, as described in Section 6.1, which
has 36,042 sanitized query pairs collected from eight different benchmark suites (BIRD [13], Calcite [25], Cubes [25], LeetCode [20, 25], Literature [25], XDataBM [17, 18], TPC-H [18], and LargeJoin [18]).
Our performance results (Section 6.2) show that LASSO not only handles significantly more cases, showing non-equivalence, than other approaches, but it is also significantly faster than state-of-the-art tools, including SpotIT, ParSEval, and Polygon, while improving significantly on runtimes as compared to the alternatives.
This validates our original hypothesis that it is possible to build an effective and efficient test data generation system for SQL query validation, agentically.
- Our final goal was to document the development process to understand what approaches worked, which may help in other similar agentic development processes. Our description of how LASSO was built (Section 3) and our observations on generated code (Section 4) provide some insight into this process. We believe that ensuring we had a large number of initial test cases, coupled with appropriate prompts and workflows, and iterative improvement on further test cases all contributed to the success of our agentic code generation process.
Our repository, https://gitlab.com/xdata/lasso, contains source code, prompts/workflow instructions, test cases and execution testing modules, scripts to run the experiments, and results.
2 BACKGROUND AND PROBLEM STATEMENT
Validating the semantic correctness of SQL queries is a challenge when writing complex SQL queries, for grading of student queries, and for evaluation of modern AI-driven text-to-SQL systems. Validating query correctness requires executing and evaluating the query on datasets that can distinguish subtle semantic differences between potential query variants. A single static database is often insufficient for this purpose: an incorrect query may return the expected output on the given test database instance, although it may return different results on other database instances. Consequently, validation of SQL queries requires generating multiple test datasets targeted to uncover potential semantic flaws (see, e.g., [17]).
In practice, test data generation for SQL queries is employed in two key scenarios:
(1) Standalone Query Testing: A user (manually or using an LLM) writes a query for a given task that is expressed in natural language, without a reference query. Multiple datasets can be generated from , to expose corner cases, such as boundary conditions, or null value handling, etc. Checking the query result against the expected result on each dataset helps test the correctness of the query.
(2) Equivalence Refutation: Scenarios where a query pair is available, such as in text-to-SQL evaluation, a candidate predicted query is evaluated against a reference query . The goal is to synthesize a counterexample dataset such that the execution results of the queries differ, proving non-equivalence. Recent work on query equivalence checking/refutation includes SpotIT [20], Polygon [25], and
ParSEval [7]. These were shown to perform better than earlier generation systems such as Cosette [9], SPEC [27], QED [22], and VeriEQL [12] in terms of query features handled.
Our focus is on stand-alone query testing, although the test datasets generated by our approach can also be used for equivalence refutation.
2.1 Problem Formulation and Mutation Testing
In this section we give a formal problem statement, based e.g. on [17]. Given a database schema and a SQL query , the result of executing on a database instance is denoted by .
A mutation of a query is a syntactically valid variant query representing a potential semantic error, for example, replacing a comparison operator (), altering a join type (e.g., changing an INNER JOIN to a LEFT OUTER JOIN), or not considering NULL values when they should have been considered. We refer to the variant query as a mutant. While syntactically different, some mutations may be semantically equivalent to ; non-equivalent mutations, however, represent genuine semantic bugs.
A test dataset is said to kill a mutation (or kill a mutant ) with respect to query if executing and on produces divergent results, i.e., . A test suite with multiple datasets is said to kill a mutant of query if the results differ on at least one of the datasets.
Given a query and schema , the goal of single-query test data generation is to construct a compact suite of test datasets that (ideally) kills all non-equivalent mutants of . In the context of equivalence refutation for a query pair , the objective is to synthesize at least one counterexample dataset such that , refuting their equivalence.
We note that SQL permits certain non-deterministic constructs that can result in different executions of the same or equivalent queries generating different results. Examples of such constructs include the use of the SQL LIMIT clause, and the use of time-dependent functions such as current date/time. Such queries can be made deterministic by rewriting the query, for example by having an ORDER BY clause that includes all output attributes wherever LIMIT is used, and replacing calls to time-dependent and random-value generation functions by functions returning fixed values.
We assume in the rest of our description that queries provide deterministic answers.
Terminology. In different contexts, different terms are used to describe queries and their variants. In this paper:
- We use Reference Query and Gold Query interchangeably to denote the query considered to be correct ( or ).
- We use Candidate Query, Prediction Query, and Mutation Query (or Mutant) interchangeably to denote the variant query ( or ) whose semantic equivalence to the reference query is being evaluated. In practice, such queries may be generated by text-to-SQL models, written manually (e.g., by students), or produced by other tools such as query optimizers or mutation generators.
2.2 The XData Approach
Since LASSO is based on the single-query test data generation methodology of XData [4, 11, 17, 18], we briefly outline the XData methodology below. Rather than requiring a query pair, XData utilizes a single query and its schema to generate a suite of datasets .
The methodology for single-query generation in XData follows a two-stage process:
(1) Baseline Non-Empty Dataset: The system first generates a baseline dataset designed to produce a non-empty result for the reference query (). This baseline dataset immediately kills all mutations that evaluate to an empty result on .
(2) Targeted Mutation-Killing Datasets: The system subsequently derives additional datasets specifically crafted to kill mutations across a targeted mutation space (such as comparison boundaries, join types, NULL handling, aggregates, and subqueries).
This methodology has evolved across two main paradigms:
-
Imperative and Algorithmic Generation: The initial version of XData [17] achieved this imperatively and algorithmically. It operated by first synthesizing a base dataset that satisfied the original query. It then systematically applied imperative modifications to this baseline, such as selectively omitting certain tuples or altering attribute values to kill specific mutants, while preserving database integrity constraints.
-
SMT-Based Constraint Solving: Subsequent versions of XData [4, 17, 18] accomplish this mutation-killing process by generating and solving constraints using an SMT solver (such as Z3). This approach models tables as arrays of tuples with constraint variables, generates constraints between the variables based on integrity and query constraints, and utilizes an SMT solver (such as Z3) to generate datasets satisfying the constraints.
One dataset is created using constraints designed to generate a non-empty query result. To kill a specific mutation, the system modifies the constraints at the targeted relational algebra node, by ensuring that the unmutated node yields a result that diverges from the mutated node.
While this SMT-driven approach provides formal mathematical guarantees, it can become computationally intensive as query complexity and the required number of tuples increase. Because relations and intermediate results are modeled as bounded arrays of symbolic tuples, increasing the maximum number of tuples introduces additional constraint variables and constraint predicates for each tuple. Consequently, synthesizing datasets for complex queries or scenarios requiring larger tuple bounds places a significant burden on the solver, often leading to performance overhead and timeouts.
3 THE LASSO FRAMEWORK
In this paper we present the LASSO framework, which is an extension of the XData approach. Like XData, LASSO retains a similar high-level methodology: given a query, generate a base data designed to provide non-empty results, and then generate multiple targeted datasets to kill mutations. Each such dataset is created using one approach from a collection of approaches that we call Attack Strategies. Revisiting the initial XData idea from [17], LASSO generates datasets algorithmically for the most part, minimizing reliance on SMT solvers.
LASSO was built using agentic coding, and designed to support a wide variety of SQL queries. Human input to the agents included the codebase architecture, pre-defined workflows and instructions, and a testing setup.
We used Google Antigravity for code development, with Gemini (versions 3.1 to 3.8) as the primary LLM, but also used Claude Opus 4.6 for some tasks. We used a Gemini AI Pro subscription over a 5 month period. The overall code development was done by just one person, and approx. 10k lines of code were generated.
LASSO uses a design approach of having separate attack strategies of each type of semantic bug, which are stored in separate files named based on the error being targeted. When an agent needs to modify code to handle a semantic error that is not currently caught, this approach makes it easy for the agent to navigate to the exact attack strategy files, and load only the required relatively small attack strategy code into context and work in isolation without affecting other attack strategies. This also makes it easy to support new type of bugs by creating corresponding attack strategy with applicability rules for the strategy, instead of having to work on a central large strongly-connected code base. A central large algorithm also means that an LLM agent has to load longer input context, which can result in performance degradation [14].
3.1 Setup for System Generation
The basic setup for generating the system consisted of two parts: an initial architecture, and a testing setup. We summarize the prompts used to create these two parts in this section. To generate meaningful data, we used the Faker library https://github.com/joke2k/faker.
We provided an initial scaffolding prompt explaining the core idea of the project. The prompt asked the coding agent to implement a basic architecture, by providing it a prompt for each component of the architecture. The prompts are summarized below.
Parsing Modules Prompt: "The DDL should be parsed using SQLglot and converted into a Schema representation containing tables, columns, data types, primary keys, UNIQUE constraints, NULLability, foreign keys, and CHECK constraints.
- While parsing columns, include metadata such as corresponding Faker domain, determined using heuristics such pattern matching on column names. (e.g., first_name to person-name generators, address to location/address generators, company to organization names). This metadata should be later used to come up with reasonably realistic looking domain-specific values using the Faker library."
Base Dataset Generator Prompt: "The base dataset generator module should be responsible to construct a base dataset that would produce non-empty results for the given query and schema."
Dataset Post-processing Prompt: "After dataset generation, this post-processing stage should ensure consistency. This includes
repairing potential foreign-key violations, etc. to avoid issues with loading the dataset and remain valid under the declared schema."
Attack Strategies Prompt: "Each attack strategy should focus on a specific class of semantic mutations (for example, inverted comparisons, omitted DISTINCT, or improper join types). Each attack strategy should be placed separately as a module in a separate file in the /attacks directory. All strategies should implement a common AttackStrategy interface with two core operations:
-
Is Applicable: Analyzes the parsed query AST to detect the presence of query features or constructs where the specific semantic error (mutation) targeted by the strategy can potentially occur.
-
Generator: Constructs one or more Dataset objects specifically designed to kill the corresponding mutant queries. Each generated dataset should contain the synthesized data, the strategy name, tags, and a description of the targeted mutation and dataset design."
We describe later the approach for creating datasets for each attack strategy that was used by the agent.
SQL Serialization Prompt: "The internal relational representation will be converted into executable SQL (INSERT INTO...) statements. Tables should be serialized in dependency order so that referenced tables are inserted before dependent ones. Values should be formatted appropriately for SQL types, including NULL handling, string escaping, etc."
Entry Point Prompt: "The main entry point should receive the DDL and SQL query, constructs schema and query representations. It should then execute the applicable attack strategies. Each strategy should produce one or more datasets, which are post-processed, serialized, and finally de-duplicated."
3.2 Testing Infrastructure
The success of agentic coding depends on having a strong test suite. We therefore created a large test suite as described below, and also created test utilities to verify that the generated datasets were catching errors.
When we subsequently found test cases which were not caught by our code, we added these to the test suite and prompted the agent to create appropriate attack strategies for the new test cases.
- Test Cases: To bootstrap development, we constructed initial test cases using the semantic error descriptions from NL2SQL-BUGs by Liu et al. [15]. The paper provides a detailed taxonomy and descriptions of SQL semantic errors categorized into 9 main categories and 31 subcategories. We passed the content to an LLM, prompting it to generate a representative multiple test cases for each subcategory. Each test case is a JSON file comprising the following properties:
-
A database schema DDL
-
A reference (gold) query passed for data generation
-
Expected Mutants to be Killed: An array of candidate queries representing semantic mutations (mutants). Each mutant query is associated with a description of the targeted mutation.
- Execution Tester: A separate module that executes both the reference query and each candidate mutant on the generated datasets to detect whether a given dataset refutes the equivalence, along with feedback on the execution details.
- Regression Suite: For each example that is successfully handled, a minimal test case is added to the regression suite, ensuring future modifications do not break previously supported functionality.
- Module Testing: Beyond execution testing, we checked that the core data generator module supports all test suite queries, and produces datasets yielding non-empty query results. Any failure results in a prompt to modify the code to properly handle the failed query.
- Helper Scripts:
- Run All: A dedicated script that prints the only feedback that is required for an agent, after running all the test cases. Such as only the failing cases if any.
- Improvements Finder: A script that automatically gathers examples that current codebase does not handle. The examples are grouped into two categories: (1) Other-Proved Non-Equivalent Queries: Finds instances where other tools (such as ParSEval, Polygon, SpotIT) successfully proved query non-equivalence but LASSO did not. Such confirmed non-equivalent queries are then used to improve the LASSO codebase. (2) Unknown Queries: Collects the remaining examples where none of the tools proved non-equivalence. For such queries we ask the LLM to check for equivalence directly using its own reasoning, and proceed to implement support in the codebase only if LLM determines non-equivalence.
3.3 Instructions and Workflows
After the initial scaffolding prompt, we created multiple re-usable prompts and instructions to extend the framework.
3.3.1 Rules.
Upon observation of coding agent's output and behavior over multiple iterations, we created a set of rules to guide the agent to avoid some common mistakes in future iterations and improve overall code generation quality through correct reasoning. We attached these rules to every prompt. Below, we explain the rules at a high level. (The full set of rules is available in our code repository.)
Reasoning related rules are designed to guide the LLM's reasoning to help in coming up with better quality solutions. For example, explicitly asking the LLM to consider reasoning about SQL semantics, relational algebra, and to create generalized solutions. The rules also instruct the LLM to first reason about exactly what type of data would be needed for a given case, what would be general steps to construct such datasets, reason whether the solution always work, or is any better choices available, and to check if the approach being considered would break existing features, etc.
Implementation related rules mention overall implementation style that the project should follow. Such as prioritizing programmatic, imperative algorithms over SMT solver formulations for dataset construction, while also outlining cases where it should consider using SMT solvers (e.g. complex expressions). We also include
rules telling the agent to avoid common implementation mistakes, for example, rules to make sure each strategy focuses on a single category of semantic errors, data generation is deterministic and targeted, without relying on simple random data generation, avoiding hard-coding of fixed values or benchmark specific assumptions, avoiding cluttering with redundant logic, etc.
Testing and debugging related rules emphasize testing and debugging through the prescribed test runner, verifying that the generated dataset exposes the intended semantic difference, rather than an unrelated discrepancy, steps to inspect the results, avoiding getting stuck running long scripts, etc.
3.3.2 Workflow.
For any failing benchmark instance or test cases, we provided the agent with a set of steps to follow to address the failure, which helped in avoiding token wastage. Below we highlight a few important workflow instructions. (Detailed workflow instructions are available in our code repository.)
(1) For a given example query pair and a schema, first reason whether the queries are semantically non-equivalent. If the queries are semantically equivalent, notify the user and terminate immediately.
(2) If the queries are semantically non-equivalent, modify only the src/ codebase to generate required test data for proving non-equivalence (NEQ) of query pairs in the example. If changes to testing scripts are required, first request a review from user.
(3) Before coding, create a minimal reproducible test case in the test_cases/ directory.
(4) Before implementation, verify directly (not generating by code) that the dataset would actually proves the queries are not equivalent.
(5) Implement a required generalized solution in src/
(6) Verify the functionality of base data generator that it produces non-empty results for the reference query and verify generating data using the mutant query produces non-empty results for the mutant.
(7) Verify the minimal test case passes after the implementation. and finally, verify the original provided example also passes.
(8) Ensure your solution did not cause any regressions, if there are any regression, you will re-consider your solution and fix them.
3.3.3 Routine Checks.
After each iteration, we manually skimmed through the generated diffs to inspect code quality and integrity. We looked for shortcuts such as modifying test runners, or hardcoding, etc. instead of implementing genuine data generation logic, and when we found it, we reverted the code changes, and later added instructions in the prompt to avoid recurrences.
3.3.4 Refactoring.
To maintain code quality and prevent architectural degradation across iterations, we conducted separate refactoring sessions. We provided LLM agents with refactoring rules, mainly to follow standard software engineering principles (e.g., separation of concerns, eliminating duplication, maintaining simplicity, ensuring observability, and preserving existing behavior).
In practice, coding agents occasionally hallucinated code or attempted shortcuts that violated core guidelines, such as generating random data, hardcoding values, or modifying testing scripts. As such issues were noticed, we updated the rules and workflows accordingly, to avoid those mistakes in future iterations. Combined with manual verification (especially for testing related code) and dedicated LLM-based routine code-reviews and refactoring sessions, the overall approach became effective for quickly supporting a large number of SQL features while maintaining system reliability.
3.4 LLM-Human Interaction
When implementing any code, the agent was asked to first suggest an implementation plan. The human then had a dialog with the agent to discuss the plan in more detail, and to suggest changes in the plan. Finally, the agent was asked to implement the code according to the mutually agreed plan. If any issues were found later, the agent was asked to check what could be the root cause. After suggestions on how the plan could be improved based on the causes found, the agent regenerated the relevant part of the code as per the refined plan. Some examples of interaction can be found in our repository.
4 OBSERVATIONS ON GENERATED CODE
The agent came up with high level strategies as well as detailed implementation approaches on its own. We reviewed the core modules and attack strategies, to gain insights and understand how the system actually works. Below, we provide high-level explanations of the working of base data generation (Section 4.1), and some of the attack strategies (Section 4.2) from the generated code. We also discuss below what could have been the literature/code source that inspired the agent to come up with the chosen approach.
4.1 Base Data Generation
The base dataset generation pipeline constructs datasets on which the given query produces a non-empty result. Below is an overview of the core sequential steps executed by the pipeline (details can be found in our code repository):
- Equivalence Class Construction. The code groups columns that must share identical values for the query to produce a non-empty result (e.g., join keys, foreign key pairs, aliased references to the same table column) into equivalence classes using a Union-Find structure.
Relation to Existing Techniques: Partitioning relational attributes into equivalence classes to capture join dependencies originates in query optimization and size estimation [19], and was subsequently adopted by constraint-based test data generators such as XData [4, 17] to consolidate predicates across equi-joins.
- Constraint Collection & Cardinality Analysis. For each equivalence class, all column constraints from the query and the schema on those columns are gathered into a single ColumnSpec record. This includes allowed and disallowed values, range bounds, uniqueness constraints, CHECK expressions, and flags indicating whether column is part of certain clauses such as GROUP BY or sub-query, etc. This step also computes , the minimum number of rows that may be needed for queries to return non-empty results.
Depending on the query complexity, the Z3 solver is used to estimate cardinality and to find seed values. However, the constraint formulations also make simple assumptions and use heuristics, some of which are sketched later in this section.
The approach of collecting constraints is implicit in earlier work on data generation, and may have been present in the corresponding code that was used to train the LLM.
- Column-Centric Value Resolution. Once constraints are aggregated and the target row count is determined, this stage synthesizes concrete values for columns of each equivalence class root. We observed that the code used several heuristics, and used SMT solver only in a few cases.
Examples of heuristic choices include choosing a starting value and incrementing it to generate values for integer valued primary key/unique valued columns, and having different starting point for different columns to detect wrong column selection errors.
For cases with constraints, heuristics included choosing a midpoint for bounded range constraints, directly choosing literals from query for satisfying equality conditions, and using small SMT formulations and calling z3 for resolution of arithmetic expressions across multiple columns.
Heuristic choices related to strings included generating strings by replacing wildcards in regex patterns with fixed values, trimming strings to satisfy length constraints, and using fake values from Faker library (keeping column names in mind) for unconstrained strings.
Aggregation related heuristics included assuming all tuples are in a single group to simplify data generation, and generating pairs of values equally spaced from a desired average value, to ensure the desired average is generated.
When constraints are violated, the code iterates over checking and heuristic repairs until valid assignments are found. The agent is asked to update the code when we find the code is not able to handle a given query.
We note that while there would certainly be some cases where heuristics fail, the performance results show that, overall, LASSO significantly outperforms other approaches in catching errors as well as in time taken. The heuristics are straightforward, but we could not find any specific source from which the LLM could have learnt the heuristics.
-
Row Assembly & Cross-Column CHECK Repair. Individual column value lists produced above are assembled into complete row records one column at a time. If certain value combination violates the check condition (e.g., end_date was generated earlier than start_date), the repair mechanism fix such violations heuristically as well (e.g., advancing end_date past start_date). Any adjusted candidate value is verified through the constraint checker against the dependent column's own ColumnSpec.
-
Augmentation. This step allows the base dataset to already detect mutations in outer joins (LEFT JOIN mutated to INNER JOIN) or anti-joins (NOT IN subqueries). The pipeline appends deliberately unmatched parent rows.
This strategy is somewhat similar to the approach of [11], which deletes tuples to get a similar effect. The strategy was observed to
Detailed explanations generated by LLM-assistance (manually verified) are provided in our code repository.
have been created in response to a prompt asking for minimization of datasets where possible.
- Post-Processing & Serialization. A final consistency pass prepares the datasets for execution: (1) Orphan Row Repair recursively creates parent rows for any child rows referencing missing foreign keys; (this high level idea was provided by a human via prompts, however the agent handles the implementation details such as transitively fixing foreign-key dependencies). (2) Uniqueness Enforcement deduplicates primary and unique keys; (3) Topological DAG Serialization writes out SQL INSERT statements in foreign-key dependency order; and (4) Dataset Deduplication removes duplicate datasets across attack strategies via canonical query hashing.
We note that the above step is applied also to datasets created by attack strategies.
4.2 Targeted Attack Strategies
Attack strategies either parameterize the base data generator pipeline (such as by injecting specific values or nulls for specified columns, or omitting specified tables from the generated dataset) or attack strategies may mutate the generated base dataset in certain ways to create a test dataset (e.g. as duplicating a row or modifying individual values).
4.2.1 Initial manually provided Strategies.
As part of the initial scaffolding prompt we provided the LLM agents with examples of basic attack strategies (only ideas, not actual implementation). These initial strategy ideas established the basic design pattern of inspecting the parsed SQL AST for applicable syntactic patterns and ideas to synthesize datasets for killing various mutations. For example, the NullHandlingAttackStrategy identifies nullable columns referenced in IS NULL checks and injects NULL values specifically into those columns. The DistinctAttackStrategy targets queries missing a DISTINCT modifier. It generates datasets with intentionally duplicated rows in the referenced tables. The ComparisonAttackStrategy targets comparison operator mutations (>, <, =, BETWEEN). It extracts all literal boundaries from the AST predicates and generates exact boundary values alongside slight offsets (e.g., ) using value injections.
These seed strategies served as examples demonstrating how an attack strategy remains lightweight and imperative, avoiding SMT formulations.
4.2.2 Observations on Agent-Generated Strategies.
The remaining attack strategies in LASSO were generated by the LLM agents to support our curated collection of initial test cases, created as described in Section 3.2. During iterative framework development, we initially aimed to support all of the failing test cases, one at a time. In response to supporting each failing test case, and taking hints from descriptions, the agent updated or created new targeted attack strategies. Some strategies may also have been created or evolved to support specific examples directly from existing benchmarks such as BIRD, XDataBM, etc. Below, we detail our observations and key insights for a representative subset of attack strategies generated by the agent:
- Join Attack Strategy: To kill join type mutants (such as mutating an INNER JOIN to a LEFT OUTER JOIN or vice versa) this strategy works as follows:
(1) Extract all distinct table aliases referenced in the query ().
(2) For each alias , invoke the base generator, specifying is to be suppressed. The generator suppresses tuple generation for table alias , producing a dataset where contains zero rows while all other tables remain populated with valid records.
The above strategy is directly based on the strategy in [11]. For example, to distinguish a LEFT JOIN from an incorrect INNER JOIN, the strategy generates a dataset that populates the left table (Dept) while leaving the right table (Emp) completely empty:
| Deptid | name |
|---|---|
| 1 | 'HR' |
| Empd_id | title |
|---|---|
| (0 rows / empty) | |
- Aggregate Null Attack Strategy: To kill mutants with incorrect NULL handling in aggregate functions (such as replacing COUNT(*) with COUNT(col) or unintended NULL propagation in SUM, AVG, MIN, MAX), this strategy injects NULL values into nullable aggregate arguments:
(1) It traverses aggregate function nodes in the query AST to find non-primary-key, nullable column references () (or all nullable columns for COUNT(*)).
(2) For each target (), the strategy synthesizes three datasets:
(a.) Only-Nulls Configuration: Generates two separate partitions—one standard group with valid non-null values, and a second group where every row has column set to NULL:
| Emp | |||
|---|---|---|---|
| id | dept | bonus | Partition |
| 1 | 'Eng' | 500 | Group 1 (Valid) |
| 2 | 'HR' | NULL | Group 2 (Only-Null) |
| 3 | 'HR' | NULL | Group 2 (Only-Null) |
(Differentiates COUNT (bonus) from COUNT(*).
b. Mixed-Nulls Configuration: Creates a single group containing both valid and NULL values for column . It forces NULL rows and non-null rows to share identical GROUP BY keys (using value_injections).
c. Standalone-Null Dataset: Emits an isolated dataset containing strictly rows where column is NULL without any non-null groups:
| Emp | |||
|---|---|---|---|
| id | dept | bonus | |
| 1 | 'HR' | NULL | |
| 2 | 'HR' | NULL | |
(Tests scalar aggregations and subqueries (e.g., SELECT AVG(bonus) FROM Emp), verifying that the aggregate correctly evaluates to NULL rather than defaulting to 0.)
- Group-By Attack Strategy: To kill mutants related to GROUP BY clauses, this strategy works in three different ways:
(1) Hierarchical Prefix Synthesis (for queries with GROUP BY): When a query groups by multiple columns (e.g., dept and role), a mutant query might accidentally drop trailing grouping columns (e.g., grouping only by dept). To catch this, the strategy generates rows that share the same leading grouping keys (using value injections) but have distinct values for subsequent grouping keys:
| Emp | ||
|---|---|---|
| id | dept | role |
| 1 | 'Eng' | 'Dev' |
| 2 | 'Eng' | 'QA' |
(A query grouping by both (dept, role) partitions these rows into 2 distinct groups (2 output rows). A mutant query grouping only by dept collapses them into 1 single group (1 output row).)
(2) Empty Relation Synthesis: Synthesizes an empty dataset containing zero tuples (0 rows) across all tables:
(In SQL, a scalar aggregate without GROUP BY over an empty table returns exactly 1 row containing default or NULL values ((∅)). Conversely, a query with an explicit GROUP BY over an empty table produces 0 groups (0 rows). This output asymmetry kills mutants with missing or spurious GROUP BY clauses.)
(3) Multi-Group Synthesis for Scalar Aggregations: For global scalar aggregate queries, a mutant might incorrectly introduce an unnecessary GROUP BY clause. The strategy generates multiple rows with distinct attribute values:
| Emp | ||
|---|---|---|
| id | dept | salary |
| 1 | 'Eng' | 1000 |
| 2 | 'HR' | 800 |
(The correct scalar aggregate combines all rows into 1 global summary row, whereas a mutant that adds GROUP BY dept splits the output into multiple separate group rows (2 rows).)
- Null in Subquery Attack Strategy: In SQL, WHERE col NOT IN (subquery) type of queries may introduce subtle Three-Valued Logic (3VL) bugs: if the subquery returns even a single NULL value, the entire NOT IN condition evaluates to UNKNOWN (treated as false in WHERE), causing the query to return an empty result. This strategy synthesizes a dataset where the subquery explicitly contains a NULL value in the join column:
(1) Traverses the query AST for NOT IN subqueries, identifies the projected subquery column, and verifies via the schema that the column is nullable.
(2) Invokes the base generator to synthesize valid outer rows satisfying outer predicates and joins.
(3) Clones the subquery AST and invokes the generator with a NULL value injection on the projected column, generating a subquery record with a NULL join key.
(4) Combines the outer records and the null-injected subquery records into a unified dataset.
For example, when evaluated on the dataset below where student_id in ExamScore is NULL:
| Student (Outer) | |
|---|---|
| id | name |
| 1 | 'Alice' |
| ExamScore (Inner Subquery) | |||
|---|---|---|---|
| exam_id | student_id | score | |
| 101 | NULL | 85 | |
The reference query WHERE id NOT IN (SELECT student_id FROM ExamScore) evaluates to UNKNOWN and returns an empty result, whereas a mutant using LEFT JOIN ... WHERE ExamScore.student_id IS NULL treats the row as unmatched and returns 'Alice', successfully killing the mutant.
- Alternative Column Attack Strategy: To kill column misselection mutants where a candidate query mistakenly filters on a type-compatible sibling attribute in the same table instead of the intended predicate column, this strategy transposes query literals across sibling columns:
(1) Scans the table schema for alternative non-primary-key columns sharing data type compatibility with the predicate column, using attribute name similarity heuristics. (e.g., Digit Substitution such as phone1 → phone2, Affix Matching such as ship_city → bill_city, and similarly with prefixes/suffixes such as alt_and_other).
(2) Literal Transposition Synthesis: Generates a dataset using value_injections that assigns the reference query's filter literal (e.g., 'Paris') to the sibling column while assigning a distinct non-matching value ('London') to the original predicate column:
| Orders | |||
|---|---|---|---|
| id | cust_id | ship_city | bill_city |
| 1 | 100 | 'London' | 'Paris' |
In total, the LASSO codebase implements 37 distinct attack strategy classes. A breakdown of the top attack strategies and their corresponding refutation shares in evaluation is provided in Table 6.
Relation to Existing Techniques: Selecting values near predicate boundaries is a known pattern from boundary value analysis [16] and domain testing principles [23], which systematically select ON and OFF boundary points. LASSO attack strategies include some techniques similar to those described in AGENDA [5, 6] such as filling duplicate values, forcing NULLs, and random selection of intermediate values from the intervals (LASSO chooses intermediate values deterministically). The alternative column attack strategy has some connections to fuzzy column matching used for schema matching.
5 EVALUATION SETUP
Execution-Test (EX) is widely used in modern text-to-SQL benchmarks, such as BIRD, as the primary metric for determining semantic equivalence between two SQL queries. In standard EX, a gold query and a candidate predicted query are executed on an already populated database and considered non-equivalent (i.e. the prediction query is erroneous) if the query results are different.
However this approach ignores several subtle nuances that we address in our testing module EX+, an execution testing environment organized into two complementary phases: (i) pre-execution query normalization, and (ii) execution testing.
5.1 Pre-Execution Query Normalization
Before queries are passed to test data generation tools or executed, EX+ normalizes the input query AST using sqlglot to fix two sources of non-determinism.
-
Time and Randomness Normalization
- Problem: Queries invoking temporal functions (e.g., NOW(), CURRENT_TIMESTAMP) or stochastic functions (e.g., RANDOM()) yield different outputs across execution calls, which can cause spurious mismatches on identical queries as well as on equivalent queries.
- Check Implemented: EX+ transforms the query AST to rewrite temporal functions and string arguments (such as 'now') into a shared, frozen UTC timestamp, and seeds stochastic functions with a fixed seed.
-
Sorting Tie-Breaking
- Problem: When an ORDER BY clause sorts on attributes containing duplicate values (ties), SQL engines can return rows in physical orders depending on row layout and chosen execution plan. Consequently, two functionally equivalent queries can return identical rows in different sequences. When combined with a LIMIT clause, identical or equivalent queries may potentially return different results.
- Check Implemented: EX+ augments the AST's ORDER BY clause by appending schema primary keys or unique columns (falling back to projected expressions) along with NULLS LAST to resolve sorting ties and produce stable, reproducible row ordering.
Without the above normalization, execution testing may potentially report even identical but non-deterministic queries as non-equivalent.
5.2 Execution Result Comparison
During execution testing on generated datasets, EX+ matches execution results and provides structured diagnostics through the following checks:
- Order and Multiset Sensitivity: When the reference query contains an ORDER BY clause, EX+ enforces strict list ordering. Otherwise, it compares results as unordered multisets using row frequency counters, accounting for discrepancies in duplicate tuple counts.
- Permutation-Aware Column Matching: Standard query output comparison requires exact positional column matching and equal column counts. However, text-to-SQL predictions may project columns in an alternate valid order (e.g., (age, name) instead of (name, age)) or project extra columns that might still fulfill the prompt. EX+ supports a permutation-aware column matcher that evaluates whether any column permutation of the candidate query results matches that of the gold query results, and optionally accommodates extra columns. We note that the option did not have any significant impact on our benchmark queries, although it may be useful in other scenarios.
- Strict Type Checking: Standard Python comparators rely on loose equality where distinct primitive types are coerced
(e.g., evaluating 1 == 1.0 or 1 == True as true). While some applications may not require strict type checking, for others distinguishing data types is critical, such as for distinguishing boolean status flags from numeric codes, distinguishing a string containing numeric value from true numeric value, etc.
EX+ includes a configurable option that, when enabled, wraps each projected value with its runtime data type to prevent type coercion across integers, floats, strings, and booleans.
-
Structured Diagnostics: Rather than returning an opaque binary pass/fail flag, EX+ categorizes evaluation outcomes into fine-grained status codes (e.g. distinguishing true non-equivalent pairs, and non-equivalent pairs only due to differences in column ordering), failure reasons (e.g. row counts mismatch, values mismatch, etc.), and error classes (e.g. errors in query execution, schema loading, or dataset loading).
-
Reproducible Counterexample Serialization Whenever a counterexample dataset refutes equivalence, EX+ automatically serializes a self-contained SQL script containing schema DDL, foreign-key safe data loading statements, both queries, and formatted execution outputs in block comments for immediate reproduction.
5.3 Cross Checking Strategies
In our default, single-query data generation approach, test datasets are typically generated using only the reference query. These datasets are then used to evaluate candidate predicted queries.
Datasets generated from a reference query may not trigger the specific logical pathways or boundary conditions of a predicted query. For instance, consider the following queries:
-
Gold Query: SELECT name FROM students
-
Predicted Query: SELECT name FROM students WHERE age <> 25
Because the gold query lacks the age <> 25 predicate, the datasets generated solely from the gold query may not generate records with age = 25 that are needed to show non-equivalence of the two queries.
To address this, we utilize Two-Way Data Generation [4, 7]. If a candidate predicted query survives the datasets generated from the reference query, we use the predicted query to generate a supplementary set of "Prediction Datasets." The comparison attack strategy operating on the predicted query will synthesize boundary data with age = 25, catching the above error.
We can discover more non-equivalent queries through cross-checking strategies. In practical settings, such as educational autograding or evaluating multiple text-to-SQL models on a benchmark, evaluators test multiple predictions against a reference query , and there are multiple queries one any given schema . Cross-checking pools and reuses test datasets across queries for a given schema, increasing the likelihood of exposing bugs, as demonstrated by experimentation (Table 8).
Hierarchical Cross-Checking Scopes. Let an evaluation instance over database schema consist of a reference query and candidate predictions , forming candidate query pairs . Across an entire benchmark, let denote the set of all queries (both reference and predicted) that share schema .
For any query , let denote the suite of test datasets synthesized by generating datasets from (using LASSO's baseline and attack strategies). Unlike single-query testing where each query is evaluated solely on its own generated data, cross-checking evaluates candidate query pairs across four hierarchical levels:
(1) Level 1 (Gold-Only): Datasets are generated solely from the reference query:
All candidate pairs are tested against and checked for differences in results.
(2) Level 2 (Pairwise Cross-Checking): Datasets are generated from both queries in the pair:
In an optimized setting, only the surviving (non-refuted) candidate query pairs after Level 1 are used to generate additional datasets based on the prediction query.
(3) Level 3 (Instance-Level Sibling Pool): Datasets are generated for all candidates (regardless of whether surviving or already killed) in and pooled:
(4) Level 4 (Cross-Instance Schema Pool): Datasets generated across all queries on schema are pooled:
6 PERFORMANCE EVALUATION
To evaluate the effectiveness of LASSO, we compare it with recent test data generation tools on our unified benchmark. All evaluation and benchmarking scripts were manually reviewed and checked using unit test cases, to ensure that the experimental results and timings are correct and reliable.
We note that LASSO and XData can be used in situations where only one query is available, e.g., a query written by a programmer or a text-to-SQL system, which needs to be validated by using test data. The alternatives that we compare with, however, check for equivalence of a pair of queries. To check for effectiveness of our data generation, we compare LASSO with the alternatives in terms of its effectiveness in detecting non-equivalence of query pairs.
6.1 Unified Benchmark
We constructed a unified benchmark integrating query pairs and schemas across eight benchmark sources, which includes benchmarks used for originally testing each individual tool. We compared against: BIRD [13] (10, 153 pairs), Calcite (Calc) [25] (221 pairs), Literature (Lit) [25] (51 pairs), Cubes [25] (3, 106 pairs), LeetCode (LC) [20, 25] (21, 960 pairs), XDataBM (XBM) [17, 18] (343 pairs), TPC-H(TPX) [18] with manually created mutations by XData (198
Table 1: Refutations on the Unified Benchmark (- means tool had many errors, * means we did not run the tool due to cost)
| Tool | Benchmark | Total(36,042) | |||||||
|---|---|---|---|---|---|---|---|---|---|
| BIRD(10,153) | Cubes(3,106) | LC(21,960) | Lit(51) | Calc(221) | XBM(343) | TPX(198) | LJ(10) | ||
| SpotIT | 1,048 | 576 | 1,414 | 15 | 1 | 0 | 11 | 3 | 3,068 |
| Polygon | 3,399 | 558 | 4,752 | 18 | 1 | 0 | 61 | 5 | 8,794 |
| ParSEval | 5,800 | 1,044 | 5,244 | 16 | 6 | 120 | 122 | 6 | 12,358 |
| XData | - | - | - | - | 2 | 302 | 135 | 4 | - |
| XData-CC | - | - | - | - | 4 | 327 | 141 | 4 | - |
| Gemini | * | * | * | * | * | * | 186 | 10 | * |
| LASSO | 6,255 | 2,320 | 6,984 | 19 | 9 | 318 | 159 | 10 | 16,074 |
| LASSO-CC | 6,685 | 2,466 | 11,279 | 22 | 9 | 324 | 162 | 10 | 20,957 |
pairs), and LargeJoin (LJ) [18] (10 pairs). In subsequent evaluation tables, these benchmark names are abbreviated accordingly.
We implemented some pre-processing and sanitization and used the normalized version of queries (generated as described in Section 5.1, and made SQLite/PostgreSQL compatible, as required, using SQLglot) to prepare the inputs as required for various other tools. We eliminated query pairs where we could trivially determine equivalence, syntactically invalid queries, duplicate prediction queries, etc. (The exact reasons for eliminations are available in our repo.) Our final unified benchmark has 36,042 query pairs.²
6.2 Performance Results
We compared LASSO with four state-of-the-art test data generation tools: SpotIT [20], Polygon [25], ParSEval [7], and XData [17], as well as direct data generation using Gemini 3.8 Flash. We also compared extensions LASSO-CC and XData-CC of LASSO and XData, which perform pairwise cross checking by generating data from both queries instead of from only one query.
We note that since the Bird, Cubes, LeetCode and Literature benchmarks are SQLite/MySQL based, whereas XData works only on the PostgreSQL dialect of SQL, we did not run these benchmarks on XData.
To avoid cases where data generation takes a very long time on some queries, we set a timeout of 30 seconds for data generation for each query pair being compared (SpotIT, Polygon, ParSEval and Gemini). For XData and LASSO, datasets are generated from one query and used against multiple candidate queries. To make the comparison fair, we set the timeout for XData to 1 minute (for generating all datasets), but left it as 30 seconds for LASSO since LASSO was very fast anyway.
Table 1 presents the number of refutations per benchmark across all 36,042 query pairs. For tools that support only a subset of benchmarks (such as XData on Calcite and XDataBM), unsupported benchmarks are marked with a dash (-), while * (for the case of Gemini) denotes that we did not run the experiment due to the high cost of running on thousands of query pairs.
²Two queries can also be proven non-equivalent if a dataset causes one query to execute successfully while triggering a runtime execution error in the other (for example, a subquery returning more than one row, a division by zero, or a numeric overflow). However, identifying such specific errors is not handled in our testing scripts and presented results only consider NEQ only when both queries execute successfully against the dataset and produce different output results.
Table 2: Refutations on Common Supported Queries
| Tool | Benchmark | Total(17,868) | |||||||
|---|---|---|---|---|---|---|---|---|---|
| BIRD(7,508) | Cubes(1,734) | LC(8,303) | Lit(42) | Calc(96) | XBM(139) | TPX(36) | LJ(10) | ||
| SpotIT | 965 | 387 | 1,165 | 14 | 1 | 0 | 11 | 3 | 2,546 |
| Polygon | 3,223 | 402 | 2,089 | 18 | 0 | 0 | 35 | 5 | 5,772 |
| ParSEval | 4,111 | 442 | 2,536 | 16 | 4 | 100 | 14 | 6 | 7,229 |
| XData | - | - | - | - | 1 | 116 | 22 | 4 | - |
| XData-CC | - | - | - | - | 3 | 130 | 28 | 4 | - |
| Gemini | * | * | * | * | * | * | 36 | 10 | * |
| LASSO | 4,385 | 1,221 | 2,702 | 18 | 6 | 130 | 21 | 10 | 8,493 |
| LASSO-CC | 4,629 | 1,304 | 3,874 | 21 | 6 | 134 | 21 | 10 | 9,999 |
Table 3: Refutations on Queries Excluding ORDER BY and LIMIT
| Tool | Benchmark | Total(23,586) | |||||||
|---|---|---|---|---|---|---|---|---|---|
| BIRD(7,825) | LC(15,118) | Lit(51) | Calc(207) | XBM(343) | TPX(32) | LJ(10) | |||
| SpotIT | 624 | 1,177 | 15 | 0 | 0 | 0 | 3 | 1,819 | |
| Polygon | 2,730 | 3,363 | 18 | 1 | 0 | 15 | 5 | 6,132 | |
| ParSEval | 4,506 | 3,890 | 16 | 5 | 120 | 18 | 6 | 8,561 | |
| XData | - | - | - | 1 | 302 | 25 | 4 | - | |
| XData-CC | - | - | - | 3 | 327 | 25 | 4 | - | |
| Gemini | * | * | * | * | * | 32 | 10 | * | |
| LASSO | 4,681 | 5,340 | 19 | 6 | 318 | 19 | 10 | 10,393 | |
| LASSO-CC | 4,944 | 7,952 | 22 | 6 | 324 | 19 | 10 | 13,277 | |
Table 4: Average Time per Refutation (seconds) (36,042 pairs)
| Tool | Benchmark | Overall | |||||||
|---|---|---|---|---|---|---|---|---|---|
| BIRD | Cubes | LC | Lit | Calc | XBM | TPX | LJ | ||
| SpotIT | 10.91 | 2.12 | 53.78 | 7.39 | 98.64 | - | 117.87 | 47.25 | 29.51 |
| Polygon | 0.73 | 1.03 | 3.57 | 5.21 | 189.10 | - | 1.51 | 0.53 | 2.33 |
| ParSEval | 4.28 | 2.11 | 3.25 | 11.55 | 41.10 | 2.15 | 16.66 | 22.59 | 3.79 |
| XData | - | - | - | - | 542.91 | 0.96 | 2.66 | 110.97 | - |
| XData-CC | - | - | - | - | 465.27 | 1.37 | 5.81 | 112.68 | - |
| Gemini | * | * | * | * | * | * | 7.33 | 5.95 | * |
| LASSO | 0.43 | 0.19 | <0.01 | 2.04 | 1.42 | 0.02 | 0.22 | 0.10 | 0.20 |
| LASSO-CC | 1.75 | 0.32 | 0.31 | 3.33 | 2.83 | 0.03 | 2.67 | 0.10 | 0.79 |
It can be seen that LASSO performs significantly better than the alternatives across all benchmarks, except XDataBM where XData-CC performed marginally better, and LASSO-CC improves further on LASSO. Gemini also performs very well, matching or surpassing LASSO for TPC-H (TPX) and LargeJoin (LJ) in terms of refutations, but as we discuss later, is much slower than LASSO.
Table 2 reports the refutation counts on the commonly supported subset (17,868 query pairs). Here, if at least one of the tools encounters an error during data generation, for e.g. because of SQL operators that the tool is not designed for or lacks support, or parser exceptions, etc., then the corresponding benchmark instance is excluded from results of all the tools. Even on this benchmark, we see that LASSO and LASSO-CC outperform the alternatives overall. ParSEval and Polygon close the gap here, implying that there are many queries they don't support, which LASSO supports, although on queries that they do support, they do well at refutation.
Table 3 presents refutation counts on the 23,586 query pairs where neither the reference query nor the candidate prediction contains an ORDER BY or LIMIT clause, since some tools may not handle ordering. Again, LASSO and LASSO-CC were substantially better than the alternatives, except on XDataBM where XData-CC was marginally better. We note that the Cubes benchmark is eliminated here because all of the queries have an ORDER BY clause.
Execution time: Table 4 reports the average time per refutation (in seconds) achieved across each benchmark, as well as overall. For each tool and benchmark, this metric is computed as the total tool execution time spent on that benchmark divided by the number of confirmed refutations achieved (Execution Time/Refutations). The recorded time accounts only for tool execution time, and does not include the external time used for execution testing (loading datasets and executing queries).
It can be seen that LASSO has the lowest execution time for each benchmark, and overall.
Solver-based tools (such as SpotIT, ParSEval, and XData) frequently time out or require substantial generation time when solving constraints for large or complex queries. For the Large Join query benchmark (which has queries with 2, 4, 7, 8, and 10 relations being joined, with two instances of each size), SpotIT and ParSEval timed out on 4 of 10 LJ queries, while XData-CC timed out on 6 of them. We note that although Polygon had a relatively small execution time on LJ, it failed to refute 5 out of 10 query pairs.
Direct test data synthesis using an LLM (Gemini 3.8 Flash) successfully generates refutation datasets for all 10 LJ query pairs, but takes a total of 59.5s, with 16K output and 6.3K input tokens (cost $0.053).
In contrast, LASSO leveraging fast heuristic, successfully generates datasets on all 10 queries in just 1.0 second, and all 10 query pairs were refuted.
Effectiveness on Complex Queries/Unseen Schemas: Does LASSO generalize across schemas and complex queries that were not used during framework development is an important question. We note that the LJ and TPC benchmarks were not used during development, and thus unseen by the code base.
We also evaluated LASSO on the BEAVER enterprise data warehouse (dw) suite [8], which has relatively complex queries, and which also we did not use during development. Results are shown on 10 queries from the dw schema.³
The results are summarized in Table 5, ParSEval produces non-empty datasets for only 5 of the 10 queries (50.0%), timing out (> 30s) on the other 5 queries (206.3s total time) due to SMT constraint solver bottlenecks on complex CTEs. Direct LLM dataset generation using Gemini 3.8 Flash (gemini-3.8-flash) successfully synthesizes non-empty datasets for all 10 queries (100.0%), taking 43.4s (15K input and 9k output tokens, total cost $0.045) using API calls. In comparison, LASSO generates valid non-empty test datasets for 9 of the 10 queries (90.0%) in just 0.16s.
For TPX benchmark on Gemini, across 198 query pairs, Gemini took approx. 300k input and 300k output tokens for a total cost of $1.35.
³Getting results on the full set of schemas and queries after making them SQLite compatible is ongoing work.
Table 5: Data Generation on BEAVER Benchmark (10 Queries, dw Schema)
| Tool | Non-Empty | TIMEOUT | Total Time (s) |
|---|---|---|---|
| ParSEval | 5 / 10 | 5 | 206.3 |
| Gemini 3.8 Flash | 10 / 10 | 0 | 43.4 |
| LASSO | 9 / 10 | 0 | 0.16 |
Table 6: Effectiveness of Top 20 Individual Attack Strategies
| # | Attack Strategy | % of Refutations |
|---|---|---|
| 1 | TableAttackStrategy | 8.32% |
| 2 | BaseDatasetStrategy | 7.98% |
| 3 | JoinAttackStrategy | 7.77% |
| 4 | ComparisonAttackStrategy | 6.99% |
| 5 | GroupByAttackStrategy | 6.45% |
| 6 | AggregateNullAttackStrategy | 6.37% |
| 7 | MissingPredicateAttackStrategy | 6.26% |
| 8 | JoinCardinalityAttackStrategy | 5.46% |
| 9 | AggregateFunctionAttackStrategy | 4.46% |
| 10 | OrderingAttackStrategy | 3.97% |
| 11 | DuplicatesAttackStrategy | 3.82% |
| 12 | NullableJoinAttackStrategy | 3.57% |
| 13 | StringLiteralAttackStrategy | 3.54% |
| 14 | RedundantDistinctAttackStrategy | 3.19% |
| 15 | DistinctAttackStrategy | 2.52% |
| 16 | StringLiteralCaseAttackStrategy | 2.27% |
| 17 | JoinTypeAttackStrategy | 1.88% |
| 18 | DivisionAttackStrategy | 1.64% |
| 19 | AlternativeColumnAttackStrategy | 1.50% |
| 20 | AggregateMissingDistinctAttackStrategy | 1.43% |
Generated Dataset Statistics: For each data generation call, LASSO generates a mean of 20.1 datasets (median: 16.0, standard deviation: 19.5). Furthermore, across all refutations, the number of tuples per dataset generated by LASSO has a mean of 5.3 rows (median: 3.0 rows, standard deviation: 31.5 rows). The vast majority of generated counterexamples contain only a few records, they remain concise and easy to inspect for debugging.
Interestingly, one of the benchmark queries (Literature Q46) with a constraint of count(FID) > 1000 required at least 1000 rows in the dataset. Only LASSO was able to successfully generate the dataset.
LASSO Attack Strategy Effectiveness: To analyze the effectiveness of different LASSO attack strategies, we generated datasets from the gold queries, with each dataset associated with the strategy that generated it. We then executed all query pairs on these datasets.
Table 6 presents the effectiveness breakdown of the top 20 attack strategies (sorted in descending order of refutations), reporting the percentage share of total strategy kills contributed by each strategy.
The most effective strategy, TableAttackStrategy injects parent rows that have no matching child rows, to kill mutants that substitute a table by another, omit a table, or add spurious outer joins to a parent table. The BaseDatasetStrategy generates datasets to provide non-empty results on the query, killing all mutants that give empty results. JoinAttackStrategy generates multiple datasets having one empty table at a time to detect SQL queries that use the wrong JOIN type and incorrectly include or exclude rows. The DivisionAttackStrategy generates datasets to produce 0, negative, or NULL values for division denominators. A detailed explanation of each of the attack strategies is available in our repo.
Table 7: Refutation Origin in LASSO-CC
| Benchmark | Total | Gold | Pred (CC) | Gain |
|---|---|---|---|---|
| BIRD | 6,685 | 6,255 | 430 | +6.9% |
| Cubes | 2,466 | 2,320 | 146 | +6.3% |
| LeetCode | 11,279 | 6,984 | 4,295 | +61.5% |
| Literature | 22 | 19 | 3 | +15.8% |
| Calcite | 9 | 9 | 0 | +0.0% |
| XDataBM | 324 | 318 | 6 | +1.9% |
| TPC-H | 162 | 159 | 3 | +1.9% |
| LargeJoin | 10 | 10 | 0 | +0.0% |
| Overall | 20,957 | 16,074 | 4,883 | +30.4% |
Table 8: Refutation Performance Across Cross-Checking Levels (100 BIRD Instances, 664 Query Pairs Across 11 Schemas)
| Level | Dataset Scope | Killed | Frac. | Marg. Gain | Time (s) |
|---|---|---|---|---|---|
| Level 1 | Gold-Only () | 411 | 61.9% | - | 1.80 |
| Level 2 | Pairwise Gold + Pred () | 431 | 64.9% | +20 (+3.0%) | 2.89 |
| Level 3 | Instance Pool () | 436 | 65.7% | +5 (+0.8%) | 5.08 |
| Level 4 | Schema Pool () | 439 | 66.1% | +3 (+0.5%) | 55.33 |
| Net Gain | Full Cross-Checking | 439 | 66.1% | +28 (+4.2%) | 65.09 |
Performance of Cross-Checking Strategies: To evaluate the effectiveness of pair-wise cross-checking (LASSO-CC), we compared the number of datasets generated from gold queries that could refute equivalence, versus the incremental benefit of generating datasets from prediction queries when the gold query generated datasets failed to refute equivalence. Table 7 shows these results across each benchmark suite. Overall, the incremental gain due to cross-checking was over 60% for LeetCode, and 30% overall although less for other benchmarks.
To evaluate the impact of all the four cross-checking strategies (Section 5.3), we tested 100 BIRD benchmark instances spanning 11 database schemas sequentially from Level 1 to Level 4, recording the first level at which each non-equivalent mutant is killed and the execution runtime. As observed from Table 8, using the generated test datasets for queries other than the reference query makes it possible to discover more non-equivalent query pairs, though at the expense of higher evaluation time due to the substantially larger pool of test datasets evaluated.
7 CONCLUSION
In this paper we described how we built the LASSO test data generation system using agentic coding. We demonstrated that it is possible to generate test data using case-specific techniques with low execution time, and yet refute more query pairs than existing techniques. The approach we used for creating LASSO agentially can be useful for other similar projects in future.
An important area of future work is to test and extend LASSO to handle queries of high complexity, beyond what we have in the current benchmarks.
Another area of future work in the context of text-to-SQL is to explore how to use generated test datasets and user feedback on correctness of results to guide the LLM to correct errors in the generated SQL. Expanding attack strategies currently requires human oversight, since agents are observed to violate rules such as avoiding hard-coded constants, random data generation etc. How to use agents to detect and prevent such violations is an area of future work. Some queries result in generation of a large number of datasets. Minimizing the number of datasets is another area of future work.
REFERENCES
[1] Carsten Binnig, Donald Kossmann, and Eric Lo. 2007. Reverse Query Processing. In 2007 IEEE 23rd International Conference on Data Engineering. 506–515. doi:10.1109/ICDE.2007.367896
[2] Carsten Binnig, Donald Kossmann, Eric Lo, and M Tamer Özsu. 2007. QAGen. In Proceedings of the 2007 ACM SIGMOD international conference on Management of data (Beijing China). ACM, New York, NY, USA. https://doi.org/10.1145/1247480.1247520
[3] Nicolas Bruno and Surajit Chaudhuri. 2005. Flexible database generators. In Proceedings of the 31st International Conference on Very Large Data Bases (Trondheim, Norway) (VLDB '05). VLDB Endowment, 1097–1107. http://www.vldb.org/conf/2005/papers/p1097-bruno.pdf
[4] Bikash Chandra, Bhupesh Chawda, Biplab Kar, K. V. Reddy, Shetal Shah, and S. Sudarshan. 2015. Data generation for testing and grading SQL queries. The VLDB Journal 24, 6 (Dec. 2015), 731–755. doi:10.1007/s00778-015-0395-0
[5] David Chays. 2004. Test Data Generation for Relational Database Applications. Ph.D. Dissertation. Polytechnic University, Brooklyn, New York. Department of Computer and Information Science, TR-CIS-2005-01. https://cs.ecu.edu/gudivada/research/papers/Database-Test-Data-Generation.pdf
[6] David Chays, Yuetang Deng, Phyllis G. Frankl, Saikat Dan, Filippos I. Voko-los, and Elaine J. Weyuker. 2004. An AGENDA for testing relational database applications. Software Testing, Verification and Reliability 14, 1 (2004), 17–44. arXiv:https://onlinelibrary.wiley.com/doi/pdf/10.1002/stvr.286 doi:10.1002/stvr.286
[7] Chunyu Chen, Zhengjie Miao, Yong Zhang, and Jianman Wang. 2025. ParSEval: Plan-Aware Test Database Generation for SQL Equivalence Evaluation. Proc. VLDB Endow. 18, 11 (July 2025), 4750–4762. doi:10.14778/3749646.3749727
[8] Peter Baile Chen, Weiyue Li, Fabian Wenz, Yi Zhang, Nesime Tatbul, Michael J. Cafarella, Çagatay Demiralp, and Michael Stonebraker. 2024. BEAVER: An Enterprise Benchmark for Text-to-SQL. ArXiv abs/2409.02038 (2024). https://api.semanticscholar.org/CorpusID:272367292
[9] Shumo Chu, Chenglong Wang, Konstantin Weitz, and Alvin Cheung. 2017. Cosette: An Automated Prover for SQL. In 8th Biennial Conference on Innovative Data Systems Research, CIDR 2017, Chaminade, CA, USA, January 8-11, 2017, Online Proceedings. www.cidrdb.org. http://cidrdb.org/cidr2017/papers/p51-chu-cidr17.pdf
[10] Jim Gray, Prakash Sundaresan, Susanne Englert, Ken Baclawski, and Peter J. Weinberger. 1994. Quickly generating billion-record synthetic databases. In Proceedings of the 1994 ACM SIGMOD International Conference on Management of Data (Minneapolis, Minnesota, USA) (SIGMOD '94). Association for Computing Machinery, New York, NY, USA, 243–252. doi:10.1145/191839.191886
[11] Bhanu Pratap Gupta, Devang Vira, and S. Sudarshan. 2010. X-data: Generating test data for killing SQL mutants. In 2010 IEEE 26th International Conference on Data Engineering (ICDE 2010). 876–879. doi:10.1109/ICDE.2010.5447862
[12] Yang He, Pinhan Zhao, Xinyu Wang, and Yuepeng Wang. 2024. VeriQL: Bounded Equivalence Verification for Complex SQL Queries with Integrity Constraints. Proc. ACM Program. Lang. 8, OOPSLA1, Article 132 (April 2024), 29 pages. doi:10.1145/3649849
[13] Jinyang Li, Binyuan Hui, Ge Qu, Jiaxi Yang, Binhua Li, Bowen Li, Bailin Wang, Bowen Qin, Ruiying Geng, Nan Huo, Xuanhe Zhou, Chenhao Ma, Guoliang Li, Kevin C.C. Chang, Fei Huang, Reynold Cheng, and Yongbin Li. 2023. Can LLM already serve as a database interface? a big bench for large-scale database grounded text-to-SQLs. In Proceedings of the 37th International Conference on Neural Information Processing Systems (New Orleans, LA, USA) (NIPS '23). Curran Associates Inc., Red Hook, NY, USA, Article 1835, 28 pages. https://dl.acm.org/doi/abs/10.5555/3666122.3667957
[14] Nelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, and Percy Liang. 2024. Lost in the Middle: How Language Models Use Long Contexts. Transactions of the Association for Computational Linguistics 12 (2024), 157–173. doi:10.1162/tacl_a_00638
[15] Xinyu Liu, Shuyu Shen, Boyan Li, Nan Tang, and Yuyu Luo. 2025. NL2SQL-BUGS: A Benchmark for Detecting Semantic Errors in NL2SQL Translation. In Proceedings of the 31st ACM SIGKDD Conference on Knowledge Discovery and Data Mining V.2 (Toronto ON, Canada) (KDD '25). Association for Computing Machinery, New York, NY, USA, 5662–5673. doi:10.1145/3711896.3737427
[16] Glenford J. Myers, Corey Sandler, and Tom Badgett. 2011. The Art of Software Testing (3rd ed.). Wiley Publishing. https://dl.acm.org/doi/10.5555/2161638
[17] Shetal Shah, S. Sudarshan, Suhas Kajabje, Sandeep Patidar, Bhanu Pratap Gupta, and Devang Vira. 2011. Generating test data for killing SQL mutants: A constraint-based approach. In 2011 IEEE 27th International Conference on Data Engineering. 1175–1186. doi:10.1109/ICDE.2011.5767876
[18] Sunanda Somwase, Parismita Das, and S. Sudarshan. 2025. Test Data Generation for Complex SQL Queries. Proc. ACM Manag. Data 3, 6, Article 367 (Dec. 2025), 26 pages. doi:10.1145/3769832
[19] Arun N. Swami and K. Bernhard Schiefer. 1994. On the Estimation of Join Result Sizes. In Advances in Database Technology – EDBT '94, 4th International Conference on Extending Database Technology (Lecture Notes in Computer Science, Vol. 779). Springer, Berlin, Heidelberg, 287–300. doi:10.1007/3-540-57818-8_58
[20] Andrew Tremante, Yang He, Rocky Klopfenstein, Yuepeng Wang, Nina Nardytska, and Haoze Wu. 2026. Spotlt+: Verification-based Text-to-SQL Evaluation with Database Constraints. arXiv preprint arXiv:2603.04334 (2026). doi:10.48550/arXiv.2603.04334
[21] Margus Veanes, Nikolai Tillmann, and Jonathan de Halleux. 2010. Qex: Symbolic SQL Query Explorer. In Logic for Programming, Artificial Intelligence, and Reasoning. Edmund M. Clarke and Andrei Voronkov (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 425–446. doi:10.1007/978-3-642-17511-4_24
[22] Shuxian Wang, Sicheng Pan, and Alvin Cheung. 2024. QED: A Powerful Query Equivalence Decider for SQL. Proc. VLDB Endow. 17, 11 (July 2024), 3602–3614. doi:10.14778/3681954.3682024
[23] Lee J. White and Edward I. Cohen. 1980. A Domain Strategy for Computer Program Testing. IEEE Transactions on Software Engineering SE-6, 3 (1980), 247–257. doi:10.1109/TSE.1980.234486
[24] Fuheng Zhao, Jiaoyue Chen, Lawrence Lim, Ishtiyaque Ahmad, Divyakant Agrawal, and Amr El Abbadi. 2025. LLM-SQL-Solver: Can LLMs Determine SQL Equivalence?. In Proceedings of the 2025 IEEE International Conference on Big Data (BigData). IEEE, 1887–1894. doi:10.1109/BigData66926.2025.11401595
[25] Pinhan Zhao, Yuepeng Wang, and Xinyu Wang. 2025. Polygon: Symbolic reasoning for SQL using conflict-driven under-approximation search. Proc. ACM Program. Lang. 9, PLDI (June 2025), 1315–1340. https://doi.org/10.1145/3729303
[26] Ruiqi Zhong, Tao Yu, and Dan Klein. 2020. Semantic Evaluation for Text-to-SQL with Distilled Test Suites. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP). Association for Computational Linguistics, 396–411. doi:10.18653/v1/2020.emnlp-main.29
[27] Qi Zhou, Joy Arulraj, Shamkant B. Navathe, William Harris, and Jinpeng Wu. 2022. SPES: A Symbolic Approach to Proving Query Equivalence Under Bag Semantics. In 38th IEEE International Conference on Data Engineering, ICDE 2022, Kuala Lumpur, Malaysia, May 9-12, 2022. IEEE, 2735–2748. doi:10.1109/ICDE53745.2022.00250