Skip to content

Commit

Permalink
[HUDI-4875] Fix NoSuchTableException when dropping temporary view aft…
Browse files Browse the repository at this point in the history
…er applied HoodieSparkSessionExtension in Spark 3.2 (#6709)
  • Loading branch information
dohongdayi authored and yuzhaojing committed Sep 29, 2022
1 parent 464d992 commit 4f616f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Expand Up @@ -581,9 +581,9 @@ case class HoodiePostAnalysisRule(sparkSession: SparkSession) extends Rule[Logic
if sparkAdapter.isHoodieTable(table) =>
CreateHoodieTableCommand(table, ignoreIfExists)
// Rewrite the DropTableCommand to DropHoodieTableCommand
case DropTableCommand(tableName, ifExists, isView, purge)
case DropTableCommand(tableName, ifExists, false, purge)
if sparkAdapter.isHoodieTable(tableName, sparkSession) =>
DropHoodieTableCommand(tableName, ifExists, isView, purge)
DropHoodieTableCommand(tableName, ifExists, false, purge)
// Rewrite the AlterTableDropPartitionCommand to AlterHoodieTableDropPartitionCommand
case AlterTableDropPartitionCommand(tableName, specs, ifExists, purge, retainData)
if sparkAdapter.isHoodieTable(tableName, sparkSession) =>
Expand Down
Expand Up @@ -314,7 +314,6 @@ class TestDropTable extends HoodieSparkSqlTestBase {
}
}


test("Drop an MANAGED table which path is lost.") {
val tableName = generateTableName
spark.sql(
Expand All @@ -341,6 +340,28 @@ class TestDropTable extends HoodieSparkSqlTestBase {
checkAnswer("show tables")()
}

test("Drop local temporary view should not fail") {
val viewName = generateTableName
spark.sql(
s"""
|create temporary view $viewName as
| select 1
|""".stripMargin)

spark.sql(s"drop view $viewName")
}

test("Drop global temporary view should not fail") {
val viewName = generateTableName
spark.sql(
s"""
|create global temporary view $viewName as
| select 1
|""".stripMargin)

spark.sql(s"drop view global_temp.$viewName")
}

private def alterSerdeProperties(sessionCatalog: SessionCatalog, tableIdt: TableIdentifier,
newProperties: Map[String, String]): Unit = {
val catalogTable = spark.sessionState.catalog.getTableMetadata(tableIdt)
Expand Down

0 comments on commit 4f616f7

Please sign in to comment.