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:ย 

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?

1 REPLY 1

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

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