- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- Cluster: 14.2ML ( even tried with general purpose 14.2, 13.3)
- Langchain: 0.0.348 (even tried with 0.0.341)
- SQLAlchemy: 2.0.12
- Labels:
-
LLMs
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 09:45 AM
Hi team,
We tried similar the approach as above with following versions of compatability DBR 14.2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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() .

