[Paper Review] Type- and Content-Driven Synthesis of SQL Queries from Natural Language
This paper presents Sqlizer, a database-agnostic system that synthesizes SQL queries from natural language using a three-stage process: semantic parsing to generate query sketches, type-directed synthesis to complete them with confidence scoring, and automated repair to fix schema mismatches. The approach achieves top-5 accuracy in 89% of test cases across three databases, outperforming state-of-the-art NLIDB systems.
This paper presents a new technique for automatically synthesizing SQL queries from natural language. Our technique is fully automated, works for any database without requiring additional customization, and does not require users to know the underlying database schema. Our method achieves these goals by combining natural language processing, program synthesis, and automated program repair. Given the user's English description, our technique first uses semantic parsing to generate a query sketch, which is subsequently completed using type-directed program synthesis and assigned a confidence score using database contents. However, since the user's description may not accurately reflect the actual database schema, our approach also performs fault localization and repairs the erroneous part of the sketch. This synthesize-repair loop is repeated until the algorithm infers a query with a sufficiently high confidence score. We have implemented the proposed technique in a tool called Sqlizer and evaluate it on three different databases. Our experiments show that the desired query is ranked within the top 5 candidates in close to 90% of the cases.
Motivation & Objective
- To address the limitations of existing natural language-to-SQL systems that require database-specific training or user guidance.
- To enable fully automated, database-agnostic SQL query synthesis without requiring users to know the underlying schema.
- To improve accuracy in complex scenarios where user descriptions do not match the actual database schema.
- To combine semantic parsing, type-directed synthesis, and program repair into a robust, iterative query synthesis pipeline.
Proposed method
- Use semantic parsing to generate a query sketch—a partial, schema-agnostic representation of the desired query structure from natural language input.
- Apply type-directed program synthesis to enumerate and complete the sketch with valid database terms (tables, columns, predicates), guided by type safety and database contents.
- Assign confidence scores to each completed query using both the natural language description and actual data values in the database.
- When no high-confidence completion is found, perform fault localization to identify the most likely erroneous part of the sketch.
- Apply a database of pre-defined repair tactics to iteratively refine the sketch and generate new candidate sketches.
- Repeat the synthesis and repair loop up to n times per sketch, then rank all resulting queries by confidence score and return the top m results.
Experimental results
Research questions
- RQ1Can a natural language-to-SQL system achieve high accuracy without requiring database-specific training or schema knowledge?
- RQ2How effective is the combination of semantic parsing, type-directed synthesis, and automated repair in handling schema mismatches caused by user misunderstanding?
- RQ3Can a system maintain high precision across diverse databases without customization?
- RQ4How does the confidence scoring mechanism based on both natural language and data contents improve query selection?
Key findings
- Sqlizer achieves a top-5 accuracy rate of 89% across 455 queries on three different databases, demonstrating strong generalization.
- The system significantly outperforms Nalir, a state-of-the-art NLIDB system, in non-interactive mode, particularly in handling complex or ambiguous user descriptions.
- The use of query sketches enables the system to work without prior training on a specific database, making it fully database-agnostic.
- The integration of automated repair and fault localization allows the system to correct structural errors in the initial sketch when the user’s description misrepresents the database schema.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.