I am trying to use create widget in SQL Notebooks on SQL warehouse, but it give me SQL Syntax error:
CREATE WIDGET TEXT ENVIRONMENT DEFAULT "uat";
[PARSE_SYNTAX_ERROR] Syntax error at or near 'WIDGET'.(line 2, pos 7)
== SQL ==
--
CREATE WIDGET TEXT ENVIRONMENT DEFAULT "uat"
Can anyone help me resolve above error?
As per this Documentation, It is only mentioned about the usage of the existing Widgets in the SQL warehouse but not the creation of the widgets through SQL code.
You can see that it is giving the same result for the removal of widget as well.
It seems to be currently, creation and removal of widgets through SQL code is not supported in SQL warehouse. You can raise the feature request for that here.
If you want to use widgets, you can create the and remove the widgets by using the notebook UI. Go to Edit-> Add widget -> create widget like below.
After creating widget, you can access the widget value in the SQL warehouse notebook by using :<widget_name>
like below.
(OR) As a workaround, you can maintain a table for the required widgets where table has column for the required widgets. You can update the row or remove the column as per your requirement and use the row value to access the widget value.