-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-17806] [SQL] fix bug in join key rewritten in HashJoin #15390
Conversation
cc @rxin |
val bits = dt.defaultSize * 8 | ||
keyExpr = BitwiseOr(ShiftLeft(keyExpr, Literal(bits)), | ||
BitwiseAnd(Cast(e, LongType), Literal((1L << bits) - 1))) | ||
width += dt.defaultSize |
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.
This is the only change (for people also reviewing this).
LGTM pending Jenkins. |
* | ||
* If not, returns the original expressions. | ||
*/ | ||
private[joins] def rewriteKeyExpr(keys: Seq[Expression]): Seq[Expression] = { |
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.
This will be a lot clear and less error prone if we can write the check first and go through the data twice, e.g.
if (keys.map(_.dataType.defaultSize).sum <= 8) {
return keys
}
// do the rewrite here
Test build #66510 has finished for PR 15390 at commit
|
LGTM, pending the new test run. |
Test build #66522 has finished for PR 15390 at commit
|
## What changes were proposed in this pull request? In HashJoin, we try to rewrite the join key as Long to improve the performance of finding a match. The rewriting part is not well tested, has a bug that could cause wrong result when there are at least three integral columns in the joining key also the total length of the key exceed 8 bytes. ## How was this patch tested? Added unit test to covering the rewriting with different number of columns and different data types. Manually test the reported case and confirmed that this PR fix the bug. Author: Davies Liu <davies@databricks.com> Closes #15390 from davies/rewrite_key. (cherry picked from commit 94b24b8) Signed-off-by: Davies Liu <davies.liu@gmail.com>
Test build #3300 has finished for PR 15390 at commit
|
## What changes were proposed in this pull request? In HashJoin, we try to rewrite the join key as Long to improve the performance of finding a match. The rewriting part is not well tested, has a bug that could cause wrong result when there are at least three integral columns in the joining key also the total length of the key exceed 8 bytes. ## How was this patch tested? Added unit test to covering the rewriting with different number of columns and different data types. Manually test the reported case and confirmed that this PR fix the bug. Author: Davies Liu <davies@databricks.com> Closes apache#15390 from davies/rewrite_key.
What changes were proposed in this pull request?
In HashJoin, we try to rewrite the join key as Long to improve the performance of finding a match. The rewriting part is not well tested, has a bug that could cause wrong result when there are at least three integral columns in the joining key also the total length of the key exceed 8 bytes.
How was this patch tested?
Added unit test to covering the rewriting with different number of columns and different data types. Manually test the reported case and confirmed that this PR fix the bug.