Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/16168#discussion_r91133302 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala --- @@ -509,32 +509,42 @@ class Analyzer( * Replaces [[UnresolvedRelation]]s with concrete relations from the catalog. */ object ResolveRelations extends Rule[LogicalPlan] { - private def lookupTableFromCatalog(u: UnresolvedRelation): LogicalPlan = { + private def lookupTableFromCatalog( + u: UnresolvedRelation, db: Option[String] = None): LogicalPlan = { try { - catalog.lookupRelation(u.tableIdentifier, u.alias) + catalog.lookupRelation(u.tableIdentifier, u.alias, db) } catch { case _: NoSuchTableException => u.failAnalysis(s"Table or view not found: ${u.tableName}") } } - def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators { - case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved => - i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u))) - case u: UnresolvedRelation => - val table = u.tableIdentifier - if (table.database.isDefined && conf.runSQLonFile && !catalog.isTemporaryTable(table) && + def apply(plan: LogicalPlan): LogicalPlan = { + var currentDatabase = catalog.getCurrentDatabase --- End diff -- Why we need to do it here? This should be moved to https://github.com/jiangxb1987/spark/blob/434009ef7fcfc552314dca35dc9395bb98f5e9c6/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala#L539
--- 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