Skip to content
Closed
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 @@ -29,6 +29,7 @@ import org.scalatest.BeforeAndAfterAll
import org.apache.spark.SparkFunSuite
import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.analysis.NoSuchTableException
import org.apache.spark.sql.catalyst.catalog.SessionCatalog.DEFAULT_DATABASE
import org.apache.spark.sql.catalyst.FunctionIdentifier
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
import org.apache.spark.sql.catalyst.util._
Expand Down Expand Up @@ -196,7 +197,12 @@ private[sql] trait SQLTestUtils
fail("Failed to create temporary database", cause)
}

try f(dbName) finally spark.sql(s"DROP DATABASE $dbName CASCADE")
try f(dbName) finally {
if (spark.catalog.currentDatabase == dbName) {
spark.sql(s"USE ${DEFAULT_DATABASE}")
}
spark.sql(s"DROP DATABASE $dbName CASCADE")
}
}

/**
Expand Down