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

Pass catalog/schema/table name as a parameter to sql task

EdemSeitkh
New Contributor III

Hi, i am trying to pass catalog name as a parameter into query for sql task, and it pastes it with single quotes, which results in error. Is there a way to pass raw value or other possible workarounds? 

query:

INSERT INTO {{ catalog }}.pas.product_snapshot
SELECT ...

task parameters

 { "catalog": "dev" }

error message:

[PARSE_SYNTAX_ERROR] Syntax error at or near ''dev''.(line 1, pos 12) == SQL == INSERT INTO 'dev'.pas.product_snapshot  SELECT ...

Thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions

EdemSeitkh
New Contributor III

workaround that worked for me was to create databricks sql query, add enum parameter and use that query in task, instead of git file. 

View solution in original post

5 REPLIES 5

EdemSeitkh
New Contributor III

workaround that worked for me was to create databricks sql query, add enum parameter and use that query in task, instead of git file. 

dropdownlist works well, however it doesnt work when i do a dynamic parameter like {{task.name}}.

Any one got a solution?

shan_chandra
Esteemed Contributor
Esteemed Contributor

@EdemSeitkh  -  you may need to populate in a single quote -'{{ catalog }}'.  Hopefully, you had created a sql query in DBSQL query editor and it will provide the parameters to populate in the UI itself like below example. Screenshot 2024-01-23 at 10.00.50โ€ฏAM.png

 

EdemSeitkh
New Contributor III

@shan_chandra yes, i have created with DBSQL query and it worked fine. Previously it was using direct file from git and had this issue i described. 

lathaniel
New Contributor III

@EdemSeitkh  can you elaborate on your workaround? Curious how you were able to implement an enum paramter in DBSQL.

I'm running into this same issue now.

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