vix.ing · top · new · best · stats · spec

Synthesizing highly expressive SQL queries from input-output examples

2017/06/14 by Chenglong Wang, Alvin Cheung, Rastislav Bodik +1
Computer Science · Decision Sciences · #Advanced Database Systems and Queries #Data Quality and Management #Web Application Security Vulnerabilities

paper · pdf · doi:10.1145/3140587.3062365

openalex publication_date 2017/06/14 · openalex created_date 2025/10/10 · openalex updated_date 2026/08/01

Abstract

SQL is the de facto language for manipulating relational data. Though powerful, many users find it difficult to write SQL queries due to highly expressive constructs. While using the programming-by-example paradigm to help users write SQL queries is an attractive proposition, as evidenced by online help forums such as Stack Overflow, developing techniques for synthesizing SQL queries from given input-output (I/O) examples has been difficult, due to the large space of SQL queries as a result of its rich set of operators. In this paper, we present a new scalable and efficient algorithm for synthesizing SQL queries based on I/O examples. The key innovation of our algorithm is development of a language for abstract queries, i.e., queries with uninstantiated operators, that can be used to express a large space of SQL queries efficiently. Using abstract queries to represent the search space nicely decomposes the synthesis problem into two tasks: 1) searching for abstract queries that can potentially satisfy the given I/O examples, and 2) instantiating the found abstract queries and ranking the results. We have implemented this algorithm in a new tool called Scythe and evaluated it using 193 benchmarks collected from Stack Overflow. Our evaluation shows that Scythe can efficiently solve 74% of the benchmarks, most in just a few seconds, and the queries range from simple ones involving a single selection to complex queries with 6 nested subqueires.

Related