How to pass task name as parameter in scheduled job that will be used as a schema name in query

jeroaranda
New Contributor II

I want to run a parametrized sql query in a task. Query:

 

select * from {{client}}.catalog.table

 

with client value being {{task.name}}.

if client is a string parameter, it is replaced with quotes which throws an error.
if table is a dropdown list parameter, it throws: The following parameter values are invalid: [{'key': 'client', 'value': 'randomclient'}]. 

How can I solve?

Zach_Jacobson23
Databricks Employee
Databricks Employee

Try this:

select * from identifier(:catalog||'.schema.table') 

The :catalog is a parameter within DBSQL

Replace schema and table with actual names