Skip to content

Commit

Permalink
ignore table or view not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
sunchao committed Jan 12, 2021
1 parent 708adc4 commit 712b079
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,14 @@ class CatalogImpl(sparkSession: SparkSession) extends Catalog {
* @since 2.0.0
*/
override def dropTempView(viewName: String): Boolean = {
sparkSession.sessionState.catalog.getTempView(viewName).exists { _ =>
sparkSession.sharedState.cacheManager.uncacheQuery(
sparkSession.table(viewName), cascade = false)
sparkSession.sessionState.catalog.getTempView(viewName).exists { viewDef =>
try {
val plan = sparkSession.sessionState.executePlan(viewDef)
sparkSession.sharedState.cacheManager.uncacheQuery(
sparkSession, plan.analyzed, cascade = false)
} catch {
case NonFatal(_) => // ignore
}
sessionCatalog.dropTempView(viewName)
}
}
Expand All @@ -411,11 +416,14 @@ class CatalogImpl(sparkSession: SparkSession) extends Catalog {
* @since 2.1.0
*/
override def dropGlobalTempView(viewName: String): Boolean = {
sparkSession.sessionState.catalog.getGlobalTempView(viewName).exists { _ =>
val db = sparkSession.sessionState.conf.getConf(StaticSQLConf.GLOBAL_TEMP_DATABASE)
val ident = TableIdentifier(viewName, Some(db))
sparkSession.sharedState.cacheManager.uncacheQuery(
sparkSession.table(ident), cascade = false)
sparkSession.sessionState.catalog.getGlobalTempView(viewName).exists { viewDef =>
try {
val plan = sparkSession.sessionState.executePlan(viewDef)
sparkSession.sharedState.cacheManager.uncacheQuery(
sparkSession, plan.analyzed, cascade = false)
} catch {
case NonFatal(_) => // ignore
}
sessionCatalog.dropGlobalTempView(viewName)
}
}
Expand Down

0 comments on commit 712b079

Please sign in to comment.