Member-only story

Azure Databricks — How To Use Widgets

Tech Zero
4 min readDec 17, 2021

--

This article explains the use of widgets in Azure Databricks and how to use them.

Image credit — https://icon-icons.com/icon/widget/176615

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 —

  1. text: accepts string characters
  2. dropdown: provides a list of values
  3. combobox: provides a combination of string characters and dropdown. Basically, you have the option to either choose from the list or enter a text.
  4. 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.

Azure Databricks Python Function
(Azure Databricks Python Function)

The above function accepts country_name as an argument, passes it through a switch statement and returns the capital of the input argument…

--

--

Tech Zero
Tech Zero

Written by Tech Zero

Product Manager, Data & Governance | Azure, Databricks and Snowflake stack | Here to share my knowledge with everyone

No responses yet