<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can assign a default value for job parameter from the widget? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/can-assign-a-default-value-for-job-parameter-from-the-widget/m-p/6533#M2634</link>
    <description>&lt;P&gt;Hi @Mattias P​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for posting your question in our community! We are happy to assist you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2023 06:39:32 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-04-05T06:39:32Z</dc:date>
    <item>
      <title>Can assign a default value for job parameter from the widget?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-assign-a-default-value-for-job-parameter-from-the-widget/m-p/6531#M2632</link>
      <description>&lt;P&gt;The Databricks widget (dbutils) provides the get function for accessing the job parameters of a job.​&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;dbutils.widgets.get('my_param')&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unlike P&lt;A href="https://docs.python.org/3/library/stdtypes.html?highlight=dict#dict.get" alt="https://docs.python.org/3/library/stdtypes.html?highlight=dict#dict.get" target="_blank"&gt;ython dict&lt;/A&gt;, where &lt;I&gt;get&lt;/I&gt; returns None or an optional argument if the dict doesn't contain the parameter, the widget &lt;I&gt;get&lt;/I&gt; will raise an error if there is no such parameter. The benefit of this design I guess is to promote failing early.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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 &lt;I&gt;getArgument&lt;/I&gt; that does exactly this. However it is deprecated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It also says that it is equivalent to &lt;I&gt;get&lt;/I&gt;, but this is clearly not true as getArgument has the option of a default value.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;dbutils.widgets.help()
get(name: String): String -&amp;gt; Retrieves current value of an input widget
getArgument(name: String, optional: String): String -&amp;gt; (DEPRECATED) Equivalent to get
&amp;nbsp;
test = dbutils.widgets.getArgument('test2', 'bla2')
print(test)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;That seems like a bug.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 13:34:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-assign-a-default-value-for-job-parameter-from-the-widget/m-p/6531#M2632</guid>
      <dc:creator>fuselessmatt</dc:creator>
      <dc:date>2023-04-03T13:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can assign a default value for job parameter from the widget?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-assign-a-default-value-for-job-parameter-from-the-widget/m-p/6532#M2633</link>
      <description>&lt;P&gt;@Mattias P​&amp;nbsp;Hi. You can set the default parameter while giving dbutils.widgets.text('my_param',default_Value). &lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 07:34:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-assign-a-default-value-for-job-parameter-from-the-widget/m-p/6532#M2633</guid>
      <dc:creator>pvignesh92</dc:creator>
      <dc:date>2023-04-04T07:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Can assign a default value for job parameter from the widget?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-assign-a-default-value-for-job-parameter-from-the-widget/m-p/6533#M2634</link>
      <description>&lt;P&gt;Hi @Mattias P​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for posting your question in our community! We are happy to assist you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 06:39:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-assign-a-default-value-for-job-parameter-from-the-widget/m-p/6533#M2634</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-05T06:39:32Z</dc:date>
    </item>
  </channel>
</rss>

