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.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!