# Automatic Metadata Extraction for Text-to-SQL

**Authors:** Vladislav Shkapenyuk, Divesh Srivastava, Theodore Johnson, Parisa Ghane  
**arXiv:** [2505.19988](https://arxiv.org/abs/2505.19988)  
**Date:** 2025-05-26  
**Summary page:** https://www.summarizepaper.com/en/paper/2505.19988v1/

## Key points

- Understanding database contents is identified as the most arduous task.
- Database profiling
- Query log analysis
- SQL-to-text generation
- Importance of database profiling techniques in characterizing database contents effectively.
- Leveraging Large Language Models (LLMs) for insightful summaries of field meanings by combining profiling results with basic table metadata.
- Higher accuracy in text-to-SQL tasks achieved by leveraging field metadata generated through profiling and LLM summarization.
- Effectiveness of using profiling metadata alone compared to relying solely on provided hints in text-to-SQL tasks.
- Fusion of multiple sources of metadata proves most effective in enhancing accuracy levels.
- Valuable insights uncovered through query log analysis, such as undocumented equality constraints and multi-field join constraints not present in traditional documentation or hints provided with text-to-SQL tasks.
- Promising results in SQL-to-text generation even without explicit metadata, especially when fused with BIRD/profiling metadata, outperforming human-generated questions.
- Importance of task alignment when utilizing Large Language Models for complex tasks like schema linking, highlighting limitations beyond training boundaries.
- Significance of automatic metadata extraction techniques in enhancing text-to-SQL generation accuracy and efficiency for more seamless and accurate query development processes.

## Summary

In this paper, we delve into the challenges of text-to-SQL generation by focusing on the crucial aspect of understanding database contents. Drawing from our extensive experience in query development on complex industrial databases, we identify database comprehension as the most arduous task. SQL query formulation typically follows a more straightforward path. To address this issue, we propose strategies for automatic metadata extraction for text-to-SQL generation, including database profiling, query log analysis, and SQL-to-text generation. Database profiling techniques are utilized to characterize database contents effectively. By combining profiling results with basic table metadata, we demonstrate that Large Language Models (LLMs) can offer insightful summaries of field meanings. For evaluation purposes, we introduce a novel schema linking strategy based on task alignment. Our findings reveal that leveraging field metadata generated through profiling and LLM summarization yields high accuracy in text-to-SQL tasks. Through experimentation using the BIRD benchmark suite, we compare the effectiveness of using profiling metadata versus supplied metadata with or without hints. Surprisingly, utilizing profiling metadata alone leads to higher accuracy than relying solely on provided hints. Furthermore, the fusion of multiple sources of metadata proves to be most effective in enhancing accuracy levels. Additionally, we explore query log analysis within the BIRD dev query set and discover valuable insights such as undocumented equality constraints and multi-field join constraints. The analysis uncovers essential information not present in traditional documentation or hints provided with text-to-SQL tasks. Furthermore, our experiments on SQL-to-text generation showcase promising results even without explicit metadata. The LLM performs comparably to human-generated questions and significantly outperforms them when fused with BIRD/profiling metadata. This highlights the potential for automated question/SQL generation processes to surpass human-generated counterparts due to reduced error rates associated with manual tasks. In our pursuit of schema linking mechanisms for our BIRD submission, we experimented with various techniques but encountered unsatisfactory outcomes due to limitations in LLM performance beyond their training boundaries. This underscores the importance of task alignment when utilizing LLMs for complex tasks like schema linking. Overall, our research emphasizes the significance of automatic metadata extraction techniques in enhancing text-to-SQL generation accuracy and efficiency. By leveraging innovative strategies and harnessing the capabilities of LLMs, we aim to advance the field towards more seamless and accurate query development processes in diverse database environments.
