Skip to content

[BUG] 生成的SQL语句字段不存在 #697

@harold227

Description

@harold227

SQLBot Version
1.4.0

Run Mode
Is it running in a Docker container or running from source code?
Docker container

Describe the bug
模型:Grok(换其他模型也出现过)
用户问题:新疆的塞浦路斯AAAA产品的提供商是谁?
生成SQL:
SELECT
c.CUSTOMER_NAME AS customer_name,
p.CUST_CURRENT_PROD AS product_name,
comp.COMPETITOR_NAME AS provider_name
FROM
sales.ai_cust_info c
JOIN sales.blade_region r ON c.PROVINCE = r.code
JOIN sales.ai_cust_prod cp ON c.ID = cp.CUST_ID
LEFT JOIN sales.ai_competitor comp ON FIND_IN_SET( comp.ID, cp.PROVIDER ) > 0
WHERE
c.CUSTOMER_NAME LIKE '%塞浦路斯%'
AND r.province_name LIKE '%新疆%'
AND cp.CUST_CURRENT_PROD LIKE '%AAAA%'
LIMIT 1000

查询字段 p.CUST_CURRENT_PROD ,就没有表的别名p,造成解析SQL报错。
之前还出现过表别名存在,查的字段在表里不存在。
小参数的模型还出现过,表别名和表名直接没有空格,反引号变成中文单引号,别名是保留字等问题。

是不是可以有个反思机制,对自己生成的SQL进行检查。

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions