Abstract
SPORTSQL is a modular, end-to-end system designed to bridge the gap between complex relational sports databases and non-expert fans. By translating natural language questions into executable SQL and generating real-time visualizations, the system enables reasoning over hyper-dynamic datasets like the Fantasy Premier League. This paper introduces the SPORTSQL architecture and DSQABENCH, a new 1,700+ query benchmark. Evaluation reveals that while the system excels at simple retrieval, it faces a "complexity cliff" as the number of reasoning primitives increases, highlighting current limitations in multi-clause SQL generation for large language models.
Introduction
While Large Language Models (LLMs) have become adept at generating code, most existing Text-to-SQL systems are designed for static, "frozen" datasets. In the real world, domains like sports are hyper-dynamic: player stats, injury reports, and league standings change daily. Relying on an LLM's internal knowledge leads to "hallucinations" (outdated stats), while standard Retrieval-Augmented Generation (RAG) often struggles with complex relational reasoning, such as calculating averages over specific recent windows.
SPORTSQL addresses the challenge of building a system that is both grounded in real-time truth and capable of sophisticated symbolic reasoning over a constantly shifting database schema. It provides a modular pipeline that translates fan queries into live data insights and visualizations.
System Architecture
The authors developed a modular pipeline for SPORTSQL consisting of four primary stages designed to handle the volatility of sports data:
- Database Streaming & Hybrid Storage: The system scrapes the Fantasy Premier League (FPL) API. To keep the database lean, it uses a two-tiered strategy: "Query-agnostic" tables (core stats) are updated nightly, while "Query-dependent" tables (fine-grained views like "past 5 games") are fetched via API on-demand and materialized in memory only for the duration of the query.
- Entity Recognition: Since fans frequently use nicknames (e.g., "CR7"), the system uses an LLM to map surface forms to canonical IDs via case-insensitive wildcard SQL lookups before generating the final query.
- Schema-Driven SQL Generation: The system prompts an LLM using only the database schema and "targeted hints" (e.g., "penalty saves are for goalkeepers only") to generate executable SQL. This ensures the model reasons about the structure without needing to see the actual underlying data.
- Visual Output Generation: If a query implies a trend or comparison, a secondary LLM agent generates Matplotlib or Seaborn code to produce charts alongside the raw data.
The DSQABENCH Dataset
To evaluate the system, the paper introduces DSQABENCH (Dynamic Sport Question Answering Benchmark). This dataset contains 1,793 questions derived from 180 base templates. Each question is paired with a manually authored SQL program, a "gold" answer, and a database snapshot from the time of execution. The benchmark covers various soccer metrics and reasoning types, including 398 queries that require just-in-time API access for player-specific history or future fixtures.
Experimental Results and Reasoning Analysis
The researchers evaluated the system using GPT-4o and Gemini-2.0 Flash. GPT-4o achieved a top performance of 80.48% exact-match accuracy on string-based answers and a 0.75 macro-F1 score on tabular data, consistently outperforming Gemini-2.0 Flash by approximately 4.2 points.
One of the most significant findings is the "Complexity Cliff." While system performance is excellent (~93% accuracy) for single-step queries (e.g., simple retrieval), accuracy drops sharply to 67% with two primitives and stabilizes near 50% for three or more. This highlights a significant reasoning gap in current LLMs when handling multi-clause SQL.
Further analysis identified that operations involving JOIN, UNION, or MERGE (categorized as "Manipulate") are the primary failure points, scoring as low as 15.4% accuracy. In contrast, the system is nearly perfect at "Retrieve" (100%) and "Order" (97.6%) tasks.
Conclusion and Future Work
SPORTSQL demonstrates that a hybrid storage strategy and schema-only prompting can maintain a robust, real-time reasoning system while keeping the database footprint small (under 5GB). However, limitations remain, such as the "Tie Problem" where standard LIMIT clauses may arbitrarily exclude tied players, and the current restriction to English-language queries for the Premier League.
Future work will focus on expanding the system to other sports like the NBA and NFL, as well as applying the architecture to other dynamic domains such as finance and healthcare. The authors also plan to support multi-turn conversational analysis to allow fans to dive deeper into data through follow-up questions.
Summary updated