Table of Contents
Fetching ...

E-SQL: Direct Schema Linking via Question Enrichment in Text-to-SQL

Hasan Alp Caferoğlu, Özgür Ulusoy

TL;DR

E-SQL presents a direct-schema-linking framework for Text-to-SQL by enriching natural-language questions with database items and generated SQL reasoning steps, coupled with candidate predicate augmentation and an error-aware SQL refinement stage. The approach deliberately avoids schema filtering, showing that modern LLMs can maintain strong schema understanding without pruning, while QE and SR substantially improve performance on complex queries. Evaluations on the Spider and BIRD benchmarks demonstrate competitive results, with notable gains on challenging questions and strong performance for non-fine-tuned small LLMs when enriched questions are used. The work highlights the practical viability of enriching prompts with database context to enhance LLM-based SQL generation and points to future directions for improving efficiency and small-model performance.

Abstract

Translating Natural Language Queries into Structured Query Language (Text-to-SQL or NLQ-to-SQL) is a critical task extensively studied by both the natural language processing and database communities, aimed at providing a natural language interface to databases (NLIDB) and lowering the barrier for non-experts. Despite recent advancements made through the use of Large Language Models (LLMs), significant challenges remain. These include handling complex database schemas, resolving ambiguity in user queries, and generating SQL queries with intricate structures that accurately reflect the user's intent. In this work, we introduce E-SQL, a novel pipeline specifically designed to address these challenges through direct schema linking and candidate predicate augmentation. E-SQL enhances the natural language query by incorporating relevant database items (i.e., tables, columns, and values) and conditions directly into the question and SQL construction plan, bridging the gap between the query and the database structure. The pipeline leverages candidate predicate augmentation to mitigate erroneous or incomplete predicates in generated SQLs. Comprehensive evaluations on the BIRD benchmark illustrate that E-SQL achieves competitive performance, particularly excelling in complex queries with a 66.29% execution accuracy on the test set. A further observation from our experiments reveals that incorporating schema filtering into the translation pipeline does not have a positive impact on performance when the most advanced proprietary LLMs are used. Additionally, our experiments with small LLMs highlight the importance and positive impact of enriched questions on their performance. Without fine-tuning, single-prompt SQL generation using enriched questions with DeepSeek Coder 7B Instruct 1.5v achieves 56.45% execution accuracy on the BIRD development set.

E-SQL: Direct Schema Linking via Question Enrichment in Text-to-SQL

TL;DR

E-SQL presents a direct-schema-linking framework for Text-to-SQL by enriching natural-language questions with database items and generated SQL reasoning steps, coupled with candidate predicate augmentation and an error-aware SQL refinement stage. The approach deliberately avoids schema filtering, showing that modern LLMs can maintain strong schema understanding without pruning, while QE and SR substantially improve performance on complex queries. Evaluations on the Spider and BIRD benchmarks demonstrate competitive results, with notable gains on challenging questions and strong performance for non-fine-tuned small LLMs when enriched questions are used. The work highlights the practical viability of enriching prompts with database context to enhance LLM-based SQL generation and points to future directions for improving efficiency and small-model performance.

Abstract

Translating Natural Language Queries into Structured Query Language (Text-to-SQL or NLQ-to-SQL) is a critical task extensively studied by both the natural language processing and database communities, aimed at providing a natural language interface to databases (NLIDB) and lowering the barrier for non-experts. Despite recent advancements made through the use of Large Language Models (LLMs), significant challenges remain. These include handling complex database schemas, resolving ambiguity in user queries, and generating SQL queries with intricate structures that accurately reflect the user's intent. In this work, we introduce E-SQL, a novel pipeline specifically designed to address these challenges through direct schema linking and candidate predicate augmentation. E-SQL enhances the natural language query by incorporating relevant database items (i.e., tables, columns, and values) and conditions directly into the question and SQL construction plan, bridging the gap between the query and the database structure. The pipeline leverages candidate predicate augmentation to mitigate erroneous or incomplete predicates in generated SQLs. Comprehensive evaluations on the BIRD benchmark illustrate that E-SQL achieves competitive performance, particularly excelling in complex queries with a 66.29% execution accuracy on the test set. A further observation from our experiments reveals that incorporating schema filtering into the translation pipeline does not have a positive impact on performance when the most advanced proprietary LLMs are used. Additionally, our experiments with small LLMs highlight the importance and positive impact of enriched questions on their performance. Without fine-tuning, single-prompt SQL generation using enriched questions with DeepSeek Coder 7B Instruct 1.5v achieves 56.45% execution accuracy on the BIRD development set.
Paper Structure (36 sections, 1 equation, 7 figures, 10 tables)

This paper contains 36 sections, 1 equation, 7 figures, 10 tables.

Figures (7)

  • Figure 1: Overview of the general pipeline for the Text-to-SQL translation task, highlighting the key modules: Schema Filtering, Question Decomposition, Entity Retrieval, and Query Generation. The modular design allows for variation in the usage of these components, depending on the preferred pipeline configuration.
  • Figure 2: Overview of the proposed E-SQL pipeline with candidate predicate generation, question enrichment, SQL refinement modules, and without schema filtering module.
  • Figure 3: Example for the generation of incomplete value in the predicate explained in Section \ref{['subsec:cpg']}, case (2).
  • Figure 4: Example for correct table and value but wrong column in the predicate explained the Section \ref{['subsec:cpg']}, case (3).
  • Figure 5: Example for correct table but wrong column and value selection in the predicate explained in Section \ref{['subsec:cpg']}, case (4).
  • ...and 2 more figures