Louis_Frolio
Databricks Employee
Databricks Employee
Try this
 
The SQL script snippet provided (DECLARE OR REPLACE var query = "SELECT :PARAMETER_1"; EXECUTE IMMEDIATE query;) will not work as intended in Databricks SQL because it uses a placeholder :PARAMETER_1 without properly assigning a value to it or using a parameterized query format compatible with Databricks SQL.
The error most likely corresponds to unbound SQL parameters, meaning the declared parameter (:PARAMETER_1) is not bound to a concrete value at execution time. Also, Databricks SQL doesn't support bound parameter syntax like PostgreSQL or Oracle.
To address this issue, you should:
  1. Directly substitute the desired value into the query string rather than using unbound parameters.
  2. Avoid usage of EXECUTE IMMEDIATE unless required in a procedural-like SQL flow. Typically, you would write queries in standard SQL directly.
Here is a working structure for SQL in Databricks for a valid query:
DECLARE my_param STRING;
SET my_param = 'desired_value';
SELECT ${my_param};
This approach ensures that the value is dynamically assigned and incorporated into the SQL query.
The error documentation from Azure Databricks confirms the need for properly binding or removing unbound parameters in SQL queries.
 
Cheers, Louis.