Lune

EMNLP Findings2025

Pi-SQL: Enhancing Text-to-SQL with Fine-Grained Guidance from Pivot Programming Languages

Yongdong Chi, Hanqing Wang, Yun Chen, Yan Yang, Jian Yang, Zonghan Yang, Xiao Yan, Guanhua Chen

Abstract

Text-to-SQL transforms the user queries from natural language to executable SQL programs, enabling non-experts to interact with complex databases. Existing prompt-based methods craft meticulous text guidelines and examples to facilitate SQL generation, but their accuracy is hindered by the large semantic gap between the texts and the low-resource SQL programs. In this work, we propose PI-SQL, which incorporates the high-resource Python program as a pivot to bridge between the natural language query and SQL program. In particular, PI-SQL first generates Python programs that provide fine-grained step-by-step guidelines in their code blocks or comments, and then produces an SQL program following the guidance of each Python program. The final SQL program matches the reference Python program's query results and, through selection from candidates generated by different strategies, achieves superior execution speed, with a reward-based valid efficiency score up to 4.55 higher than the best-performing baseline. Extensive experiments demonstrate the effectiveness of PI-SQL, which improves the execution accuracy of the best-performing baseline by up to 3.20.

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.

Questions to start from

Lune can draw on

the full paper · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Teaching Large Language Models to Self-Debug cites Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation cites RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
  • Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation cites Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • The Dawn of Natural Language to SQL: Are We Fully Ready? [Experiment, Analysis & Benchmark ] cites RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQL
  • The Dawn of Natural Language to SQL: Are We Fully Ready? [Experiment, Analysis & Benchmark ] cites Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation
Builds onCited byLeft to right by year; the more cited, the higher.

Builds on12

  1. Teaching Large Language Models to Self-DebugXinyun Chen, Maxwell Lin, Nathanael Schärli, Denny ZhouICLR 2024 · 1,085 citations
  2. Self-Consistency Improves Chain of Thought Reasoning in Language ModelsXuezhi Wang, Jason Wei, Dale Schuurmans, Quoc V. Le et al.ICLR 2023 · 681 citations
  3. Text-to-SQL Empowered by Large Language Models: A Benchmark EvaluationDawei Gao, Haibin Wang, Yaliang Li, Xiuyu Sun et al.VLDB 2024 · 609 citations
  4. RESDSQL: Decoupling Schema Linking and Skeleton Parsing for Text-to-SQLHaoyang Li, Jing Zhang, Cuiping Li, Hong ChenAAAI 2023 · 343 citations
  5. The Dawn of Natural Language to SQL: Are We Fully Ready? [Experiment, Analysis & Benchmark ]Boyan Li, Yuyu Luo, Chengliang Chai, Guoliang Li et al.VLDB 2024 · 137 citations

Related papers

  1. CORES: Code-Oriented Reasoning for Complex Text-to-SQL and Generalizable TableQAMeng Zhang, Ruochun Jin, Yuanxi Peng, Wenjing Yang et al.ACL Findings 2026
  2. EXPO-SQL: Execution-based Clause-level Policy Optimization for Text-to-SQLJaehoon Lee, CheolWon Na, Suyoung Bae, Jin-Seop Lee et al.ACL Findings 2026 · 1 citation
  3. SQLens: An End-to-End Framework for Error Detection and Correction in Text-to-SQLYue Gong, Chuan Lei, Xiao Qin, Kapil Vaidya et al.NeurIPS 2025 · 21 citations
  4. Enhancing Text-to-SQL Parsing through Question Rewriting and Execution-Guided RefinementWenxin Mao, Ruiqi Wang, Jiyu Guo, Jichuan Zeng et al.ACL Findings 2024 · 19 citations
  5. Natural SQL: Making SQL Easier to Infer from Natural Language SpecificationsYujian Gan, Xinyun Chen, Jinxia Xie, Matthew Purver et al.EMNLP Findings 2021 · 88 citations
Dusk over the sea between two cliffs drawn in fine vertical lines