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



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
##########
@@ -729,7 +729,7 @@ class DataSourceV2SQLSuite
     val ex = intercept[AnalysisException] {
       sql("DROP TABLE testcat.db.notbl")
     }
-    assert(ex.getMessage.contains("Table or view not found: testcat.db.notbl"))
+    assert(ex.getMessage.contains("Table or view not found for 'DROP TABLE': 
testcat.db.notbl"))

Review comment:
       This message could be misleading since `DROP TABLE` supports table and a 
temporary view. To fix this, we can add `allowPermanentView` as the following 
and update `Analyzer` accordingly:
   ```scala
   case class UnresolvedTableOrView(
       multipartIdentifier: Seq[String],
       commandName: String,
       allowTempView: Boolean = true,
       allowPermanentView: Boolean = true) extends LeafNode {
     require(allowTempView || allowPermanentView)
     override lazy val resolved: Boolean = false
     override def output: Seq[Attribute] = Nil
   }
   ```
   such that the exception message can be updated to
   `Table or temporary view not found for 'DROP TABLE': t`.
   
   One downside is that if `t` is resolved to a view, the message will become:
   ```
   t is a permanent view. 'DROP TABLE' expects a table or temporary view.
   ```
   instead of (current message):
   ```
   Cannot drop a view with DROP TABLE. Please use DROP VIEW instead
   ```
   , meaning it will lose the "hint" (which we can add it to `Unresolved*` if 
required).
   
   @cloud-fan WDYT? If you are OK with introducing `allowPermanentView`, I can 
do it as a separate PR.




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