-
Notifications
You must be signed in to change notification settings - Fork 777
Intermittent Syntax Error in WrenAI on Identical Input #1661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@UMANET123 could you also share ibis container log? and what is your pg version? thanks |
Hi @cyyeh, Thank you for your quick response. Please find the below requested details. We are using Postgres SQL 12. 22 Please find the Wren-Ul error logs: 2025-05-16T06:17:24.450] [INFO] AskingTaskTracker - Polling for updates for task 83a84def-ca2a-4207-9211-447496b25e64 [2025-05-16T06:17:25.451] [INFO] AskingTaskTracker - Polling for updates for task 83a84def-ca2a-4207-9211-447496b25e64 [2025-05-16T06:17:26.069] [DEBUG] QueryService - Use ibis adaptor to preview [2025-05-16T06:17:26.076] [DEBUG] IbisAdaptor - Dry run sql from ibis with body: [2025-05-16T06:17:26.076] [DEBUG] IbisAdaptor - Using ibis v3 api [2025-05-16T06:17:26.222] [INFO] IbisAdaptor - Got error when dry running ibis [2025-05-16T06:17:26.452] [INFO] AskingTaskTracker - Polling for updates for task 83a84def-ca2a-4207-9211-447496b25e64 [2025-05-16T06:17:26.459] [INFO] AskingTaskTracker - Updating task 83a84def-ca2a-4207-9211-447496b25e64 in database [2025-05-16T06:17:27.453] [INFO] AskingTaskTracker - Polling for updates for task 83a84def-ca2a-4207-9211-447496b25e64 [2025-05-16T06:17:28.454] [INFO] AskingTaskTracker - Polling for updates for task 83a84def-ca2a-4207-9211-447496b25e64 [2025-05-16T06:17:28.718] [DEBUG] QueryService - Use ibis adaptor to preview [2025-05-16T06:17:28.723] [DEBUG] IbisAdaptor - Dry run sql from ibis with body: [2025-05-16T06:17:28.723] [DEBUG] IbisAdaptor - Using ibis v3 api [2025-05-16T06:17:28.880] [INFO] IbisAdaptor - Got error when dry running ibis [2025-05-16T06:17:29.454] [INFO] AskingTaskTracker - Polling for updates for task 83a84def-ca2a-4207-9211-447496b25e64 [2025-05-16T06:17:29.459] [INFO] AskingTaskTracker - Updating task 83a84def-ca2a-4207-9211-447496b25e64 in database [2025-05-16T06:17:29.465] [INFO] AskingTaskTracker - Task 83a84def-ca2a-4207-9211-447496b25e64 is finalized with status: FAILED As requested please find the IBIS error logs: 2025-05-16 06:59:49.061 | [b123e993-6ad5-4293-9b5d-3589d884e292] | ERROR | main.custom_http_error_handler:77 - Request failed Traceback (most recent call last): File "/app/mdl/rewriter.py", line 119, in rewrite
File "/app/.venv/lib/python3.11/site-packages/anyio/to_thread.py", line 56, in run_sync
File "/app/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 2461, in run_sync_in_worker_thread
File "/app/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 962, in run
Exception: DataFusion error: Error during planning: table 'wrenai.public.person' not found During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/routers/v3/connector.py", line 51, in query
File "/app/.venv/lib/python3.11/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper
File "/app/mdl/rewriter.py", line 57, in rewrite
File "/app/.venv/lib/python3.11/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper
File "/app/mdl/rewriter.py", line 121, in rewrite
app.mdl.rewriter.RewriteError: DataFusion error: Error during planning: table 'wrenai.public.person' not found During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/model/connector.py", line 61, in dry_run
File "/usr/local/lib/python3.11/contextlib.py", line 81, in inner
File "/app/model/connector.py", line 77, in dry_run
File "/app/.venv/lib/python3.11/site-packages/ibis/backends/sql/init.py", line 179, in sql
File "/app/.venv/lib/python3.11/site-packages/ibis/backends/postgres/init.py", line 547, in _get_schema_using_query
File "/usr/local/lib/python3.11/contextlib.py", line 137, in enter
File "/app/.venv/lib/python3.11/site-packages/ibis/backends/postgres/init.py", line 710, in _safe_raw_sql
File "/app/.venv/lib/python3.11/site-packages/ibis/backends/postgres/init.py", line 735, in raw_sql
File "/app/.venv/lib/python3.11/site-packages/psycopg/cursor.py", line 97, in execute
psycopg.errors.UndefinedTable: relation "person" does not exist LINE 1: ...("so"."customerid" = "c"."customerid") INNER JOIN "person" A...
During handling of the above exception, another exception occurred: Traceback (most recent call last):
File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
File "/app/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
File "/app/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
File "/app/routers/v3/connector.py", line 64, in query
File "/app/routers/v2/connector.py", line 63, in query
File "/app/model/connector.py", line 63, in dry_run
app.model.connector.QueryDryRunError: Exception: <class 'psycopg.errors.UndefinedTable'>, message: relation "person" does not exist LINE 1: ...("so"."customerid" = "c"."customerid") INNER JOIN "person" A...
2025-05-16 06:59:49.069 | [b123e993-6ad5-4293-9b5d-3589d884e292] | INFO | init.dispatch:29 - Request ended 2025-05-16 06:59:48.971 | [b123e993-6ad5-4293-9b5d-3589d884e292] | WARNING | connector.query:60 - Failed to execute v3 query, fallback to v2: DataFusion error: Error during planning: table 'wrenai.public.person' not found Wren engine is migrating to Rust version now. Wren AI team are appreciate if you can provide the error messages and related logs for us. 2025-05-16 06:59:48.979 | [b123e993-6ad5-4293-9b5d-3589d884e292] | DEBUG | rewriter.rewrite:56 - Extracted manifest: eyJjYXRhbG9nIjoid3JlbmFpIiwic2NoZW1hIjoicHVibGljIiwibW9kZWxzIjpbeyJuYW1lIjoicGVyc29uX3BlcnNvbiIsInJlZlNxbCI6bnVsbCwiYmFzZU9i 2025-05-16 06:59:40.346 | [a80951b7-ebaf-4d1f-b8e4-fe2991ca1511] | ERROR | main.custom_http_error_handler:77 - Request failed Traceback (most recent call last): File "/app/mdl/rewriter.py", line 119, in rewrite
File "/app/.venv/lib/python3.11/site-packages/anyio/to_thread.py", line 56, in run_sync
File "/app/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 2461, in run_sync_in_worker_thread
File "/app/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 962, in run
Exception: DataFusion error: Error during planning: table 'wrenai.person.person' not found During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/routers/v3/connector.py", line 51, in query
File "/app/.venv/lib/python3.11/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper
File "/app/mdl/rewriter.py", line 57, in rewrite
File "/app/.venv/lib/python3.11/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper
File "/app/mdl/rewriter.py", line 121, in rewrite
app.mdl.rewriter.RewriteError: DataFusion error: Error during planning: table 'wrenai.person.person' not found During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/model/connector.py", line 61, in dry_run
File "/usr/local/lib/python3.11/contextlib.py", line 81, in inner
File "/app/model/connector.py", line 77, in dry_run
File "/app/.venv/lib/python3.11/site-packages/ibis/backends/sql/init.py", line 179, in sql
File "/app/.venv/lib/python3.11/site-packages/ibis/backends/postgres/init.py", line 547, in _get_schema_using_query
File "/usr/local/lib/python3.11/contextlib.py", line 137, in enter
File "/app/.venv/lib/python3.11/site-packages/ibis/backends/postgres/init.py", line 710, in _safe_raw_sql
File "/app/.venv/lib/python3.11/site-packages/ibis/backends/postgres/init.py", line 735, in raw_sql
File "/app/.venv/lib/python3.11/site-packages/psycopg/cursor.py", line 97, in execute
psycopg.errors.UndefinedColumn: column p.customerid does not exist LINE 1: ...N "person"."person" AS "p" ON ("c"."customerid" = "p"."custo...
HINT: Perhaps you meant to reference the column "c.customerid". During handling of the above exception, another exception occurred: Traceback (most recent call last):
File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
File "/app/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
File "/app/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
File "/app/routers/v3/connector.py", line 64, in query
File "/app/routers/v2/connector.py", line 63, in query
File "/app/model/connector.py", line 63, in dry_run
app.model.connector.QueryDryRunError: Exception: <class 'psycopg.errors.UndefinedColumn'>, message: column p.customerid does not exist LINE 1: ...N "person"."person" AS "p" ON ("c"."customerid" = "p"."custo...
HINT: Perhaps you meant to reference the column "c.customerid". 2025-05-16 06:59:40.349 | [a80951b7-ebaf-4d1f-b8e4-fe2991ca1511] | INFO | init.dispatch:29 - Request ended 2025-05-16 06:59:48.952 | [b123e993-6ad5-4293-9b5d-3589d884e292] | INFO | init.dispatch:14 - POST /v3/connector/postgres/query 2025-05-16 06:59:48.952 | [b123e993-6ad5-4293-9b5d-3589d884e292] | INFO | init.dispatch:15 - Request params: {'dryRun': 'true'} 2025-05-16 06:59:48.953 | [b123e993-6ad5-4293-9b5d-3589d884e292] | INFO | init.dispatch:22 - Request body: {"sql":"SELECT CONCAT("p"."firstname", ' ', "p"."middlename", ' ', "p"."lastname") AS "customer_name", ROUND(SUM("so"."totaldue"), 2) AS "total_sales_value" FROM "sales_salesorderheader" AS "so" JOIN "sales_customer" AS "c" ON "so"."customerid" = "c"."customerid" JOIN "person" AS "p" ON "c"."customerid" = "p"."customerid" WHERE CAST("so"."orderdate" AS TIMESTAMP WITH TIME ZONE) >= CAST('2024-01-01 00:00:00' AS TIMESTAMP WITH TIME ZONE) AND CAST("so"."orderdate" AS TIMESTAMP WITH TIME ZONE) < CAST('2025-01-01 00:00:00' AS TIMESTAMP WITH TIME ZONE) GROUP BY 1 ORDER BY "total_sales_value" DESC" Kindly let us know, if you need any other details. |
Hi Team,
We have successfully implemented and configured WrenAI in our production environment, and it is working well overall. However, we are occasionally encountering a syntax error when processing a specific question. Interestingly, the same question sometimes returns the expected output without any issues.
Please find the screenshot attached for your reference.
we are using Open Al LLM API KEY.
Data connection error
invalid input syntax for type bigint: "2025-03-13"
and
Required keyword: 'expression' missing for <class 'sqlglot.expressions.JSONExtract'>. Line 1, Col: 48.
SELECT CONCAT(LAX_STRING(JSON_QUERY(p.firstname�[4m)�[0m), ' ', LAX_STRING(JSON_QUERY(p.middlename)), ' ', LAX_STRING(JSON_QUERY(p.lastname))) AS customer_n
Required keyword: 'expression' missing for <class 'sqlglot.expressions.JSONExtract'>. Line 1, Col: 91.
SELECT CONCAT(LAX_STRING(JSON_QUERY(p.firstname)), ' ', LAX_STRING(JSON_QUERY(p.middlename�[4m)�[0m), ' ', LAX_STRING(JSON_QUERY(p.lastname))) AS customer_name, ROUND(SUM(ssh.totaldue), 2) AS total_s
Required keyword: 'expression' missing for <class 'sqlglot.expressions.JSONExtract'>. Line 1, Col: 132.
UERY(p.firstname)), ' ', LAX_STRING(JSON_QUERY(p.middlename)), ' ', LAX_STRING(JSON_QUERY(p.lastname�[4m)�[0m)) AS customer_name, ROUND(SUM(ssh.totaldue), 2) AS
total_sales_value FROM sales_salesorderheader AS
and
Exception: <class 'psycopg.errors.CannotCoerce'>, message: cannot cast type integer to timestamp with time zone
LINE 1: ...ON ("so"."customerid" = "c"."customerid") WHERE ((CAST("so"....
The text was updated successfully, but these errors were encountered: