<?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 How to restrict the values permitted in a job or task parameter? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-restrict-the-values-permitted-in-a-job-or-task-parameter/m-p/140617#M51488</link>
    <description>&lt;P&gt;Hi, apologies if this is a daft question - I'm relatively new to Databricks and still finding my feet!&lt;/P&gt;&lt;P&gt;I have a notebook with a parameter set within it via a widget, like this:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;dbutils.widgets.dropdown("My widget", "A", ["A", "B", "C"]) &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;my_variable = dbutils.widgets.get("My widget")&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;As you can see, the only options available to pick are&amp;nbsp;'A', 'B', and 'C'.I want to run this notebook through a job, so I can log runs. I want to set the value of my_variable through a job or task parameter in the job.&lt;/P&gt;&lt;P&gt;I know how to create a job or task parameter, and that the value this is set to can be picked up by widgets.get. However, I don't know how I can restrict the values that can be entered to 'A', 'B', and 'C'; there doesn't seem to be an option to do this.&lt;/P&gt;&lt;P&gt;Does anyone know how to do this please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Nov 2025 15:49:38 GMT</pubDate>
    <dc:creator>SRJDB</dc:creator>
    <dc:date>2025-11-28T15:49:38Z</dc:date>
    <item>
      <title>How to restrict the values permitted in a job or task parameter?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-restrict-the-values-permitted-in-a-job-or-task-parameter/m-p/140617#M51488</link>
      <description>&lt;P&gt;Hi, apologies if this is a daft question - I'm relatively new to Databricks and still finding my feet!&lt;/P&gt;&lt;P&gt;I have a notebook with a parameter set within it via a widget, like this:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;dbutils.widgets.dropdown("My widget", "A", ["A", "B", "C"]) &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;my_variable = dbutils.widgets.get("My widget")&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;As you can see, the only options available to pick are&amp;nbsp;'A', 'B', and 'C'.I want to run this notebook through a job, so I can log runs. I want to set the value of my_variable through a job or task parameter in the job.&lt;/P&gt;&lt;P&gt;I know how to create a job or task parameter, and that the value this is set to can be picked up by widgets.get. However, I don't know how I can restrict the values that can be entered to 'A', 'B', and 'C'; there doesn't seem to be an option to do this.&lt;/P&gt;&lt;P&gt;Does anyone know how to do this please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2025 15:49:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-restrict-the-values-permitted-in-a-job-or-task-parameter/m-p/140617#M51488</guid>
      <dc:creator>SRJDB</dc:creator>
      <dc:date>2025-11-28T15:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict the values permitted in a job or task parameter?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-restrict-the-values-permitted-in-a-job-or-task-parameter/m-p/140621#M51490</link>
      <description>&lt;P&gt;Databricks Job/Task parameter interface &lt;STRONG&gt;does not provide a built-in UI feature&lt;/STRONG&gt; to restrict the possible values entered by user. Yoou can add a runtime validation code inside the notebook to allow/fail based on the values entered in.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2025 16:42:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-restrict-the-values-permitted-in-a-job-or-task-parameter/m-p/140621#M51490</guid>
      <dc:creator>Raman_Unifeye</dc:creator>
      <dc:date>2025-11-28T16:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict the values permitted in a job or task parameter?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-restrict-the-values-permitted-in-a-job-or-task-parameter/m-p/140678#M51505</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/199244"&gt;@SRJDB&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Here is a work around, you can switch to the widget to text parameter and implement a enums. It helps in validation in both value as well as case check. Using enums in one of the best practices to use constant variables. More over you can add functions that can terminate the notebook gracefully if you have mentioned wrong values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use the below command to terminate the notebook,&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN&gt;dbutils.notebook.exit(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;Optional exit value or message&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Hope this helps.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 01 Dec 2025 05:12:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-restrict-the-values-permitted-in-a-job-or-task-parameter/m-p/140678#M51505</guid>
      <dc:creator>Prajapathy_NKR</dc:creator>
      <dc:date>2025-12-01T05:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict the values permitted in a job or task parameter?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-restrict-the-values-permitted-in-a-job-or-task-parameter/m-p/140781#M51531</link>
      <description>&lt;P&gt;Job/task parameters are free-form strings (or JSON) that get pushed down into tasks; there’s no built‑in way in Jobs to constrain them to an enum list like A/B/C in the UI or API. You can override them at run time, but they’re not validated against the widget choices.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;val = dbutils.widgets.get("My widget")

# Validate against your curated list
allowed = {"A", "B", "C"}
if val not in allowed:
    # Fail fast (or coerce to a default) so job runs are clearly logged as invalid
    raise ValueError(
        f"Invalid value for 'My widget': {val}. Allowed values are {sorted(allowed)}."
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 01 Dec 2025 19:17:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-restrict-the-values-permitted-in-a-job-or-task-parameter/m-p/140781#M51531</guid>
      <dc:creator>iyashk-DB</dc:creator>
      <dc:date>2025-12-01T19:17:53Z</dc:date>
    </item>
  </channel>
</rss>

