-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-37829][SQL] DataFrame.joinWith should return null rows for missing values #35139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1173,8 +1173,20 @@ class Dataset[T] private[sql]( | |
| joined = resolveSelfJoinCondition(joined) | ||
| } | ||
|
|
||
| implicit val tuple2Encoder: Encoder[(T, U)] = | ||
| ExpressionEncoder.tuple(this.exprEnc, other.exprEnc) | ||
| // SPARK-37829: an outer-join requires the null semantics to represent missing keys. | ||
| // As we might be running on DataFrames, we need a custom encoder that will properly | ||
| // handle null top-level Rows. | ||
| def nullSafe[V](exprEnc: ExpressionEncoder[V]): ExpressionEncoder[V] = { | ||
| if (exprEnc.clsTag.runtimeClass != classOf[Row]) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks a bit ugly.
Are they UT or end-to-end tests? If they are UT, we can simply update the tests because we have changed the assumption. |
||
| exprEnc | ||
| } else { | ||
| RowEncoder.nullSafe(exprEnc.asInstanceOf[ExpressionEncoder[Row]]) | ||
| .asInstanceOf[ExpressionEncoder[V]] | ||
| } | ||
| } | ||
| implicit val tuple2Encoder: Encoder[(T, U)] = ExpressionEncoder.tuple( | ||
| nullSafe(this.exprEnc), nullSafe(other.exprEnc) | ||
| ) | ||
|
|
||
| val leftResultExpr = { | ||
| if (!this.exprEnc.isSerializedAsStructForTopLevel) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry the code here is a bit confusing. We check
exprEnc.objSerializer.nullableand then we constructIsNull(newDeserializerInput)? What's their connection?