cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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

4 REPLIES 4

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. 

shan_chandra
Honored Contributor III
Honored Contributor III

@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 II

@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.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.