โ12-10-2023 03:59 AM
Hi,
I am trying to connect my database through LLM and expecting to receive a description of the table and 1st 3 rows from the table.
from langchain.agents import create_sql_agent
from langchain.agents.agent_toolkits import SQLDatabaseToolkit
from langchain.sql_database import SQLDatabase
from langchain import OpenAI
from langchain.agents.agent_types import AgentType
db = SQLDatabase.from_databricks(catalog="hive_metastore", schema="my_data", host="*****.gcp.databricks.com",api_token="dapi*****")
llm = OpenAI(temperature=0.9)
toolkit = SQLDatabaseToolkit(db=db, llm=llm)
agent = create_sql_agent(llm=llm, toolkit=toolkit, verbose=True)
agent.run("describe silver_tableabc")
The error that I am facing:
DatabaseError: (databricks.sql.exc.ServerOperationError) [UNBOUND_SQL_PARAMETER] Found the unbound parameter: param_1. Please, fix `args` and provide a mapping of the parameter to either a SQL literal or collection constructor functions such as `map()`, `array()`, `struct()`. SQLSTATE: 42P02; line 3 pos 7
[SQL: SELECT silver_tableabc.health,silver_tableabc.cust_id,... FROM silver_tableabc
LIMIT :param_1]
[parameters: {'param_1': 3}]
(Background on this error at: https://sqlalche.me/e/20/4xp6)
Version:
โ12-29-2023 05:28 AM
It worked after downgrading databricks-sql-connector to 2.9.3.
For the same question format: agent.run("what the job title of contact kevin young")
Thanks,
Murali
โ12-10-2023 05:12 AM
I am getting the same error when executing this notebook: https://docs.databricks.com/en/_extras/notebooks/source/machine-learning/large-language-models/sql-d...
โ12-28-2023 09:45 AM
Hi team,
We tried similar the approach as above with following versions of compatability DBR 14.2
โ12-29-2023 05:28 AM
It worked after downgrading databricks-sql-connector to 2.9.3.
For the same question format: agent.run("what the job title of contact kevin young")
Thanks,
Murali
โ01-04-2024 10:34 AM
This is not databricks issue but from langchain. A PR has been raised to solve this:
One workaround that worked is: https://github.com/langchain-ai/langchain/issues/11068 setting sample_rows_in_table_info to 0 when calling SQLDatabase.from_databricks() .
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโt want to miss the chance to attend and share knowledge.
If there isnโt a group near you, start one and help create a community that brings people together.
Request a New Group