cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

DatabaseError: (databricks.sql.exc.ServerOperationError) [UNBOUND_SQL_PARAMETER]

nag_kanchan
New Contributor III

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
  • databricks-sql-connector: 3.0.0
     
    @Retired_mod COuld you please help me how can I resolve this?

 

1 ACCEPTED SOLUTION

Accepted Solutions

MuraliPinninti_
New Contributor III

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

View solution in original post

4 REPLIES 4

nag_kanchan
New Contributor III

MuraliPinninti_
New Contributor III

Hi team,

We tried similar the approach as above with following versions of compatability DBR 14.2

langchain==0.0.348 databricks-vectorsearch==0.22 openai==0.27 langchain-experimental databricks-sql-connector==3.0.0
 
In the run method there is no way to pass any positional parameters like {'param_1':3}.
Can you please help us how can i modify my below statement using set:param_1 to 3 statement to make it work?
 
agent.run("what the job title of contact kevin young")
 
Thanks,
Murali
 

 

MuraliPinninti_
New Contributor III

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

nag_kanchan
New Contributor III

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() .

Connect with Databricks Users in Your Area

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