cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now