dataease / dataease/SQLBot

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

Ouverte
#725 4 commentaires 0 réactions 2 personnes assignées Voir sur GitHub

@xuwei-fit2cloud y travaille déjà.

Depuis le 2/1/2026.

bug
Langage dominant
JavaScript
Étoiles
6.8k
Forks
882
Merge moyen
4 h 37 min
PR mergées (30 j)
32

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.