dataease / dataease/SQLBot

[BUG]SQL Parsing Fails for Valid LLM Outputs with Non-Standard JSON Structure

オープン
#725 コメント 4 件 リアクション 0 件 担当者 2 名 GitHub で見る

@xuwei-fit2cloud がすでに取り組んでいます。

2026年1月2日 から。

bug
主要言語
JavaScript
スター
6.8k
フォーク
882
平均マージ
4時間 37分
マージ済み PR(30日)
32

説明

SQLBot Version
1.5.1
Run Mode
Is it running in a Docker container or running from source code?
Docker
Describe the bug
When using local or open-source LLMs (e.g. Qwen2.5-32B, Qwen3-32B, LLaMA 3.x), SQLBot fails to parse valid SQL generated by the model and raises the error:
Cannot parse sql from answer
This happens even though the LLM output contains a correct and executable SQL statement.
The failure is caused by SQLBot relying on a strict JSON schema for parsing, while many LLMs return SQL in alternative but reasonable formats.
To Reproduce
Deploy SQLBot 1.5.1 using Docker
Configure a local LLM (Qwen2.5-32B / Qwen3-32B / LLaMA 3.x) via Ollama or vLLM
Ask a simple SQL question (e.g. daily aggregation query)
Let the LLM generate SQL
Observe the error:Cannot parse sql from answer
Example LLM output that is rejected:{
"query": "SELECT SUM(chulu_guoshu) FROM example_table WHERE DATE(insert_time) = '2025-12-31'"
}

Expected behavior
SQLBot should successfully extract and execute SQL as long as the generated SQL is valid, including cases such as:
{ "query": "SELECT ..." }
{ "sql": "SELECT ..." }
Nested JSON containing SQL
Plain SQL strings starting with SELECT
The system should not require a single rigid JSON structure for SQL parsing.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
SQLBot rejects valid SQL outputs that do not strictly match the expected JSON schema and throws:Cannot parse sql from answer
Additional context
This is not an SQL generation issue — the SQL itself is correct
The problem occurs at the SQL parsing stage only
Cloud models tend to follow the expected format, but local/open-source models do not
This significantly limits SQLBot’s usability with local LLM deployments
A more tolerant SQL extraction mechanism or fallback for raw SQL would greatly improve compatibility.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。