[UNBOUND_SQL_PARAMETER] When running Placeholder query

AadityaBhatt
New Contributor II

I am using the databricks-sql-go library version 1.5.2. I am trying to run a query with placeholders of type '?'

The query looks like 

params, args := databricksParams(values)
sql := fmt.Sprintf(`SELECT COUNT(*) FROM %s.%s WHERE %s IN (%s)`, schema, table, column, strings.Join(params, ", "))
res, err := conn.Exec(sql, args...)
where params is nothing but a slice of '?' and args are the values I want to query.
I am getting the error
[UNBOUND_SQL_PARAMETER] Found the unbound parameter: _58. Please, fix `args` and provide a mapping of the parameter to a SQL literal.; line 1 pos 58
I have tried with $1,$2 type placeholders as well. Is this not supported with Databricks or am I doing something incorrectly.

feiyun0112
Honored Contributor
# Query parameters

Passing parameters to a query is supported when run against servers with version DBR 14.1.

	p := dbsql.Parameter{Name: "p_bool", Value: true},
	rows, err1 := db.QueryContext(ctx, `select * from sometable where condition=:p_bool`,dbsql.Parameter{Name: "p_bool", Value: true})

databricks-sql-go/doc.go at main · databricks/databricks-sql-go (github.com)

AadityaBhatt
New Contributor II

This works fine when I have to pass just 1 argument. But how will this work where I have n number of values to pass inside an IN clause?

SergeRielau
Databricks Employee
Databricks Employee

Can you print out an example after the Sprintf substitutions?
It seems you generated a query with a named parameter: ":_58" But args (which should be a Map) does not have a key named "_58".