其二,未解决。点击 查看SQL 是正常的SQL语句:
SELECT 数量 AS total_orders
FROM pods-bi-data.订单_订单总数
LIMIT 1000
然而,实际执行中,又加了一层嵌套,导致出错
Traceback (most recent call last):
File “/opt/sqlbot/app/apps/chat/task/llm.py”, line 869, in execute_sql
return exec_sql(ds=self.ds, sql=sql, origin_column=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘;\n) AS 订单_订单总数 LIMIT 1000’ at line 3”)
[SQL: SELECT 数量 AS total_orders FROM (SELECT SUM(qty) 数量
FROM bi_orders_051023
WHERE order_date>=‘2025-01-01 00:00:00’ LIMIT 1;
) AS 订单_订单总数 LIMIT 1000]
(Background on this error at: Error Messages — SQLAlchemy 2.0 Documentation)