Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HUDI-4875] Fix NoSuchTableException when dropping temporary view after applied HoodieSparkSessionExtension in Spark 3.2 #6709

Merged
merged 3 commits into from Sep 20, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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