Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,11 @@ class Dataset[T] private[sql](
catalyst.expressions.EqualTo(
withPlan(plan.left).resolve(a.name),
withPlan(plan.right).resolve(b.name))
case catalyst.expressions.EqualNullSafe(a: AttributeReference, b: AttributeReference)
if a.sameRef(b) =>
catalyst.expressions.EqualNullSafe(
withPlan(plan.left).resolve(a.name),
withPlan(plan.right).resolve(b.name))
}}

withPlan {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,12 @@ class DataFrameJoinSuite extends QueryTest with SharedSQLContext {
dfOne.join(dfTwo, $"a" === $"b", "left").queryExecution.optimizedPlan
}
}

test("SPARK-24385: Resolve ambiguity in self-joins with EqualNullSafe") {
withSQLConf(SQLConf.CROSS_JOINS_ENABLED.key -> "false") {
val df = spark.range(2)
// this throws an exception before the fix
df.join(df, df("id") <=> df("id")).queryExecution.optimizedPlan
}
}
}