06-14-2024 11:24 AM
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.
06-14-2024 12:30 PM
Hi @JeremyH - can you please try adding like the below in your query and see if widgets are getting populated?
06-14-2024 01:12 PM
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.
06-14-2024 01:36 PM
@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.
06-17-2024 05:53 AM
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 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