<?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: How to programmatically get the Spark Job ID of a running Spark Task? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27876#M19719</link>
    <description>&lt;P&gt;Hi @Franklin George​&amp;nbsp; , As mentioned on stackoverflow also, &lt;I&gt;jobIdToStageIds &lt;/I&gt;mapping is store in spark context (DagScheduler) . So I don't think it is possible to get this info at the executor level while the task is running. &lt;/P&gt;&lt;P&gt;May I know what you want to do with jobId at the task level? What is the use case here? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Mar 2022 01:34:09 GMT</pubDate>
    <dc:creator>User16763506477</dc:creator>
    <dc:date>2022-03-09T01:34:09Z</dc:date>
    <item>
      <title>How to programmatically get the Spark Job ID of a running Spark Task?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27873#M19716</link>
      <description>&lt;P&gt;In Spark we can get the Spark Application ID inside the Task programmatically using:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SparkEnv.get.blockManager.conf.getAppId&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and we can get the Stage ID and Task Attempt ID of the running Task using:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TaskContext.get.stageId
TaskContext.get.taskAttemptId&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there any way to get the Spark Job Id that is associated with a running Task (preferably using TaskContext or SparkEnv)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linked Question on StackOverflow: &lt;A href="https://stackoverflow.com/questions/70929032/how-to-programmatically-get-the-spark-job-id-of-a-running-spark-task" target="test_blank"&gt;https://stackoverflow.com/questions/70929032/how-to-programmatically-get-the-spark-job-id-of-a-running-spark-task&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 04:34:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27873#M19716</guid>
      <dc:creator>FRG96</dc:creator>
      <dc:date>2022-02-17T04:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically get the Spark Job ID of a running Spark Task?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27876#M19719</link>
      <description>&lt;P&gt;Hi @Franklin George​&amp;nbsp; , As mentioned on stackoverflow also, &lt;I&gt;jobIdToStageIds &lt;/I&gt;mapping is store in spark context (DagScheduler) . So I don't think it is possible to get this info at the executor level while the task is running. &lt;/P&gt;&lt;P&gt;May I know what you want to do with jobId at the task level? What is the use case here? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 01:34:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27876#M19719</guid>
      <dc:creator>User16763506477</dc:creator>
      <dc:date>2022-03-09T01:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically get the Spark Job ID of a running Spark Task?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27877#M19720</link>
      <description>&lt;P&gt;Hi @Gaurav Rupnar​&amp;nbsp;, I have Spark SQL UDFs (implemented as Scala methods) in which I want to get the details of the Spark SQL query that called the UDF, especially a unique query ID, which in SparkSQL is the Spark Job ID. That's why I wanted a way to detect the Job ID from the UDF code itself when it is executed on the Executors as Tasks.&lt;/P&gt;&lt;P&gt;A logic in my UDF requires this unique query id (Job ID) to enforce that the UDF execution(s) will be consistent for each SparkSQL query.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 04:21:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27877#M19720</guid>
      <dc:creator>FRG96</dc:creator>
      <dc:date>2022-03-09T04:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically get the Spark Job ID of a running Spark Task?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27878#M19721</link>
      <description>&lt;P&gt;@Franklin George​&amp;nbsp;, Honestly, there is no easy way to do this. Your only option is to set up cluster log delivery, which will give you access to the cluster's event log file. This event log file is JSON and contains all of the info that the SparkUI uses (and more). It will have the information you are looking for but is not trivial to parse manually. I can't think of a better option.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 16:24:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27878#M19721</guid>
      <dc:creator>Dan_Z</dc:creator>
      <dc:date>2022-05-04T16:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically get the Spark Job ID of a running Spark Task?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27879#M19722</link>
      <description>&lt;P&gt;Hi @Franklin George​,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a friendly follow-up. Do you still need hep or any other responses provided help you to resolve your issue? Please et us know.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 17:28:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-programmatically-get-the-spark-job-id-of-a-running-spark/m-p/27879#M19722</guid>
      <dc:creator>jose_gonzalez</dc:creator>
      <dc:date>2022-05-17T17:28:28Z</dc:date>
    </item>
  </channel>
</rss>

