<?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: Why is Spark creating multiple jobs for one action? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/why-is-spark-creating-multiple-jobs-for-one-action/m-p/55450#M30337</link>
    <description>&lt;P&gt;I am very curious about this. Any answer?&lt;/P&gt;</description>
    <pubDate>Mon, 18 Dec 2023 17:34:05 GMT</pubDate>
    <dc:creator>chrishj</dc:creator>
    <dc:date>2023-12-18T17:34:05Z</dc:date>
    <item>
      <title>Why is Spark creating multiple jobs for one action?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-is-spark-creating-multiple-jobs-for-one-action/m-p/17163#M11206</link>
      <description>&lt;P&gt; I noticed that when launching this bunch of code with only one action, I have three jobs that are launched.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from pyspark.sql import DataFrame from pyspark.sql.types import StructType, StructField, StringType from pyspark.sql.functions import avg&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;data: List = [("Diamant_1A", "TopDiamant", "300", "rouge"), ("Diamant_2B", "Diamants pour toujours", "45", "jaune"), ("Diamant_3C", "Mes diamants préférés", "78", "rouge"), ("Diamant_4D", "Diamants que j'aime", "90", "jaune"), ("Diamant_5E", "TopDiamant", "89", "bleu") ]&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;schema: StructType = StructType([ \ StructField("reference", StringType(), True), \ StructField("marque", StringType(), True), \ StructField("prix", StringType(), True), \ StructField("couleur", StringType(), True) ])&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;dataframe: DataFrame = spark.createDataFrame(data=data,schema=schema)&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;dataframe_filtree:DataFrame = dataframe.filter("prix &amp;gt; 50")&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;dataframe_filtree.show()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;From my understanding, I should get only one. One action corresponds to one job.&lt;/P&gt;&lt;P&gt;I don't know why I have 3 jobs.&lt;/P&gt;&lt;P&gt;Here is the first one : &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="https___i.stack.imgur.com_xfYDe.png"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2464i56BCAF8C67769D85/image-size/large?v=v2&amp;amp;px=999" role="button" title="https___i.stack.imgur.com_xfYDe.png" alt="https___i.stack.imgur.com_xfYDe.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the second one :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="LTHBM"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2454i5550740AE0B1D9C6/image-size/large?v=v2&amp;amp;px=999" role="button" title="LTHBM" alt="LTHBM" /&gt;&lt;/span&gt;And this is the last one :&lt;/P&gt;&lt;P&gt; &lt;span class="lia-inline-image-display-wrapper" image-alt="DdfHN"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2455i5B718B735EDDBFB2/image-size/large?v=v2&amp;amp;px=999" role="button" title="DdfHN" alt="DdfHN" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 12:33:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-is-spark-creating-multiple-jobs-for-one-action/m-p/17163#M11206</guid>
      <dc:creator>Nastasia</dc:creator>
      <dc:date>2021-07-29T12:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Spark creating multiple jobs for one action?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-is-spark-creating-multiple-jobs-for-one-action/m-p/55450#M30337</link>
      <description>&lt;P&gt;I am very curious about this. Any answer?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 17:34:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-is-spark-creating-multiple-jobs-for-one-action/m-p/55450#M30337</guid>
      <dc:creator>chrishj</dc:creator>
      <dc:date>2023-12-18T17:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Spark creating multiple jobs for one action?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-is-spark-creating-multiple-jobs-for-one-action/m-p/55529#M30362</link>
      <description>&lt;P&gt;The above code will create two jobs.&lt;/P&gt;&lt;P&gt;JOB-1.&amp;nbsp;dataframe: DataFrame = spark.createDataFrame(data=data,schema=schema)&lt;/P&gt;&lt;P&gt;The createDataFrame function is responsible for inferring the schema from the provided data or using the specified schema.Depending on the data source, this might involve reading a small sample of the data to infer the schema correctly.This operation might be triggered lazily but can sometimes cause Spark to execute certain tasks immediately.&lt;/P&gt;&lt;P&gt;So, in practical terms, while createDataFrame is usually considered a transformation, there might be scenarios,&lt;BR /&gt;especially with certain data sources, where it involves internal actions for schema inference&lt;/P&gt;&lt;P&gt;JOB-2.&amp;nbsp;dataframe_filtree.show()&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 21:33:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-is-spark-creating-multiple-jobs-for-one-action/m-p/55529#M30362</guid>
      <dc:creator>RKNutalapati</dc:creator>
      <dc:date>2023-12-19T21:33:53Z</dc:date>
    </item>
  </channel>
</rss>

