Qr-Hint: Actionable Hints Towards Correcting Wrong SQL Queries
Yihao Hu, Amir Gilad, Kristin Stephens-Martinez, Sudeepa Roy, Jun Yang
Abstract
We describe a system called Qr-Hint that, given a (correct) target query ๐ โ and a (wrong) working query ๐, both expressed in SQL, provides actionable hints for the user to fix the working query so that it becomes semantically equivalent to the target. It is particularly useful in an educational setting, where novices can receive help from Qr-Hint without requiring extensive personal tutoring. Since there are many different ways to write a correct query, we do not want to base our hints completely on how ๐ โ is written; instead, starting with the user's own working query, Qr-Hint purposefully guides the user through a sequence of steps that provably lead to a correct query, which will be equivalent to ๐ โ but may still "look" quite different from it. Ideally, we would like Qr-Hint's hints to lead to the "smallest" possible corrections to ๐. However, optimality is not always achievable in this case due to some foundational hurdles such as the undecidability of SQL query equivalence and the complexity of logic minimization. Nonetheless, by carefully decomposing and formulating the problems and developing principled solutions, we are able to provide provably correct and locally optimal hints through Qr-Hint. We show the effectiveness of Qr-Hint through quality and performance experiments as well as a user study in an educational setting.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 1dfa7bf9-90a0-4b52-930f-0e4f428b07a0Cited by top-tier papers3
- The Power of Constraints in Natural Language to SQL TranslationTonghui Ren, Chen Ke, Yuankai Fan, Yinan Jing et al.VLDB 2025 ยท 4 citations
- Towards Selecting Informative Alternative Relational Query Plans for Database EducationHui Li, Hu Wang, Sourav S. Bhowmick, Zihao MaSIGMOD 2026
- I-Rex: An Interactive Debugger for SQLYihao Hu, Zian Chen, Zhiming Leong, Sharan Sokhi et al.VLDB 2026
Builds on5
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 ยท 64,255 citations
- CoCoNuT: combining context-aware neural translation models using ensemble for program repairThibaud Lutellier, Hung Viet Pham, Lawrence Pang, Yitong Li et al.ISSTA 2020 ยท 325 citations
- TFix: Learning to Fix Coding Errors with a Text-to-Text TransformerBerkay Berabi, Jingxuan He, Veselin Raychev, Martin T. VechevICML 2021 ยท 143 citations
- QueryVis: Logic-based Diagrams help Users Understand Complicated SQL Queries FasterAristotelis Leventidis, Jiahui Zhang, Cody Dunne, Wolfgang Gatterbauer et al.SIGMOD 2020 ยท 36 citations
- Understanding Queries by Conditional InstancesAmir Gilad, Zhengjie Miao, Sudeepa Roy, Jun YangSIGMOD 2022 ยท 9 citations
Related papers
- Polygon: Symbolic Reasoning for SQL using Conflict-Driven Under-Approximation SearchPinhan Zhao, Yuepeng Wang, Xinyu WangPLDI 2025
- Dial: A Knowledge-Grounded Dialect-Specific NL2SQL SystemXiang Zhang, Le Zhou, Hongming Xu, Wei Zhou et al.VLDB 2026 ยท 2 citations
- Automated Validating and Fixing of Text-to-SQL Translation with Execution ConsistencyYicun Yang, Zhaoguo Wang, Yu Xia, Zhuoran Wei et al.SIGMOD 2025 ยท 7 citations
- VeriEQL: Bounded Equivalence Verification for Complex SQL Queries with Integrity ConstraintsYang He, Pinhan Zhao, Xinyu Wang, Yuepeng WangOOPSLA 2024 ยท 12 citations
- Interactive Text-to-SQL Generation via Editable Step-by-Step ExplanationsYuan Tian, Zheng Zhang, Zheng Ning, Toby Jia-Jun Li et al.EMNLP 2023 ยท 14 citations
