<?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: DROP TABLE IF EXISTS does not work in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28272#M20095</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;This is not the expected behavior for SQL users.&lt;/P&gt;
&lt;P&gt;e.g. &lt;A href="https://dev.mysql.com/doc/refman/8.0/en/drop-table.html" target="test_blank"&gt;https://dev.mysql.com/doc/refman/8.0/en/drop-table.html&lt;/A&gt; ...'With &lt;PRE&gt;&lt;CODE&gt;IF EXISTS&lt;/CODE&gt;&lt;/PRE&gt;, no error occurs for nonexisting tables.'&lt;/P&gt;
&lt;P&gt;It is a usability bug.&lt;/P&gt;
&lt;P&gt;Best regards, Robert&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jun 2019 09:26:12 GMT</pubDate>
    <dc:creator>robert4os</dc:creator>
    <dc:date>2019-06-24T09:26:12Z</dc:date>
    <item>
      <title>DROP TABLE IF EXISTS does not work</title>
      <link>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28269#M20092</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;When I try to run the command&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;spark.sql("DROP TABLE IF EXISTS table_to_drop")
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and the table does not exist, I get the following error:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;AnalysisException: "Table or view 'table_to_drop' not found in database 'null';;\nDropTableCommand `table_to_drop`, true, false, false\n"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The command works when the table does exist.&lt;/P&gt;
&lt;P&gt;I am using Python3 in an Azure Databricks notebook, Databricks runtime 5.2 on a high concurrency cluster. &lt;/P&gt;
&lt;P&gt;The table was created using the following command:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;df.write.option("path", "adl://***.azuredatalakestore.net/delta/table_to_drop").saveAsTable(name="table_to_drop", format="delta")
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I thought the whole point of using "IF EXISTS" was to avoid this error. Is this a bug, or is it something I don't understand?&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 15:40:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28269#M20092</guid>
      <dc:creator>martinch</dc:creator>
      <dc:date>2019-03-01T15:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: DROP TABLE IF EXISTS does not work</title>
      <link>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28270#M20093</link>
      <description>&lt;P&gt;According to this documentation, it is how it works... It throws an error, when the table doesn't exist:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Databricks DOCS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's pretty annoying though... &lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 15:52:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28270#M20093</guid>
      <dc:creator>Eve</dc:creator>
      <dc:date>2019-03-01T15:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: DROP TABLE IF EXISTS does not work</title>
      <link>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28271#M20094</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;But that is without the optional "IF EXISTS". With the "IF EXISTS" command the docs says: "If the table does not exist, nothing happens.".&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 15:59:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28271#M20094</guid>
      <dc:creator>martinch</dc:creator>
      <dc:date>2019-03-01T15:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: DROP TABLE IF EXISTS does not work</title>
      <link>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28272#M20095</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;This is not the expected behavior for SQL users.&lt;/P&gt;
&lt;P&gt;e.g. &lt;A href="https://dev.mysql.com/doc/refman/8.0/en/drop-table.html" target="test_blank"&gt;https://dev.mysql.com/doc/refman/8.0/en/drop-table.html&lt;/A&gt; ...'With &lt;PRE&gt;&lt;CODE&gt;IF EXISTS&lt;/CODE&gt;&lt;/PRE&gt;, no error occurs for nonexisting tables.'&lt;/P&gt;
&lt;P&gt;It is a usability bug.&lt;/P&gt;
&lt;P&gt;Best regards, Robert&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 09:26:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28272#M20095</guid>
      <dc:creator>robert4os</dc:creator>
      <dc:date>2019-06-24T09:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: DROP TABLE IF EXISTS does not work</title>
      <link>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28273#M20096</link>
      <description>&lt;P&gt;I agree about this being a usability bug. Documentation clearly states that if the optional flag "IF EXISTS" is provided that the statement will do nothing.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/drop-table.html" target="test_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/drop-table.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Drop Table &lt;/B&gt; copy &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DROP TABLE [IF EXISTS] [db_name.]table_name&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Drop a table and delete the directory associated with the table from the file system if this is not an &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;EXTERNAL&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; table. If the table to drop does not exist, an exception is thrown. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF EXISTS&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;B&gt;If the table does not exist, nothing happens.&lt;/B&gt; &lt;/P&gt;&lt;P&gt; I am getting the same error as the original post while running the just this command with the SQL API&lt;/P&gt;&lt;P&gt;DROP TABLE IF EXISTS testTable;&lt;/P&gt;&lt;P&gt;I would expect no error but get the following.&lt;/P&gt;&lt;P&gt;Error in SQL statement: AnalysisException: Table or view 'testTable' not found in database 'null';; DropTableCommand &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;testTable&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;, true, false, false &lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 12:46:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/drop-table-if-exists-does-not-work/m-p/28273#M20096</guid>
      <dc:creator>StevenWilliams</dc:creator>
      <dc:date>2019-07-30T12:46:30Z</dc:date>
    </item>
  </channel>
</rss>

