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: 

CREATE WIDGETS in SQL Notebook attached to SQL Warehouse Doesn't Work.

JeremyH
New Contributor II

I'm able to create and use widgets using the UI in my SQL notebooks, but they get lost quite frequently when the notebook is reset.

There is documentation suggesting we can create widgets in code in SQL: https://learn.microsoft.com/en-us/azure/databricks/notebooks/widgets#sql-1

But pasting that exact code into a SQL cell in a SQL Notebook attached to a SQL Warehouse yields only this error message: 

[PARSE_SYNTAX_ERROR] Syntax error at or near 'WIDGET'. SQLSTATE: 42601 (line 1, pos 7)

 

Isn't that documentation simply wrong? I don't see any qualifying statements that suggest I should not be able to do this, yet clearly I can't.

4 REPLIES 4

shan_chandra
Esteemed Contributor
Esteemed Contributor

Hi @JeremyH - can you please try adding like the below in your query and see if widgets are getting populated?

{{parameter_name }}

I'm able to reference the widgets I create manually just fine, yes, I can use them as parameters in my queries. My issue is I don't want to recreate the widget every time the notebook is closed. In Python notebooks I create them in code so they are always there, and the docs seem to say this possible for SQL. But the CREATE WIDGET clause isn't recognized.

shan_chandra
Esteemed Contributor
Esteemed Contributor

@JeremyH - Say for example, I ran this query and saved it with a valid name and closed/reopened. the parameter is still present. 

select * from information_schema.catalogs
where catalog_name = {{catalog_name}}

SQL warehouses don’t support CREATE WIDGET statements. 

Sorry I said "closed" but I meant "cleared". When the Notebooks state is cleared (for example, after pulling in Git) the widget in the UI will disappear. The parameter still works if you pass it through a job. But for development I need the widget in the UI.


SQL warehouses don’t support CREATE WIDGET statements. 

Yes this was the conclusion I reached, but is it documented anywhere? And shouldn't it be documented where I linked to? Nothing there says anything about limitations of the compute type the notebook is attached to.

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!