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

Why does the display name of widgets not match the specified name in SQL?

User16844444140
New Contributor II

However, I have no problem accessing the widget with the specified name. Screen Shot 2021-03-18 at 2.07.34 PM

3 REPLIES 3

Mooune_DBU
Valued Contributor

What would you like the display name (3rd positional argument of dbutils.widgets.text() and the default value (2nd positional argument) to be?

I believe you may be looking to do this:

dbutils.widgets.text("max_end_revenue_date",str(date.collect()[0]), "Max End Revenue Date ?")

Just to add on, the bug in the original code is that a DataFrame named date is being converted to a string via the call str(date) which in term is used as the third parameter, the label, which in turn gives the weird label DataFrame[max_end_revenue which is the left-most part of that to-string conversion of the DataFrame object.

You can see the documentation for these methods, and the parameter lists @Amine El Helou​ is referring to, by executing the command:

dbutils.widgets.help()

User16844444140
New Contributor II

Yep, I figured out the issue now. Both of you gave the right information to solve the problem.

My first mistake was as Jacob mentioned, `date` is actually a dataframe object here. To get the string date, I had to do similar to what Amine suggested. See the screenshot here.Screen Shot 2021-03-18 at 3.24.10 PMBut now I have a new problem: the date is shown as the key, rather than showing "max_end_revenue_date". This is what Amine pointed out.

From the documentation:

text(name: String, defaultValue: String, label: String): void -> Creates a text input widget with a given name and default value

I have a mistake in my code. The third argument is actually the label, which is what shows up in the UI. However, `name`, which is the first positional argument, is what we would use with `dbutils.widgets.get("name")` here.

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.