<?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 delete from a temp view or equivalent in spark sql databricks? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20694#M14003</link>
    <description>&lt;P&gt;You cant delete data from a view, but you can create or replace temp view with the same name with the data you want deleted filtered out.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if you have a view myview, that you want to delete the record with id=2, do the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OR REPLACE TEMP VIEW myview&lt;/P&gt;&lt;P&gt;as&lt;/P&gt;&lt;P&gt;select * from myview where id = 2; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Sep 2021 20:01:39 GMT</pubDate>
    <dc:creator>franco_patano</dc:creator>
    <dc:date>2021-09-02T20:01:39Z</dc:date>
    <item>
      <title>How to delete from a temp view or equivalent in spark sql databricks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20693#M14002</link>
      <description>&lt;P&gt;&lt;B&gt;I need to delete from a temp view in databricks, but it looks like i can do only merge, select and insert. Maybe i missed something but I did not find any documentation on this.&lt;/B&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 15:16:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20693#M14002</guid>
      <dc:creator>User16790091296</dc:creator>
      <dc:date>2021-06-24T15:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete from a temp view or equivalent in spark sql databricks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20694#M14003</link>
      <description>&lt;P&gt;You cant delete data from a view, but you can create or replace temp view with the same name with the data you want deleted filtered out.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if you have a view myview, that you want to delete the record with id=2, do the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OR REPLACE TEMP VIEW myview&lt;/P&gt;&lt;P&gt;as&lt;/P&gt;&lt;P&gt;select * from myview where id = 2; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 20:01:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20694#M14003</guid>
      <dc:creator>franco_patano</dc:creator>
      <dc:date>2021-09-02T20:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete from a temp view or equivalent in spark sql databricks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20695#M14004</link>
      <description>&lt;P&gt;Franco is right, in case you use an ordinary parquet file underneath.&lt;/P&gt;&lt;P&gt;With Delta Lake it is possible to delete data.  So basically the data you read (and want to delete from) has to come from Delta lake.  Then you can create a view on it and use the DELETE command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 13:46:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20695#M14004</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2021-09-09T13:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete from a temp view or equivalent in spark sql databricks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20696#M14005</link>
      <description>&lt;P&gt;You can't delete a temp view because it's only a view.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 17:05:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20696#M14005</guid>
      <dc:creator>youssefmrini</dc:creator>
      <dc:date>2021-09-09T17:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete from a temp view or equivalent in spark sql databricks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20697#M14006</link>
      <description>&lt;P&gt;A temp view is a pointer. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The information for a temp view is stored in the spark catalog&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can drop a temp view with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;spark.catalog.dropTempView("view_name")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could also drop a temp view in a sql cell with&lt;/P&gt;&lt;P&gt;DROP TABLE "temp_view_name"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is some code to demonstrate&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;df = spark.sql("select 1 id") # creates a dataframe&lt;/P&gt;&lt;P&gt;df.createOrReplaceTempView("temp_test") # registers it as a temp view&lt;/P&gt;&lt;P&gt;spark.catalog.listTables() # Shows all tables including temp views&lt;/P&gt;&lt;P&gt;spark.catalog.dropTempView("temp_test") # drops the temp view&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the dataframe still exists, display(df) to verify. The tempview is merely a pointer to the dataframe. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using sql the sample code would look something like this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE TEMPORARY VIEW temp_test as select 1; --Creates the view&lt;/P&gt;&lt;P&gt;Drop table temp_test; --drops the view&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 18:48:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20697#M14006</guid>
      <dc:creator>User16857282152</dc:creator>
      <dc:date>2021-09-09T18:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete from a temp view or equivalent in spark sql databricks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20698#M14007</link>
      <description>&lt;P&gt;This is incorrect, see reply below. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you meant, dropping a temp view does NOT delete the underlying data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then that statement is correct. &lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 18:50:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20698#M14007</guid>
      <dc:creator>User16857282152</dc:creator>
      <dc:date>2021-09-09T18:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete from a temp view or equivalent in spark sql databricks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20699#M14008</link>
      <description>&lt;P&gt;What about&lt;/P&gt;&lt;P&gt;%sql&lt;/P&gt;&lt;P&gt;DROP TABLE IF EXISTS xxxxx&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 07:33:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-delete-from-a-temp-view-or-equivalent-in-spark-sql/m-p/20699#M14008</guid>
      <dc:creator>crazy_horse</dc:creator>
      <dc:date>2022-08-22T07:33:11Z</dc:date>
    </item>
  </channel>
</rss>

