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

Can assign a default value for job parameter from the widget?


The Databricks widget (dbutils) provides the get function for accessing the job parameters of a job.​


Unlike Python dict, where get returns None or an optional argument if the dict doesn't contain the parameter, the widget get will raise an error if there is no such parameter. The benefit of this design I guess is to promote failing early.

However, if you want an optional parameter in a PySpark script, is there a better way to implement this than to try to catch this error and defaulting from there? I noticed that there is a deprecated getArgument that does exactly this. However it is deprecated.

It also says that it is equivalent to get, but this is clearly not true as getArgument has the option of a default value.
get(name: String): String -> Retrieves current value of an input widget
getArgument(name: String, optional: String): String -> (DEPRECATED) Equivalent to get
test = dbutils.widgets.getArgument('test2', 'bla2')

That seems like a bug.


Honored Contributor

@Mattias P​ Hi. You can set the default parameter while giving dbutils.widgets.text('my_param',default_Value).

Not applicable

Hi @Mattias P​ 

Thank you for posting your question in our community! We are happy to assist you.

To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?

This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance!