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

    https://github.com/apache/spark/pull/16674#discussion_r101110989
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -617,13 +617,18 @@ class Analyzer(
         private def lookupTableFromCatalog(
             u: UnresolvedRelation,
             defaultDatabase: Option[String] = None): LogicalPlan = {
    +      val db = u.tableIdentifier.database.orElse(defaultDatabase)
    +      val tableIdentWithDb = u.tableIdentifier.copy(database = db)
           try {
    -        val tableIdentWithDb = u.tableIdentifier.copy(
    -          database = u.tableIdentifier.database.orElse(defaultDatabase))
             catalog.lookupRelation(tableIdentWithDb, u.alias)
           } catch {
             case _: NoSuchTableException =>
    -          u.failAnalysis(s"Table or view not found: ${u.tableName}")
    +          u.failAnalysis(s"Table or view not found: 
${tableIdentWithDb.unquotedString}")
    +        // If the database is defined and that database is not found, 
throw an AnalysisException.
    +        // Note that if the database is not defined, it is possible we are 
looking up a temp view.
    +        case _: NoSuchDatabaseException if db.isDefined =>
    --- End diff --
    
    if users don't specify database, and the current database is removed by 
other sessions, then they will hit `NoSuchDatabaseException`. In this case, I 
think we should also throw `AnalysisException` for consistency.


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