pandas-ai
pandas-ai copied to clipboard
Pandasai Multiple Dataframe: sqlalchemy.exc.DatabaseError: (databricks.sql.exc.ServerOperationError) [UNRESOLVED_COLUMN.WITH_SUGGESTION]
System Info
Pandasai version: 2.0.42 Python version: 3.10.12
🐛 Describe the bug
I tried to pass in 2 tables into pandasai Agent and join a column which has different column name in 2 tables.
agent = Agent([table_userinfo, table_ticketinfo], config={"llm": llm})
answer = agent.chat(prompt)
I want to get the user info of a specific ticket. It can produce the correct code until step 5. [INFO] Code generated:
result_df = dfs[1].merge(dfs[0], left_on='reporter', right_on='name')
result_df = result_df[result_df['issue_id'] == 1][['LegalLastName', 'LegalFirstName', 'Email']]
result = {'type': 'dataframe', 'value': result_df}
However, it cannot execute the code successfully on step 6.
[INFO] Executing Step 6: CodeExecution
[ERROR] Failed with error: Traceback (most recent call last):
databricks.sql.exc.ServerOperationError: [UNRESOLVED_COLUMN.WITH_SUGGESTION] A column or function parameter with name issue_id
cannot be resolved. Did you mean one of the following? [Email
, ...].; line 3 pos 6
[SQL: SELECT *
FROM table_userinfo
WHERE issue_id = %(value_0)s]
[parameters: {'value_0': 1}]
(Background on this error at: https://sqlalche.me/e/14/4xp6)
I don't understand why the code is correct about getting issue_id from the merged table, but then the SQL code try to get issue_id from the userinfo table. What might be the suitable input prompt for multiple table scenarios, or how to solve the issue?