Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14962#discussion_r77808532
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala ---
    @@ -189,31 +189,39 @@ case class DropTableCommand(
     
       override def run(sparkSession: SparkSession): Seq[Row] = {
         val catalog = sparkSession.sessionState.catalog
    -    if (!catalog.tableExists(tableName)) {
    -      if (!ifExists) {
    -        val objectName = if (isView) "View" else "Table"
    -        throw new AnalysisException(s"$objectName to drop '$tableName' 
does not exist")
    -      }
    -    } else {
    -      // If the command DROP VIEW is to drop a table or DROP TABLE is to 
drop a view
    -      // issue an exception.
    -      catalog.getTableMetadataOption(tableName).map(_.tableType match {
    -        case CatalogTableType.VIEW if !isView =>
    -          throw new AnalysisException(
    -            "Cannot drop a view with DROP TABLE. Please use DROP VIEW 
instead")
    -        case o if o != CatalogTableType.VIEW && isView =>
    -          throw new AnalysisException(
    -            s"Cannot drop a table with DROP VIEW. Please use DROP TABLE 
instead")
    -        case _ =>
    -      })
    -      try {
    -        sparkSession.sharedState.cacheManager.uncacheQuery(
    -          sparkSession.table(tableName.quotedString))
    -      } catch {
    -        case NonFatal(e) => log.warn(e.toString, e)
    +
    +    // If the table name contains database part, we should drop a 
metastore table directly,
    +    // otherwise, try to drop a temp view first, if that not exist, drop 
metastore table.
    +    val dropMetastoreTable =
    +      tableName.database.isDefined || 
!catalog.dropTempView(tableName.table)
    --- End diff --
    
    Actually I noticed this and fixed it before, but it breaks a lot of tests. 
I'd like to keep this behaviour as it was, we can discuss how to fix it in 
follow-ups.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to