rdblue commented on a change in pull request #26214: [SPARK-29558][SQL]
ResolveTables and ResolveRelations should be order-insensitive
URL: https://github.com/apache/spark/pull/26214#discussion_r346066955
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -666,12 +665,26 @@ class Analyzer(
}
/**
- * Resolve table relations with concrete relations from v2 catalog.
+ * Resolve relations to temp views. This is not an actual rule, and is only
called by
+ * [[ResolveTables]].
+ */
+ object ResolveTempViews extends Rule[LogicalPlan] {
+ def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperatorsUp {
+ case u @ UnresolvedRelation(Seq(part1)) =>
+ v1SessionCatalog.lookupTempView(part1).getOrElse(u)
+ case u @ UnresolvedRelation(Seq(part1, part2)) =>
Review comment:
This needs to check whether `part1` is a known catalog. If it is a catalog,
then it isn't a temp view reference because catalog resolution happens first.
Not needing to remember that is the purpose of the extractors. I think it
would be better to continue using the extractor:
```scala
case u @ UnresolvedRelation(AsTemporaryTableIdentifier(ident)) =>
ident.database match {
case Some(db) =>
v1SessionCatalog.lookupGlobalTempView(db, ident.table).getOrElse(u)
case None =>
v1SessionCatalog.lookupTempView(ident.table).getOrElse(u)
}
```
----------------------------------------------------------------
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]