SQL Positional parameters: INVALID_PARAMETER_MARKER_VALUE.DUPLICATE_NAME
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 09:01 AM
When trying to execute a query via sql warehouse, I get the following error:
INVALID_PARAMETER_MARKER_VALUE.DUPLICATE_NAME
the sql statement uses ? placeholders and the correct number of arguments are being passed.
I am not able to use named placeholders with my library, before I refactor I am wondering if there is something I am missing.
Sample SQL:
SELECT client_ip, count(*) as requests FROM {redacted} WHERE log_event_hour >= ? AND log_event_hour <= ? AND log_event_date >= ? AND log_event_date <= ? LIMIT 10 args: [1724332222,1724335822,"2024-08-22","2024-08-22"]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 09:41 AM - edited 08-22-2024 09:47 AM
Hi @RickB ,
Which API are you using to invoke this? Parameter markers can be provided by:
Python using its pyspark.sql.SparkSession.sql() API.
Scala using its org.apache.spark.sql.SparkSession.sql() API.
Java using its org.apache.spark.sql.SparkSession.sql() API.
- SQL
Because in each one there are subtle differences how to provide arguments to unnamed parameter markers. Take a look at below documentation entry:
Parameter markers | Databricks on AWS
If you are using sql, you should have something like below (example from documentation)
> DECLARE stmtStr = 'SELECT current_timestamp() + ?, ? * ? AS square';
> EXECUTE IMMEDIATE stmtStr USING INTERVAL '3' HOURS, 15.0, 15.0;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 02:01 AM
I am using the go-sql-driver: https://docs.databricks.com/en/dev-tools/go-sql-driver.html
Looking through the code it looks like it only works with named params which is a shame.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 02:08 AM
Hi @RickB ,
Yeah, I've checked github repo and it looks like it currently supports only named params 😕
databricks-sql-go/parameters.go at main · databricks/databricks-sql-go · GitHub