Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/16233#discussion_r93551189
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
---
@@ -549,17 +549,26 @@ class SessionCatalog(
*
* If a database is specified in `name`, this will return the table/view
from that database.
* If no database is specified, this will first attempt to return a
temporary table/view with
- * the same name, then, if that does not exist, return the table/view
from the current database.
+ * the same name, then, if that does not exist, and currentDatabase is
defined, return the
+ * table/view from the currentDatabase, else return the table/view from
the catalog.currentDb.
*
* Note that, the global temp view database is also valid here, this
will return the global temp
* view matching the given name.
*
- * If the relation is a view, the relation will be wrapped in a
[[SubqueryAlias]] which will
- * track the name of the view.
+ * If the relation is a view, we add a [[View]] operator over the
relation, and wrap the logical
+ * plan in a [[SubqueryAlias]] which will track the name of the view.
+ *
+ * @param name The name of the table/view that we lookup.
+ * @param alias The alias name of the table/view that we lookup.
+ * @param currentDatabase The database name we should use to lookup the
table/view, if the
+ * database part of [[TableIdentifier]] is not
defined.
*/
- def lookupRelation(name: TableIdentifier, alias: Option[String] = None):
LogicalPlan = {
+ def lookupRelation(
+ name: TableIdentifier,
+ alias: Option[String] = None,
+ currentDatabase: Option[String] = None): LogicalPlan = {
synchronized {
- val db = formatDatabaseName(name.database.getOrElse(currentDb))
+ val db =
formatDatabaseName(name.database.getOrElse(currentDatabase.getOrElse(currentDb)))
--- End diff --
I feel that currentDatabase and currentDb will confuse readers.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]