imback82 commented on a change in pull request #31273:
URL: https://github.com/apache/spark/pull/31273#discussion_r563908316



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala
##########
@@ -558,20 +560,27 @@ object ViewHelper {
       catalog: SessionCatalog, child: LogicalPlan): (Seq[Seq[String]], 
Seq[String]) = {
     def collectTempViews(child: LogicalPlan): Seq[Seq[String]] = {
       child.collect {
-        case UnresolvedRelation(nameParts, _, _) if 
catalog.isTempView(nameParts) =>
-          Seq(nameParts)
-        case plan if !plan.resolved => plan.expressions.flatMap(_.collect {
+        case s @ SubqueryAlias(_, view: View) if view.isTempView =>
+          Seq(s.identifier.qualifier :+ s.identifier.name)
+        case s: SubqueryAlias if s.getTagValue(SUBQUERY_TYPE_TAG).exists(_ == 
"tempView") =>

Review comment:
       Thanks @cloud-fan for the explanation.
   
   I think we have few ways to detect dataframe temp views:
   1. Add `isView: Boolean` field to the `SubqueryAlias`.
   2. If we want to wrap dataframe temp views with `View`, we need to create 
`CatalogTable` - which is `View.desc` - with relaxed requirements (e.g., 
allowing duplicate columns).
   3. Make `View.desc` optional and allow it to be `None` only for temporary 
views.
   
   I think 3) makes the most sense without changing semantics. 




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