cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Accept widget value during runtime from user

LJ
New Contributor II

list1 = ('alpha', 'beta', 'gamma', 'eta', 'Theta')

list2 = ('alpha', 'beta')

df1 = spark.createDataFrame(list1, 'String').withColumnRenamed('value', 'dataset')

df2 = spark.createDataFrame(list2, 'String').withColumnRenamed('value', 'dataset')

df = df1.exceptAll(df2)

list_of_values = [data[0] for data in df.collect()]

dbutils.widgets.dropdown("dataset", list_of_values[0], list_of_values)

dataset = dbutils.widgets.get("dataset")

print(dataset)

In above code is there a way to get data from user after widget creation?

1 ACCEPTED SOLUTION

Accepted Solutions

Hubert-Dudek
Esteemed Contributor III

Every time the user change selection in the widget, you get that selection—behavior after the dropdown change you can define in widget settings.

image.png

View solution in original post

2 REPLIES 2

Hubert-Dudek
Esteemed Contributor III

Every time the user change selection in the widget, you get that selection—behavior after the dropdown change you can define in widget settings.

image.png

Kaniz
Community Manager
Community Manager

Hi @Liju Thomas​, We haven’t heard from you since the last response from @Hubert Dudek​ , and I was checking back to see if you have a resolution yet.

If you have any solution, please share it with the community, as it can be helpful to others. Otherwise, we will respond with more details and try to help.

Also, Please don't forget to click on the "Select As Best" button whenever the information provided helps resolve your question.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.