Synthesizing Document Database Queries using Collection Abstractions
Abstract
Document databases are increasingly popular in various applications, but their queries are challenging to write due to the flexible and complex data model underlying document databases. This paper presents a synthesis technique that aims to generate document database queries from input-output examples automatically. A new domain-specific language is designed to express a representative set of document database queries in an algebraic style. Furthermore, the synthesis technique leverages a novel abstraction of collections for deduction to efficiently prune the search space and quickly generate the target query. An evaluation of 110 benchmarks from various sources shows that the proposed technique can synthesize 108 benchmarks successfully. On average, the synthesizer can generate document database queries from a small number of input-output examples within tens of seconds.
Empirical ResultsBrowse all benchmarks →
| Benchmark | Method | Metric | Score | Protocol / Evidence |
|---|---|---|---|---|
| Total: 110 benchmarks from StackOverflow, MongoDB Document, Twitter API, and Kaggle | Nosdaq | benchmarks solved | 108 benchmarks | time-limit=5 minutes · benchmark-count=110Source quoteL630: \multirow{4}{=}{Total} │ \multirow{4}{*}{110} │ \multirow{4}{*}{108} │ avg │ 14.2 │ 175 │ 57 │ 13 |
| Total: 110 benchmarks from StackOverflow, MongoDB Document, Twitter API, and Kaggle | Nosdaq | average synthesis time | 14.2 s | time-limit=5 minutes · benchmark-count=110Source quoteL630: \multirow{4}{=}{Total} │ \multirow{4}{*}{110} │ \multirow{4}{*}{108} │ avg │ 14.2 │ 175 │ 57 │ 13 |
| Synthesized queries from the 110-benchmark evaluation | Nosdaq | queries equivalent to the desired ones | 107 queries | inspection=manual · benchmark-count=110Source quoteL647: To understand if Nosdaq\xspace can synthesize desired queries, we have manually inspected all 108 synthesized queries and found 107 of them are equivalent to the desired ones. There is only one benchmark (from StackOverflow) where Nosdaq\xspace synthesized a plausible query in terms of the example but the query is not desired. |
Reported baseline / comparator measurements (2)
| Benchmark | Method | Metric | Score | Protocol / Evidence |
|---|---|---|---|---|
| 110 document database query benchmarks | EUSolver baseline | benchmarks solved | 25 benchmarks | time-limit=5 minutes · benchmark-count=110Source quoteL669: As shown in Figure~\ref{fig:baseline}, as opposed to 108 benchmarks solved by Nosdaq\xspace, EUSolver\xspace can only solve {25} benchmarks within the 5-minute time limit due to the large search space of document database queries in general. |
| 110 document database query benchmarks | ChatGPT (gpt-4o-2024-08-06) baseline | benchmarks for which the generated query was desired | 53 benchmarks | input=input-output examples and constants; no natural-language description · model=gpt-4o-2024-08-06 · benchmark-count=110Source quoteL674: To compare Nosdaq\xspace with the LLM-based approach, we have used ChatGPT (version gpt-4o-2024-08-06) to synthesize all of our 110 benchmarks. Specifically, we have used the same set of input-output examples and constants in each benchmark and asked ChatGPT to generate MongoDB queries. To make fair comparisons, we did not provide additional natural language descriptions about what the query should do. The evaluation shows that GPT can only generate the desired query for 53 out of 110 benchmarks. For 24 benchmarks, the generated query is plausible but undesired, i.e., it is consistent with the examples but not equivalent to the desired one. For the remaining 33 benchmarks, the generated query is inconsistent with the input-output examples. The errors made by GPT include misunderstanding the semantics of operators, missing predicates, etc. Recall that Nosdaq\xspace can synthesize desired queries for 107 benchmarks and plausible but undesired query for 1 benchmark. We believe our synthesis technique is more effective and generalizable than GPT to synthesize document database queries from examples. |
BibTeX
@misc{liu2024synthesizing,
author = {Qikang Liu and Yang He and Yanwen Cai and Byeongguk Kwak and Yuepeng Wang},
title = {{Synthesizing Document Database Queries using Collection Abstractions}},
year = {2024},
eprint = {2412.06102},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2412.06102},
}Ask Althea to put this paper to the test.
Loading related content...