StevenWilliams
New Contributor II

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.

https://docs.databricks.com/spark/latest/spark-sql/language-manual/drop-table.html

Drop Table copy

DROP TABLE [IF EXISTS] [db_name.]table_name

Drop a table and delete the directory associated with the table from the file system if this is not an

EXTERNAL

table. If the table to drop does not exist, an exception is thrown.

IF EXISTS

If the table does not exist, nothing happens.

I am getting the same error as the original post while running the just this command with the SQL API

DROP TABLE IF EXISTS testTable;

I would expect no error but get the following.

Error in SQL statement: AnalysisException: Table or view 'testTable' not found in database 'null';; DropTableCommand

testTable

, true, false, false