Github user ioana-delaney commented on a diff in the pull request:
https://github.com/apache/spark/pull/13867#discussion_r68513197
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -911,19 +911,30 @@ class Analyzer(
* Resolve the correlated expressions in a subquery by using the an
outer plans' references. All
* resolved outer references are wrapped in an [[OuterReference]]
*/
- private def resolveOuterReferences(plan: LogicalPlan, outer:
LogicalPlan): LogicalPlan = {
+ private def resolveOuterReferences(
+ plan: LogicalPlan,
+ outers: Seq[LogicalPlan]): LogicalPlan = {
+ var throwError = false
plan transformDown {
case q: LogicalPlan if q.childrenResolved && !q.resolved =>
q transformExpressions {
case u @ UnresolvedAttribute(nameParts) =>
withPosition(u) {
try {
- outer.resolve(nameParts, resolver) match {
+ val outer = outers.iterator
--- End diff --
The try-catch expression has to be outside the loop. The new exception is
issued only if the expression cannot be resolved for any of the outer plans.
Actually, the reason we need an explicit try-catch is to preserve the
original logic, which I kept unchanged. If an exception occurs, the original
logic will overwrite the exception and instead return the unresolved
expression. I kept this logic for any exception other than the one I
introduced.
The overall logic is the following: Loop through each outer plan until the
expression is resolved. If the expression cannot be resolved for any outer,
raised the newly introduced exception. For any other exception that may occur,
catch the expression and return the unresolved expression.
Please let me know if you agree. I hope I didn't misunderstand something.
---
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]