sunchao commented on a change in pull request #31136:
URL: https://github.com/apache/spark/pull/31136#discussion_r556337790
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala
##########
@@ -412,8 +417,13 @@ class CatalogImpl(sparkSession: SparkSession) extends
Catalog {
*/
override def dropGlobalTempView(viewName: String): Boolean = {
sparkSession.sessionState.catalog.getGlobalTempView(viewName).exists {
viewDef =>
- sparkSession.sharedState.cacheManager.uncacheQuery(
- sparkSession, viewDef, cascade = false)
+ try {
+ val plan = sparkSession.sessionState.executePlan(viewDef)
+ sparkSession.sharedState.cacheManager.uncacheQuery(
+ sparkSession, plan.analyzed, cascade = false)
+ } catch {
+ case NonFatal(_) => // ignore
Review comment:
This is also discussed above. Suppose we have:
```sql
CREATE TEMPORARY VIEW v1 AS SELECT * FROM v2
```
a Spark user can drop v2 first followed by v1. In this case the
`uncacheQuery` will fail because `v2` is already gone. Consequently, the view
will not be dropped. This seems to be a quite common scenario.
Also this is [following the
`DropTableCommand](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala#L239)`,
which swallows any non-fatal exception and proceed to drop the view.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]