rdblue commented on a change in pull request #24741: [SPARK-27322][SQL] 
DataSourceV2: Select from multiple catalogs
URL: https://github.com/apache/spark/pull/24741#discussion_r290850731
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ##########
 @@ -728,20 +737,16 @@ class Analyzer(
     //    and the default database is only used to look up a view);
     // 3. Use the currentDb of the SessionCatalog.
     private def lookupTableFromCatalog(
+        tableIdentifier: TableIdentifier,
         u: UnresolvedRelation,
         defaultDatabase: Option[String] = None): LogicalPlan = {
-      val tableIdentWithDb = u.tableIdentifier.copy(
-        database = u.tableIdentifier.database.orElse(defaultDatabase))
+      val tableIdentWithDb = tableIdentifier.copy(
+        database = tableIdentifier.database.orElse(defaultDatabase))
       try {
         catalog.lookupRelation(tableIdentWithDb)
       } catch {
-        case e: NoSuchTableException =>
-          u.failAnalysis(s"Table or view not found: 
${tableIdentWithDb.unquotedString}", e)
-        // 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 e: NoSuchDatabaseException =>
-          u.failAnalysis(s"Table or view not found: 
${tableIdentWithDb.unquotedString}, the " +
-            s"database ${e.db} doesn't exist.", e)
 
 Review comment:
   @gatorsmile, we plan to update `checkAnalysis` to produce more friendly 
error messages, but not until #24560 is merged. Without that, we can't check 
whether the namespace exists to produce the right error message.
   
   I should also note that `checkAnalysis` is the right place for the exception 
to be thrown. Individual rules should not fail analysis. In this case, a 
different rule for looking up tables in v2 catalogs is used. And later, an 
`UnresolvedRelation` could be resolved by an independent `ResolveViews` rule. 
Allowing these rules to be separate makes them smaller and doesn't mix view 
handling and table handling, as we see in this current rule.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to