<?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: Access specific input item of For Each Tasks in Warehousing &amp; Analytics</title>
    <link>https://community.databricks.com/t5/warehousing-analytics/access-specific-input-item-of-for-each-tasks/m-p/108790#M1854</link>
    <description>&lt;P class="_1t7bu9h1 paragraph"&gt;&lt;SPAN&gt;To access the individual items from your list &lt;CODE&gt;[1, 2, 3, 4]&lt;/CODE&gt; in the notebook for each iteration of the For Each task, you can use the &lt;CODE&gt;{{input}}&lt;/CODE&gt; reference. Here’s a step-by-step example to help you understand how to achieve this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;P class="_1t7bu9h1 paragraph"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Define the For Each Task:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL class="_1t7bu9h7 _1t7bu9h2"&gt;
&lt;LI&gt;&lt;SPAN&gt;Create a new For Each task in your job configuration.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;Set the &lt;CODE&gt;inputs&lt;/CODE&gt; field to your list: &lt;CODE&gt;"[1, 2, 3, 4]"&lt;/CODE&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Configure the nested task that will run for each item in the list.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P class="_1t7bu9h1 paragraph"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Configure the Nested Task:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL class="_1t7bu9h7 _1t7bu9h2"&gt;
&lt;LI&gt;&lt;SPAN&gt;In the nested task, use the &lt;CODE&gt;{{input}}&lt;/CODE&gt; reference to access the current item in the iteration.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;For example, if you are using a notebook task, you can pass the &lt;CODE&gt;{{input}}&lt;/CODE&gt; as a parameter to the notebook.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P class="_1t7bu9h1 paragraph"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Access the Parameter in the Notebook:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL class="_1t7bu9h7 _1t7bu9h2"&gt;
&lt;LI&gt;&lt;SPAN&gt;In your notebook, use &lt;CODE&gt;dbutils.widgets.get&lt;/CODE&gt; to retrieve the parameter value.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P class="_1t7bu9h1 paragraph"&gt;Here’s an example configuration:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
  "name": "Process Items",
  "tasks": [
    {
      "task_key": "process_items",
      "for_each_task": {
        "inputs": "[1, 2, 3, 4]",
        "task": {
          "task_key": "process_item_iteration",
          "notebook_task": {
            "notebook_path": "/path/to/your/notebook",
            "base_parameters": {
              "item": "{{input}}"
            }
          }
        }
      }
    }
  ]
}&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 04 Feb 2025 13:30:32 GMT</pubDate>
    <dc:creator>Walter_C</dc:creator>
    <dc:date>2025-02-04T13:30:32Z</dc:date>
    <item>
      <title>Access specific input item of For Each Tasks</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/access-specific-input-item-of-for-each-tasks/m-p/108789#M1853</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I think I have a similar issue to the one in &lt;A href="https://community.databricks.com/t5/warehousing-analytics/access-each-input-item-of-a-for-each-task/m-p/102414#M1758" target="_self"&gt;this post&lt;/A&gt;, but the answer isn't detailed enough for me.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a list defined in my first task, which contains the items I want to iterate through [1,2,3,4]. When I use it as Inputs to the For Each framing task, I can see it as Input, e.g. Input = 1, Input = 2 but can't access it in the notebook so that I could use it as a variable in the second task (not the entire list, but just the item in the list).&lt;/P&gt;&lt;P&gt;Can you explain your comment, with an example?&lt;/P&gt;&lt;P&gt;I've tried using a Job Parameter, but when it prints in the notebook, it seems to output the same parameter value for every iteration in the looper, but I might be applying it wrongly.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 13:22:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/access-specific-input-item-of-for-each-tasks/m-p/108789#M1853</guid>
      <dc:creator>Hania__b</dc:creator>
      <dc:date>2025-02-04T13:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Access specific input item of For Each Tasks</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/access-specific-input-item-of-for-each-tasks/m-p/108790#M1854</link>
      <description>&lt;P class="_1t7bu9h1 paragraph"&gt;&lt;SPAN&gt;To access the individual items from your list &lt;CODE&gt;[1, 2, 3, 4]&lt;/CODE&gt; in the notebook for each iteration of the For Each task, you can use the &lt;CODE&gt;{{input}}&lt;/CODE&gt; reference. Here’s a step-by-step example to help you understand how to achieve this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;P class="_1t7bu9h1 paragraph"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Define the For Each Task:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL class="_1t7bu9h7 _1t7bu9h2"&gt;
