You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "cloud-fan (via GitHub)" <gi...@apache.org> on 2023/09/04 12:40:40 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #42803: [SPARK-45069][SQL] SQL variable should always be resolved after outer reference

cloud-fan commented on code in PR #42803:
URL: https://github.com/apache/spark/pull/42803#discussion_r1314896459


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ColumnResolutionHelper.scala:
##########
@@ -195,9 +199,7 @@ trait ColumnResolutionHelper extends Logging {
     }
 
     try {
-      val resolved = innerResolve(expr, isTopLevel = true)
-      val withOuterResolved = if (allowOuter) resolveOuterRef(resolved) else resolved
-      resolveVariables(withOuterResolved)

Review Comment:
   This is the bug. Sometimes we only want to do basic column resolution first, and then try some special resolution logic (see `ResolveReferencesInAggregat` as an example), and finally resolve outer references. The code before always tried to resolve the SQL variable.
   
   To avoid hitting similar bugs, I refactored the code a bit to have a `last resort` step for column resolution, which contains resolving outer references and SQL variables.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org