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:ย 

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.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group