DAgent: A Relational Database-Driven Data Analysis Report Generation Agent

Wenyi Xu, Yuren Mao, Xiaolu Zhang, Chao Zhang, Xuemei Dong, Mengfei Zhang, Yunjun GaoarXiv 2025 · DOI

Abstract

DAgent is a novel Large Language Model (LLM)-based agent system designed to bridge the gap between simple database queries and complex data analysis. By integrating modular planning, hybrid retrieval tools, and a persistent memory module, it transforms natural language questions into comprehensive, multi-perspective analytical reports. DAgent significantly outperforms existing Text-to-SQL and TableQA methods on the newly introduced DA-Dataset benchmark.

Introduction

While tools like Text-to-SQL and TableQA have made progress in allowing non-experts to query databases, they are largely limited to "lookup" tasks—retrieving a single value or a simple aggregate. Real-world data analysis is significantly more complex, requiring multi-step reasoning, joining information across numerous tables, and synthesizing raw numbers into a coherent narrative (e.g., correlating regional sales trends with marketing spend).

Furthermore, the research community has lacked a dedicated benchmark for this "report generation" task. Existing datasets like Spider or BIRD focus on the accuracy of a single SQL query rather than the quality of a final analytical summary. DAgent addresses these gaps by providing both a robust framework and a specialized evaluation dataset.

System Architecture

DAgent is a modular agent framework consisting of three core pillars designed to handle the intricacies of data analysis:

  1. Planning Module: Acting as the system's "brain," this module evaluates if a question is complex enough to require decomposition. If so, it breaks the query into logically independent sub-questions, dynamically selects the best retrieval strategy, and coordinates SQL optimization.
  2. Tools Module: A suite of specialized functions including:
  3. Problem Decomposition: Utilizes domain-specific LoRA (Low-Rank Adaptation) weights to adapt to different fields (e.g., finance or healthcare) without retraining the entire model.
  4. Hybrid Data Retrieval: Combines direct vector encoding for semantic flexibility with Text-to-SQL for structural precision.
  5. SQL Rewriting: Optimizes raw SQL to ensure results are compact and relevant, preventing "data dumps" that can degrade the final report quality.
  6. Report Generation: Synthesizes retrieved data into a structured report using specialized prompt templates.
  7. Memory Module: Stores historical user questions, intermediate execution results, and successful planning paths, allowing the agent to learn from previous steps and avoid redundant computation.
The DAgent architecture illustrating the interaction between the Planning, Tools, and Memory modules to generate a final report.

The DA-Dataset Benchmark

To evaluate the system, the authors introduced DA-Dataset, a multi-domain benchmark specifically for analytical report generation. It contains 735 entries divided into two subsets:

  • DA-CCKS: 201 entries derived from financial datasets, emphasizing complex risk management and asset evaluation.
  • DA-BIRD: 535 entries built from the BIRD dataset, covering a broader range of general analytical tasks.

On average, each question in this dataset requires information from 4.5 tables and 10.8 columns, highlighting its complexity compared to standard benchmarks. The dataset is synthesized by combining multiple simple Question-SQL pairs into a single complex analytical prompt.

The question synthesis process used to create the DA-Dataset, transforming simple pairs into complex analytical questions.

Key Insights and Results

DAgent was compared against several baselines, including standard LLMs, Text-to-SQL models (like C3 and FinSQL), and TableQA frameworks (like TableRAG). Key findings include:

  • Decomposition and Hybrid Retrieval: Ablation studies show that breaking complex questions into sub-queries significantly boosts retrieval accuracy. Combining Text-to-SQL with vector-based retrieval captures both structural precision and semantic flexibility.
  • Retrieval Performance: On the DA-BIRD dataset, DAgent achieved a Precision of 81.23% and an F1-score of 82.23%, substantially outperforming TableRAG (F1 of 72.77%).
  • Report Quality: Using an LLM-based evaluation (scale 0-10), DAgent scored 6.43 in Accuracy and 7.01 in Report Relevance on the DA-BIRD set, compared to 4.16 and 6.40 for standard LLM-SQL approaches.
  • Efficiency: The SQL Rewrite module successfully reduced data redundancy without a significant drop in retrieval performance, proving that concise data leads to better report generation.

Conclusion and Future Work

DAgent demonstrates that a modular, agentic approach can effectively bridge the gap between raw database queries and high-level data analysis. While powerful, future work will focus on optimizing integrated reasoning mechanisms and enhancing the agent's ability to handle extremely large-scale database schemas where complexity exceeds 10+ tables.

Summary updated

BibTeX
@misc{xu2025dagent,
  author = {Wenyi Xu and Yuren Mao and Xiaolu Zhang and Chao Zhang and Xuemei Dong and Mengfei Zhang and Yunjun Gao},
  title = {{DAgent: A Relational Database-Driven Data Analysis Report Generation Agent}},
  year = {2025},
  eprint = {2503.13269},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.13269},
}
Figure