Skip to main content
QUICK REVIEW

[Paper Review] E-SQL: Direct Schema Linking via Question Enrichment in Text-to-SQL

Hasan Caferoğlu, Özgür Ulusoy|arXiv (Cornell University)|Sep 25, 2024
Advanced Database Systems and QueriesComputer Science3 citations
TL;DR

E-SQL proposes a novel Text-to-SQL pipeline that enhances natural language queries by directly enriching them with relevant database elements—such as tables, columns, and values—thereby improving schema linking and reducing SQL generation errors. By integrating candidate predicate augmentation and SQL refinement, E-SQL achieves 66.29% execution accuracy on the BIRD test set, outperforming schema filtering with modern LLMs.

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.

Motivation & Objective

  • To address persistent challenges in Text-to-SQL, including schema linking ambiguity and complex query generation, especially with large language models (LLMs).
  • To investigate whether schema filtering remains beneficial when using state-of-the-art LLMs, given their improved reasoning and schema understanding capabilities.
  • To develop a pipeline that enhances query understanding through direct schema linking via question enrichment, reducing reliance on pre-processing schema filtering.
  • To improve SQL accuracy through candidate predicate augmentation and a dedicated SQL refinement module that corrects erroneous or incomplete queries.
  • To demonstrate that modern LLMs can effectively handle full database schemas without explicit filtering, challenging prior assumptions about schema pruning benefits.

Proposed method

  • Enriches the natural language query by injecting relevant database items—tables, columns, and values—directly into the question to improve alignment with the schema.
  • Generates candidate predicates during the SQL generation process to reduce errors and improve completeness of WHERE and HAVING clauses.
  • Employs a two-stage pipeline: first, a question enrichment module that enhances the input query with schema-relevant context; second, a SQL refinement module that corrects incorrect queries.
  • Uses GPT-4o and GPT-4o-mini for inference, with the refinement module applying iterative validation and correction on generated SQLs.
  • Excludes schema filtering in favor of direct schema linking, based on empirical findings that filtering degrades performance with advanced LLMs.
  • Evaluates the pipeline on the BIRD benchmark using execution accuracy as the primary metric, comparing performance across difficulty levels and models.

Experimental results

Research questions

  • RQ1Does enriching natural language questions with database elements improve schema linking and overall Text-to-SQL accuracy?
  • RQ2Does schema filtering continue to provide performance benefits when used with state-of-the-art LLMs, or does it become detrimental?
  • RQ3Can candidate predicate augmentation effectively reduce errors in WHERE and HAVING clause generation in complex SQL queries?
  • RQ4To what extent can a post-generation SQL refinement module correct incorrect queries, especially when using less capable LLMs?
  • RQ5Does the performance gap between development and test sets on BIRD stem from model variance or data distribution shifts, particularly with advanced LLMs?

Key findings

  • E-SQL achieved 66.29% execution accuracy on the BIRD test set when using GPT-4o, demonstrating strong performance on complex queries.
  • The SQL refinement module corrected 5.35% of initially incorrect queries generated by GPT-4o-mini and 1.83% by GPT-4o, showing significant improvement for less capable models.
  • Schema filtering consistently degraded performance across all difficulty levels, indicating it is counterproductive when used with modern LLMs.
  • Question enrichment significantly improved schema linking, especially for complex queries, as shown by ablation studies.
  • Performance on the BIRD test set exceeded that on the development set when using GPT-4o, suggesting potential data or distribution shifts or model variance.
  • The pipeline’s effectiveness was limited by hardware constraints, preventing evaluation on open-source LLMs, which remains an open direction for future work.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.