Lune

SIGMOD2024Top-tier venue

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 Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

3 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper ยท the top-tier papers that cite it ยท related work

Get the answer

Free to start. No credit card required.

Lineage

  • TFix: Learning to Fix Coding Errors with a Text-to-Text Transformer cites CoCoNuT: combining context-aware neural translation models using ensemble for program repair
  • Towards Selecting Informative Alternative Relational Query Plans for Database Education cites QueryVis: Logic-based Diagrams help Users Understand Complicated SQL Queries Faster
  • The Power of Constraints in Natural Language to SQL Translation cites Understanding Queries by Conditional Instances
  • The Power of Constraints in Natural Language to SQL Translation cites QueryVis: Logic-based Diagrams help Users Understand Complicated SQL Queries Faster
  • I-Rex: An Interactive Debugger for SQL cites Understanding Queries by Conditional Instances
  • I-Rex: An Interactive Debugger for SQL cites Language Models are Few-Shot Learners
  • I-Rex: An Interactive Debugger for SQL cites QueryVis: Logic-based Diagrams help Users Understand Complicated SQL Queries Faster
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers3

  1. The Power of Constraints in Natural Language to SQL TranslationTonghui Ren, Chen Ke, Yuankai Fan, Yinan Jing et al.VLDB 2025 ยท 4 citations
  2. Towards Selecting Informative Alternative Relational Query Plans for Database EducationHui Li, Hu Wang, Sourav S. Bhowmick, Zihao MaSIGMOD 2026
  3. I-Rex: An Interactive Debugger for SQLYihao Hu, Zian Chen, Zhiming Leong, Sharan Sokhi et al.VLDB 2026

Builds on5

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 ยท 64,255 citations
  2. 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
  3. TFix: Learning to Fix Coding Errors with a Text-to-Text TransformerBerkay Berabi, Jingxuan He, Veselin Raychev, Martin T. VechevICML 2021 ยท 143 citations
  4. QueryVis: Logic-based Diagrams help Users Understand Complicated SQL Queries FasterAristotelis Leventidis, Jiahui Zhang, Cody Dunne, Wolfgang Gatterbauer et al.SIGMOD 2020 ยท 36 citations
  5. Understanding Queries by Conditional InstancesAmir Gilad, Zhengjie Miao, Sudeepa Roy, Jun YangSIGMOD 2022 ยท 9 citations

Related papers

  1. Polygon: Symbolic Reasoning for SQL using Conflict-Driven Under-Approximation SearchPinhan Zhao, Yuepeng Wang, Xinyu WangPLDI 2025
  2. Memo-SQL: Structured Decomposition and Experience-Driven Self-Correction for Training-Free NL2SQLZerui Yang, Weichuan Wang, Yanwei Xu, Linqi Song et al.ACL Findings 2026
  3. Dial: A Knowledge-Grounded Dialect-Specific NL2SQL SystemXiang Zhang, Le Zhou, Hongming Xu, Wei Zhou et al.VLDB 2026 ยท 2 citations
  4. Pi-SQL: Enhancing Text-to-SQL with Fine-Grained Guidance from Pivot Programming LanguagesYongdong Chi, Hanqing Wang, Yun Chen, Yan Yang et al.EMNLP Findings 2025
  5. 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
Dusk over the sea between two cliffs drawn in fine vertical lines