Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,8 @@ case class HoodiePostAnalysisRule(sparkSession: SparkSession) extends Rule[Logic
CreateHoodieTableCommand(table, ignoreIfExists)
// Rewrite the DropTableCommand to DropHoodieTableCommand
case DropTableCommand(tableName, ifExists, false, purge)
if sparkAdapter.isHoodieTable(tableName, sparkSession) =>
if sparkSession.sessionState.catalog.tableExists(tableName)
&& sparkAdapter.isHoodieTable(tableName, sparkSession) =>
DropHoodieTableCommand(tableName, ifExists, false, purge)
// Rewrite the AlterTableDropPartitionCommand to AlterHoodieTableDropPartitionCommand
case AlterTableDropPartitionCommand(tableName, specs, ifExists, purge, retainData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.apache.spark.sql.hudi

import org.apache.hadoop.fs.{LocalFileSystem, Path}
import org.apache.hudi.common.fs.FSUtils
import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.catalog.SessionCatalog

Expand Down Expand Up @@ -51,6 +52,16 @@ class TestDropTable extends HoodieSparkSqlTestBase {
}
}

test("Test Drop Table with non existent table") {
// drop table if exists
spark.sql("drop table if exists non_existent_table")

// drop table
assertThrows[AnalysisException]{
spark.sql("drop table non_existent_table")
}
}

test("Test Drop Table with purge") {
withTempDir { tmp =>
Seq("cow", "mor").foreach { tableType =>
Expand Down