&lt;LI&gt;&lt;SPAN&gt;Create a new For Each task in your job configuration.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;Set the &lt;CODE&gt;inputs&lt;/CODE&gt; field to your list: &lt;CODE&gt;"[1, 2, 3, 4]"&lt;/CODE&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Configure the nested task that will run for each item in the list.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P class="_1t7bu9h1 paragraph"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Configure the Nested Task:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL class="_1t7bu9h7 _1t7bu9h2"&gt;
&lt;LI&gt;&lt;SPAN&gt;In the nested task, use the &lt;CODE&gt;{{input}}&lt;/CODE&gt; reference to access the current item in the iteration.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;For example, if you are using a notebook task, you can pass the &lt;CODE&gt;{{input}}&lt;/CODE&gt; as a parameter to the notebook.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P class="_1t7bu9h1 paragraph"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Access the Parameter in the Notebook:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL class="_1t7bu9h7 _1t7bu9h2"&gt;
&lt;LI&gt;&lt;SPAN&gt;In your notebook, use &lt;CODE&gt;dbutils.widgets.get&lt;/CODE&gt; to retrieve the parameter value.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P class="_1t7bu9h1 paragraph"&gt;Here’s an example configuration:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
  "name": "Process Items",
  "tasks": [
    {
      "task_key": "process_items",
      "for_each_task": {
        "inputs": "[1, 2, 3, 4]",
        "task": {
          "task_key": "process_item_iteration",
          "notebook_task": {
            "notebook_path": "/path/to/your/notebook",
            "base_parameters": {
              "item": "{{input}}"
            }
          }
        }
      }
    }
  ]
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 04 Feb 2025 13:30:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/access-specific-input-item-of-for-each-tasks/m-p/108790#M1854</guid>
      <dc:creator>Walter_C</dc:creator>
      <dc:date>2025-02-04T13:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Access specific input item of For Each Tasks</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/access-specific-input-item-of-for-each-tasks/m-p/108791#M1855</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;You need a notebook to pass list:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;dbutils.jobs.taskValues.set(&lt;/SPAN&gt;&lt;SPAN&gt;key&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"list"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;value&lt;/SPAN&gt;&lt;SPAN&gt; = your&lt;/SPAN&gt;&lt;SPAN&gt;_list&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;In foreach you need a notebook with widgest to read passed parameters:&lt;/P&gt;&lt;P&gt;dbutils.widgets.text("param_1", "")&lt;BR /&gt;param_1 = dbutils.widgets.get("param_1")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 13:33:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/access-specific-input-item-of-for-each-tasks/m-p/108791#M1855</guid>
      <dc:creator>MariuszK</dc:creator>
      <dc:date>2025-02-04T13:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Access specific input item of For Each Tasks</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/access-specific-input-item-of-for-each-tasks/m-p/108794#M1856</link>
      <description>&lt;P&gt;Thank you both very much, I've nailed it &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;. I have accepted Walter_C's answer as solution because Step 2 is what I was missing. Thanks MariuszK as well for your contribution.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 13:51:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/access-specific-input-item-of-for-each-tasks/m-p/108794#M1856</guid>
      <dc:creator>Hania__b</dc:creator>
      <dc:date>2025-02-04T13:51:00Z</dc:date>
    </item>
  </channel>
</rss>

