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

dbutils.notebook.run with multiselect parameter

gbrueckl
Contributor II

I have a notebook which has a parameter defined as

dbutils.widgets.multiselect("my_param", "ALL", ["ALL", "A", "B", "C")

and I would like to pass this parameter when calling the notebook via

dbutils.notebook.run()

However, I tried passing it as an python-array, JSON-array-string, etc. but nothing worked.

any one has any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions

-werners-
Esteemed Contributor III

I have not yet used a multiselect, but for a single value widget you get {"widget":"value"}

And according to the help:

When using dbutils.widgets.get() with a multiselect widget, you get a string of

comma delimited items that are selected by user.

So I would think you have to pass a comma separated string, so "ALL, A, B, C", a string object not an array.

View solution in original post

2 REPLIES 2

-werners-
Esteemed Contributor III

I have not yet used a multiselect, but for a single value widget you get {"widget":"value"}

And according to the help:

When using dbutils.widgets.get() with a multiselect widget, you get a string of

comma delimited items that are selected by user.

So I would think you have to pass a comma separated string, so "ALL, A, B, C", a string object not an array.

gbrueckl
Contributor II

you are right, this actually works fine.

I just realized I had two multiselect parameters in my tests and only changing one of them still resulted in the same error message for the second one 😕

I ended up writing a function that parses whatever comes in via the widget to an array/list which also supports JSON arrays now

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.