HyukjinKwon commented on a change in pull request #30608:
URL: https://github.com/apache/spark/pull/30608#discussion_r536943423



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
##########
@@ -113,11 +113,11 @@ case class CreateViewCommand(
     verifyTemporaryObjectsNotExists(catalog, isTemporary, name, child)
 
     if (viewType == LocalTempView) {
-      val samePlan = catalog.getTempView(name.table).exists {
+      val samePlan = catalog.getTempView(name.table).map {
         // Don't perform sameResult check for View logical plan, since it's 
unresolved
         case _: View => false
         case other => other.sameResult(child)
-      }
+      }.getOrElse(true)
       if (replace && !samePlan) {

Review comment:
       Looks good but there's a nit here. The name `samePlan` sounds not 
correct now  because it checks if the view exists or not. What about something 
like this?
   
   ```scala
   ...
   val shouldUncache = replace && catalog.getGlobalTempView(name.table).exists {
     // Uncache View logical plan, since it's unresolved.
     case _: View => true
     case other => !other.sameResult(child)
   }
   if (shouldUncache) {
   ...
   ```




----------------------------------------------------------------
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]

Reply via email to