Member-only story
This article explains the use of widgets in Azure Databricks and how to use them.
If you’re using Azure Databricks and building notebooks, parameterization is a requirement you cannot circumvent. In this article, I will demonstrate how to use widgets in Databricks to test our parameterization logic and what other use cases widgets can help with.
There are 4 types of widgets —
- text: accepts string characters
- dropdown: provides a list of values
- combobox: provides a combination of string characters and dropdown. Basically, you have the option to either choose from the list or enter a text.
- multiselect: provides options to select one or more options from a dropdown list
Note: The widget API has been made consistent across Scala, Python and R. There are slight differences when creating it from SQL though.
Let’s create a simple Python notebook and use a widget to pass parameters.
The above function accepts country_name as an argument, passes it through a switch statement and returns the capital of the input argument…