<?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: Get task_run_id that is nested in a job_run task in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/get-task-run-id-that-is-nested-in-a-job-run-task/m-p/153721#M53999</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi — good question. The cleanest way to do this is with &lt;/SPAN&gt;&lt;STRONG&gt;task values&lt;/STRONG&gt;&lt;SPAN&gt;, no REST API needed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Approach: Task Values (Recommended)&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;In &lt;/SPAN&gt;&lt;STRONG&gt;Child 1's notebook&lt;/STRONG&gt;&lt;SPAN&gt;, capture its own run_id and set it as a task value:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;import json&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ctx = json.loads(&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dbutils.notebook.entry_point.getDbutils().notebook().getContext().toJson()&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;child1_run_id = ctx["currentRunId"]["id"]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;dbutils.jobs.taskValues.set(key="child1_run_id", value=str(child1_run_id))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then in your &lt;/SPAN&gt;&lt;STRONG&gt;orchestrator job&lt;/STRONG&gt;&lt;SPAN&gt;, when configuring Parent 2's job parameters, reference it with:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;{{tasks.Parent1.values.child1_run_id}}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Task values set inside a child job are propagated back through the &lt;/SPAN&gt;&lt;SPAN&gt;run_job&lt;/SPAN&gt;&lt;SPAN&gt; task, so the orchestrator can access them via &lt;/SPAN&gt;&lt;SPAN&gt;{{tasks.&amp;lt;run_job_task_name&amp;gt;.values.&amp;lt;key&amp;gt;}}&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Why not &lt;/STRONG&gt;&lt;STRONG&gt;{{tasks.Parent1.run_id}}&lt;/STRONG&gt;&lt;STRONG&gt;?&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;As you noticed, &lt;/SPAN&gt;&lt;SPAN&gt;{{tasks.Parent1.run_id}}&lt;/SPAN&gt;&lt;SPAN&gt; gives you the &lt;/SPAN&gt;&lt;STRONG&gt;orchestrator's task run_id&lt;/STRONG&gt;&lt;SPAN&gt; for the run&lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;job task itself — not the child job's internal task run&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt;id. That's why task values are the right tool here: they let the child task explicitly publish its own metadata for upstream consumption.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;REST API Fallback&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;If you &lt;/SPAN&gt;&lt;STRONG&gt;can't modify&lt;/STRONG&gt;&lt;SPAN&gt; Child 1's notebook, then yes, the REST API approach works:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Pass &lt;/SPAN&gt;&lt;SPAN&gt;{{tasks.Parent1.run_id}}&lt;/SPAN&gt;&lt;SPAN&gt; into an intermediate notebook task&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Use the &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/api/workspace/jobs/get-run" target="_blank"&gt;&lt;SPAN&gt;Runs Get API&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; to fetch the triggered child job's run details and extract Child 1's task run_id from the &lt;/SPAN&gt;&lt;SPAN&gt;tasks&lt;/SPAN&gt;&lt;SPAN&gt; array&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;SPAN&gt;But if you can add a couple of lines to Child 1, the task values approach is simpler and avoids API calls entirely.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Docs:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;A href="https://docs.databricks.com/aws/en/jobs/task-values" target="_blank"&gt;&lt;SPAN&gt;Task Values&lt;/SPAN&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;A href="https://docs.databricks.com/aws/en/jobs/dynamic-value-references" target="_blank"&gt;&lt;SPAN&gt;Dynamic Value References&lt;/SPAN&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;Hope that helps!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Apr 2026 10:56:33 GMT</pubDate>
    <dc:creator>anuj_lathi</dc:creator>
    <dc:date>2026-04-08T10:56:33Z</dc:date>
    <item>
      <title>Get task_run_id that is nested in a job_run task</title>
      <link>https://community.databricks.com/t5/data-engineering/get-task-run-id-that-is-nested-in-a-job-run-task/m-p/153660#M53992</link>
      <description>&lt;P&gt;Hi, I'm wondering if there is an easier way to accomplish this.&lt;/P&gt;&lt;P&gt;I can use Dynamic Value reference to pull the run_id of Parent 1 into Parent 2, however, what I'm looking for is for Child 1's task run_id to be referenced within Parent 2.&lt;/P&gt;&lt;P&gt;Currently I am considering using the databricks REST API to get the run_id of a notebook task (Child 1) that is nested inside a run_job task (Parent 1), that I can later reference in another run_job task downstream (Parent 2).&lt;/P&gt;&lt;P&gt;Would there be another/easier way of doing this?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2026 22:29:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/get-task-run-id-that-is-nested-in-a-job-run-task/m-p/153660#M53992</guid>
      <dc:creator>ChristianRRL</dc:creator>
      <dc:date>2026-04-07T22:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Get task_run_id that is nested in a job_run task</title>
      <link>https://community.databricks.com/t5/data-engineering/get-task-run-id-that-is-nested-in-a-job-run-task/m-p/153721#M53999</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi — good question. The cleanest way to do this is with &lt;/SPAN&gt;&lt;STRONG&gt;task values&lt;/STRONG&gt;&lt;SPAN&gt;, no REST API needed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Approach: Task Values (Recommended)&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;In &lt;/SPAN&gt;&lt;STRONG&gt;Child 1's notebook&lt;/STRONG&gt;&lt;SPAN&gt;, capture its own run_id and set it as a task value:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;import json&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ctx = json.loads(&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dbutils.notebook.entry_point.getDbutils().notebook().getContext().toJson()&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;child1_run_id = ctx["currentRunId"]["id"]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;dbutils.jobs.taskValues.set(key="child1_run_id", value=str(child1_run_id))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then in your &lt;/SPAN&gt;&lt;STRONG&gt;orchestrator job&lt;/STRONG&gt;&lt;SPAN&gt;, when configuring Parent 2's job parameters, reference it with:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;{{tasks.Parent1.values.child1_run_id}}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Task values set inside a child job are propagated back through the &lt;/SPAN&gt;&lt;SPAN&gt;run_job&lt;/SPAN&gt;&lt;SPAN&gt; task, so the orchestrator can access them via &lt;/SPAN&gt;&lt;SPAN&gt;{{tasks.&amp;lt;run_job_task_name&amp;gt;.values.&amp;lt;key&amp;gt;}}&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Why not &lt;/STRONG&gt;&lt;STRONG&gt;{{tasks.Parent1.run_id}}&lt;/STRONG&gt;&lt;STRONG&gt;?&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;As you noticed, &lt;/SPAN&gt;&lt;SPAN&gt;{{tasks.Parent1.run_id}}&lt;/SPAN&gt;&lt;SPAN&gt; gives you the &lt;/SPAN&gt;&lt;STRONG&gt;orchestrator's task run_id&lt;/STRONG&gt;&lt;SPAN&gt; for the run&lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;job task itself — not the child job's internal task run&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt;id. That's why task values are the right tool here: they let the child task explicitly publish its own metadata for upstream consumption.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;REST API Fallback&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;If you &lt;/SPAN&gt;&lt;STRONG&gt;can't modify&lt;/STRONG&gt;&lt;SPAN&gt; Child 1's notebook, then yes, the REST API approach works:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Pass &lt;/SPAN&gt;&lt;SPAN&gt;{{tasks.Parent1.run_id}}&lt;/SPAN&gt;&lt;SPAN&gt; into an intermediate notebook task&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Use the &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/api/workspace/jobs/get-run" target="_blank"&gt;&lt;SPAN&gt;Runs Get API&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; to fetch the triggered child job's run details and extract Child 1's task run_id from the &lt;/SPAN&gt;&lt;SPAN&gt;tasks&lt;/SPAN&gt;&lt;SPAN&gt; array&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;SPAN&gt;But if you can add a couple of lines to Child 1, the task values approach is simpler and avoids API calls entirely.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Docs:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;A href="https://docs.databricks.com/aws/en/jobs/task-values" target="_blank"&gt;&lt;SPAN&gt;Task Values&lt;/SPAN&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;A href="https://docs.databricks.com/aws/en/jobs/dynamic-value-references" target="_blank"&gt;&lt;SPAN&gt;Dynamic Value References&lt;/SPAN&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;Hope that helps!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2026 10:56:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/get-task-run-id-that-is-nested-in-a-job-run-task/m-p/153721#M53999</guid>
      <dc:creator>anuj_lathi</dc:creator>
      <dc:date>2026-04-08T10:56:33Z</dc:date>
    </item>
  </channel>
</rss>

