<?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: pyspark dataframe empties after it has been saved to delta lake. in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/45913#M27993</link>
    <description>&lt;P&gt;Hi,im also having similar issue ..does creating temp view and reading it again after saving to a table works??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;</description>
    <pubDate>Sat, 23 Sep 2023 18:04:59 GMT</pubDate>
    <dc:creator>SharathE</dc:creator>
    <dc:date>2023-09-23T18:04:59Z</dc:date>
    <item>
      <title>pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19743#M13276</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing a problem that I hope to get some help to understand. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a function that is supposed to check if the input data already exist in a saved delta table and if not, it should create some calculations and append the new data to the table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run the code without saving the data, it is possible to display the dataframe (display(dataframe)), however, after appending the data from the dataframe to the delta table, a new run of display(dataframe) suddently indicates that the dataframe is empty. Can somebody help me understand why the dataframe is displayed as empty, when the only change is that the data has been saved to the delta table? Does "display" somehow run the join function again?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simplified code&lt;/P&gt;&lt;P&gt;   #Load existing delta table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;deltaDF = spark.read.format('delta').load(filePath)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;#Remove any row that is identical to already existing data &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;condition = [&amp;lt;relevant column comparisons&amp;gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;noexistingDF = DF.join(deltaDF, on=condition, how="left_anti")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;  #Performing some additional columns to the data based on the already present data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   display(noexistingDF ) #successfullly displays data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  #Saving data to delta table&lt;/P&gt;&lt;P&gt;  noexistingDF.write.format("delta").mode("append").save(fileDestination)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  display(noexistingDF ) #Suddenly the dataframe is empty&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 06:42:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19743#M13276</guid>
      <dc:creator>Christine</dc:creator>
      <dc:date>2022-05-25T06:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19744#M13277</link>
      <description>&lt;P&gt;yes.  Spark is lazy evaluated meaning that it will execute code only on actions.  display() is such an action, write too.&lt;/P&gt;&lt;P&gt;So Spark will first execute the query for the write (read, transform, write), and then do the same a second time for the display (read, transform, display).  The left_anti join will return nothing as the data is added to the delta table.&lt;/P&gt;&lt;P&gt;if you would read/write from different tables, the df would not be empty (as the read table has not changed).&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 07:02:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19744#M13277</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-05-25T07:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19745#M13278</link>
      <description>&lt;P&gt;Okay, thank you! Do you know if there is a way to copy the table to work around it so display does not transform based on the read table but displays the data as it was before saving?&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 07:25:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19745#M13278</guid>
      <dc:creator>Christine</dc:creator>
      <dc:date>2022-05-25T07:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19746#M13279</link>
      <description>&lt;P&gt;There are several ways.&lt;/P&gt;&lt;P&gt;But they all come down to the same: writing the df to disk.&lt;/P&gt;&lt;P&gt;So if you write noexistingDF to disk (by spark.write or checkpoint) and then read it, you're there.&lt;/P&gt;&lt;P&gt;Copying the delta table itself seems overkill (althoug it can be done).&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 07:33:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19746#M13279</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-05-25T07:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19747#M13280</link>
      <description>&lt;P&gt;Hi @Christine Pedersen​&amp;nbsp;please let us know if @Werner Stinckens​&amp;nbsp;answered helped you in mitigating the issue or do you need any further help on this?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 06:57:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19747#M13280</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-01T06:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19748#M13281</link>
      <description>&lt;P&gt;Hi @Chetan Kardekar​, the replies did answer my question, so I do not need more information, thank you. &lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 13:49:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19748#M13281</guid>
      <dc:creator>Christine</dc:creator>
      <dc:date>2022-06-01T13:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19749#M13282</link>
      <description>&lt;P&gt;Hey there @Christine Pedersen​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope everything is going great!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you be happy to circle back and mark an answer as best? It would be really helpful for the other members to find the solution more quickly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 15:09:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19749#M13282</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-22T15:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19750#M13283</link>
      <description>&lt;P&gt;Hey @Vartika Nain​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes of course.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 06:45:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/19750#M13283</guid>
      <dc:creator>Christine</dc:creator>
      <dc:date>2022-08-01T06:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/45913#M27993</link>
      <description>&lt;P&gt;Hi,im also having similar issue ..does creating temp view and reading it again after saving to a table works??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;</description>
      <pubDate>Sat, 23 Sep 2023 18:04:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/45913#M27993</guid>
      <dc:creator>SharathE</dc:creator>
      <dc:date>2023-09-23T18:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark dataframe empties after it has been saved to delta lake.</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/68677#M33718</link>
      <description>&lt;P&gt;But what if i want to do some transformation after writing noexisting df into tables and use that df into my code&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 18:18:51 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-dataframe-empties-after-it-has-been-saved-to-delta-lake/m-p/68677#M33718</guid>
      <dc:creator>mayur_05</dc:creator>
      <dc:date>2024-05-09T18:18:51Z</dc:date>
    </item>
  </channel>
</rss>

