cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Missing selection for Parameter error

techg
New Contributor

Hi All,

I have created three parameters in an SQL query in Databricks. If no value is entered for a parameter, I would like the query to retrieve all values for that particular column. Currently, I'm getting an error message: "Missing selection for Parameter." How can I resolve this?

select * from table 

where country=:country

period=:period

Doc=:Document

If no value is entered for the 'Document' parameter, the query should retrieve all documents; otherwise, it should retrieve the value specified in the parameter

 

 

 

1 REPLY 1

Alberto_Umana
Databricks Employee
Databricks Employee

Hello @techg,

Could you try with below query?

SELECT * FROM table
WHERE (:country IS NULL OR country = :country)
AND (:period IS NULL OR period = :period)
AND (:Document IS NULL OR Doc = :Document)

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