Github user cloud-fan commented on the issue:
https://github.com/apache/spark/pull/16233
I'm thinking about if we really need the wrapper: the `View` operator.
Given a table/view identifier, the steps to resolve it:
1. if the database is specified, get the table/view metadata from that
database.
1. If the database is not specified, try to resolve it as temp view first.
2. If it's not a temp view, get the table/view metadata from the current
database.
For nested views, it's a different story. The sub-plan-tree of the nested
view may have a different "currentDatabase". It's kind of under a different
analysis context, and wrapping the sub-plan-tree with a `View` operator can
solve this problem, but I have a simpler proposal:
```
def lookupRelation(...) = {
...
if (table.tableType == CatalogTableType.VIEW) {
val viewContext = table.viewContext
val viewText = table.viewText
sparkSession.sessionState.sqlParser.parsePlan(viewText).transform {
case u @ UnresolvedRelation(tableIdent) if
tableIdent.database.isEmpty =>
u.copy(tableIdent = tableIdent.copy(database =
Some(viewContext.currentDatase)))
}
...
}
...
}
```
---
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]