zhengruifeng commented on code in PR #39925:
URL: https://github.com/apache/spark/pull/39925#discussion_r1103956590
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -3307,12 +3307,18 @@ class Analyzer(override val catalogManager:
CatalogManager) extends RuleExecutor
_.containsPattern(NATURAL_LIKE_JOIN), ruleId) {
case j @ Join(left, right, UsingJoin(joinType, usingCols), _, hint)
if left.resolved && right.resolved && j.duplicateResolved =>
- commonNaturalJoinProcessing(left, right, joinType, usingCols, None,
hint)
Review Comment:
https://github.com/apache/spark/blob/9fa9d4b93176dcdf5f1e3d7c883956dc3f554508/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala#L3492-L3499
commonNaturalJoinProcessing resolves `Join` to `Project(Join)` and discard
the plan id, make this change to hold the plan id, otherwise following case
will fail due to can not find the subplan:
```
left = spark.createDataFrame([Row(a=1)])
right = spark.createDataFrame([Row(a=1)])
df = left.join(right, on="a", how="left_outer")
df.withColumn("b", udf(lambda x: "x")(df.a)). <- can not resolve `df.a`
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]