Uh oh!
There was an error while loading. Please reload this page.
[SPARK-32282][SQL] Improve EnsureRquirement.reorderJoinKeys to handle more scenarios such as PartitioningCollection - #29074
[SPARK-32282][SQL] Improve EnsureRquirement.reorderJoinKeys to handle more scenarios such as PartitioningCollection#29074imback82 wants to merge 13 commits into
Conversation
| leftKeys, rightKeys, UnknownPartitioning(0), rightPartitioning)) | ||
| case (_, HashPartitioning(rightExpressions, _)) => | ||
| reorder(leftKeys.toIndexedSeq, rightKeys.toIndexedSeq, rightExpressions, rightKeys) | ||
| .orElse(reorderJoinKeysRecursively( |
There was a problem hiding this comment.
This can be also implemented by looking at left partitioning first then move to the right partitionoing:
(leftPartitioning, rightPartitioning) match {
case (HashPartitioning(leftExpressions, _), _) =>
reorder(leftKeys.toIndexedSeq, rightKeys.toIndexedSeq, leftExpressions, leftKeys)
.orElse(reorderJoinKeysRecursively(
leftKeys, rightKeys, UnknownPartitioning(0), rightPartitioning))
case (PartitioningCollection(partitionings), _) =>
partitionings.foreach { p =>
reorderJoinKeysRecursively(leftKeys, rightKeys, p, rightPartitioning).map { k =>returnSome(k)
}
}
reorderJoinKeysRecursively(leftKeys, rightKeys, UnknownPartitioning(0), rightPartitioning)
case (_, HashPartitioning(rightExpressions, _)) =>
reorder(leftKeys.toIndexedSeq, rightKeys.toIndexedSeq, rightExpressions, rightKeys)
case (_, PartitioningCollection(partitionings)) =>
partitionings.foreach { p =>
reorderJoinKeysRecursively(leftKeys, rightKeys, leftPartitioning, p).map { k =>returnSome(k)
}
}
Nonecase _ =>None
}However, I chose this way so that the behavior remains the same. If you have leftPartitioning = PartitioningCollection and rightPartitioning = HashPartitioning, it will match the rightPartitioning first, which is the existing behavior.
SparkQA
commented
Jul 12, 2020
Test build #125704 has finished for PR 29074 at commit
|
imback82
commented
Jul 12, 2020
retest this please |
SparkQA
commented
Jul 12, 2020
Test build #125722 has finished for PR 29074 at commit
|
imback82
commented
Jul 13, 2020
maropu
commented
Jul 13, 2020
also cc: @viirya |
SparkQA
commented
Jul 15, 2020
Test build #125890 has finished for PR 29074 at commit
|
SparkQA
commented
Jul 16, 2020
Test build #125917 has finished for PR 29074 at commit
|
imback82
commented
Jul 27, 2020
Gentle ping @cloud-fan / @maropu / @viirya |
SparkQA
commented
Aug 2, 2020
Test build #126928 has finished for PR 29074 at commit
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Aug 7, 2020
Test build #127164 has finished for PR 29074 at commit
|
There was a problem hiding this comment.
Looks okay except for the existing minor comments. @cloud-fan@viirya
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Aug 7, 2020
Test build #127213 has finished for PR 29074 at commit
|
maropu
commented
Aug 22, 2020
retest this please |
SparkQA
commented
Aug 22, 2020
Test build #127775 has finished for PR 29074 at commit
|
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Aug 24, 2020
Test build #127850 has finished for PR 29074 at commit
|
imback82
commented
Aug 31, 2020
Gentle ping. @cloud-fan, do you think this PR can move forward? Thanks in advance! |
maropu
commented
Sep 9, 2020
retest this please |
SparkQA
commented
Sep 9, 2020
Test build #128455 has finished for PR 29074 at commit
|
maropu
commented
Sep 28, 2020
retest this please |
SparkQA
commented
Sep 28, 2020
Kubernetes integration test starting |
SparkQA
commented
Sep 28, 2020
Kubernetes integration test status success |
SparkQA
commented
Sep 28, 2020
Test build #129183 has finished for PR 29074 at commit
|
| case (Some(PartitioningCollection(partitionings)), _) => | ||
| partitionings.foreach { p => | ||
| reorderJoinKeysRecursively(leftKeys, rightKeys, Some(p), rightPartitioning).map { k => | ||
| return Some(k) |
There was a problem hiding this comment.
nit:
partitionings.foldLeft(None) { (res, p) =>
res.orElse(reorderJoinKeysRecursively...)
}.getOrElse(reorderJoinKeysRecursively(leftKeys, rightKeys, None, rightPartitioning))
| ShuffleExchangeExec(HashPartitioning(rightPartitioningExpressions, _), _, _), _), _) => | ||
| assert(leftKeys !== smjExec1.leftKeys) | ||
| assert(rightKeys !== smjExec1.rightKeys) | ||
| assert(leftKeys === leftPartitionings.head.asInstanceOf[HashPartitioning].expressions) |
There was a problem hiding this comment.
can we simply check leftKeys === Seq(exprA, exprB)?
There was a problem hiding this comment.
OK. I simplified the checks in this test.
cloud-fan
left a comment
There was a problem hiding this comment.
LGTM except some minor comments
SparkQA
commented
Oct 7, 2020
Kubernetes integration test starting |
SparkQA
commented
Oct 7, 2020
Kubernetes integration test status success |
SparkQA
commented
Oct 7, 2020
Test build #129483 has finished for PR 29074 at commit
|
| res.orElse(reorderJoinKeysRecursively(leftKeys, rightKeys, Some(p), rightPartitioning)) | ||
| }.orElse(reorderJoinKeysRecursively(leftKeys, rightKeys, None, rightPartitioning)) | ||
| case (_, Some(PartitioningCollection(partitionings))) => | ||
| partitionings.foreach { p => |
There was a problem hiding this comment.
can you do the same refactor here?
| case SortMergeJoinExec(leftKeys, rightKeys, _, _, | ||
| SortExec(_, _, DummySparkPlan(_, _, _: PartitioningCollection, _, _), _), | ||
| SortExec(_, _, ShuffleExchangeExec(_: HashPartitioning, _, _), _), _) => | ||
| assert(leftKeys !== smjExec1.leftKeys) |
There was a problem hiding this comment.
is this check needed? We already check leftKeys === Seq(exprA, exprB) and it's obvious that leftKeys !== smjExec1.leftKeys
SparkQA
commented
Oct 7, 2020
Kubernetes integration test starting |
SparkQA
commented
Oct 7, 2020
Kubernetes integration test status failure |
SparkQA
commented
Oct 7, 2020
Test build #129523 has finished for PR 29074 at commit
|
cloud-fan
commented
Oct 8, 2020
thanks, merging to master! |
What changes were proposed in this pull request?
This PR proposes to improve
EnsureRquirement.reorderJoinKeysto handle the following scenarios:HashPartitioning, consider the right-sideHashPartitioning.PartitioningCollection, which may containHashPartitioningWhy are the changes needed?
HashPartitioningor the right-sideHashPartitioning. This means that if both sides areHashPartitioning, it will try to match only the left side.The following will not consider the right-side
HashPartitioning:PartitioningCollection:Does this PR introduce any user-facing change?
Yes, now from the above examples, the shuffle/sort nodes pointed by
This can be removedare now removed:How was this patch tested?
Added tests.