You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "aokolnychyi (via GitHub)" <gi...@apache.org> on 2023/06/07 16:00:15 UTC
[GitHub] [spark] aokolnychyi opened a new pull request, #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
aokolnychyi opened a new pull request, #41499:
URL: https://github.com/apache/spark/pull/41499
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'core/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
This PR adds a new internal join hint to disable broadcasting and replicating one side of join.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
These changes are needed to disable broadcasting and replicating one side of join when it is not permitted, such as the cardinality check in MERGE operations in PR #41448.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
This PR comes with tests. More tests are in #41448.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] andylam-db commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "andylam-db (via GitHub)" <gi...@apache.org>.
andylam-db commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1237350122
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -341,6 +341,16 @@ trait JoinSelectionHelper {
)
}
+ def getBroadcastNestedLoopJoinBuildSide(hint: JoinHint): Option[BuildSide] = {
+ if (hintToNotBroadcastAndReplicateLeft(hint)) {
+ Some(BuildRight)
+ } else if (hintToNotBroadcastAndReplicateRight(hint)) {
+ Some(BuildLeft)
+ } else {
+ None
+ }
+ }
Review Comment:
`What about adding validation the new hint is set only on one side?`
Sounds good.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581596567
Thank you so much!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581828225
Thank you, @aokolnychyi and @viirya .
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1221854936
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -413,11 +423,19 @@ trait JoinSelectionHelper {
}
def hintToNotBroadcastLeft(hint: JoinHint): Boolean = {
Review Comment:
This method name seems to mismatch with the content because of the missing `NO_BROADCAST_AND_REPLICATION`.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -413,11 +423,19 @@ trait JoinSelectionHelper {
}
def hintToNotBroadcastLeft(hint: JoinHint): Boolean = {
- hint.leftHint.exists(_.strategy.contains(NO_BROADCAST_HASH))
+ hint.leftHint.flatMap(_.strategy).exists {
+ case NO_BROADCAST_HASH => true
+ case NO_BROADCAST_AND_REPLICATION => true
+ case _ => false
+ }
}
def hintToNotBroadcastRight(hint: JoinHint): Boolean = {
Review Comment:
Ditto.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1222006246
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -354,27 +367,29 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
}
def createCartesianProduct() = {
- if (joinType.isInstanceOf[InnerLike]) {
+ if (joinType.isInstanceOf[InnerLike] && !hintToNotBroadcastAndReplicate(hint)) {
Review Comment:
It is related to replication. If I am correct, it would zip each partition on one side with each partition on the other side so the same target record would appear in multiple places.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581314133
@dongjoon-hyun, I'll submit a follow-up PR with the comments.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1222009312
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -354,27 +367,29 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
}
def createCartesianProduct() = {
- if (joinType.isInstanceOf[InnerLike]) {
+ if (joinType.isInstanceOf[InnerLike] && !hintToNotBroadcastAndReplicate(hint)) {
Review Comment:
The new hint prohibits both broadcasting and replication so it applies to 3 cases:
- Broadcast hash
- Cartesian product
- BNLJ build side
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581593618
Triggered again: https://github.com/aokolnychyi/spark/actions/runs/5202190900
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1227428110
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -341,6 +341,16 @@ trait JoinSelectionHelper {
)
}
+ def getBroadcastNestedLoopJoinBuildSide(hint: JoinHint): Option[BuildSide] = {
+ if (hintToNotBroadcastAndReplicateLeft(hint)) {
+ Some(BuildRight)
+ } else if (hintToNotBroadcastAndReplicateRight(hint)) {
+ Some(BuildLeft)
+ } else {
+ None
+ }
+ }
Review Comment:
At the moment, the new hint can be only set on one side and never on both. BNLJ is considered as the default join strategy and having no broadcast and replicate hints on both sides would mean there is no matching join strategy to use. If we were to adapt the method above, we can't keep the existing default logic that picks the broadcast side based on size (that could cause a correctness problem). What about adding validation the new hint is set only on one side?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1222214820
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -354,27 +367,29 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
}
def createCartesianProduct() = {
- if (joinType.isInstanceOf[InnerLike]) {
+ if (joinType.isInstanceOf[InnerLike] && !hintToNotBroadcastAndReplicate(hint)) {
Review Comment:
It would be nice to update this to the pr description too.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581317617
Thank you, @viirya and @aokolnychyi . Now, pending CIs.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] andylam-db commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "andylam-db (via GitHub)" <gi...@apache.org>.
andylam-db commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1227029401
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -341,6 +341,16 @@ trait JoinSelectionHelper {
)
}
+ def getBroadcastNestedLoopJoinBuildSide(hint: JoinHint): Option[BuildSide] = {
+ if (hintToNotBroadcastAndReplicateLeft(hint)) {
+ Some(BuildRight)
+ } else if (hintToNotBroadcastAndReplicateRight(hint)) {
+ Some(BuildLeft)
+ } else {
+ None
+ }
+ }
Review Comment:
This logic is saying that if we hint to NOT broadcast left, we can broadcast right, and vice-versa. Shouldn't we check the hint on the other side as well?
i.e.
```
if (hintToNotBroadcastAndReplicateLeft(hint) && !hintToNotBroadcastAndReplicateRight(hint)) {
Some(BuildRight)
} else if (hintToNotBroadcastAndReplicateRight(hint) && !hintToNotBroadcastAndReplicateLeft(hint)) {
Some(BuildLeft)
} else {
None
}
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1238975832
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -341,6 +341,16 @@ trait JoinSelectionHelper {
)
}
+ def getBroadcastNestedLoopJoinBuildSide(hint: JoinHint): Option[BuildSide] = {
+ if (hintToNotBroadcastAndReplicateLeft(hint)) {
+ Some(BuildRight)
+ } else if (hintToNotBroadcastAndReplicateRight(hint)) {
+ Some(BuildLeft)
+ } else {
+ None
+ }
+ }
Review Comment:
Cool, I will work on it. Created SPARK-44148.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581555713
When you have a chance, could you re-trigger the failed test pipeline?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581121950
cc @dongjoon-hyun
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1221891159
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -288,7 +288,8 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
.orElse(createCartesianProduct())
.getOrElse {
// This join could be very slow or OOM
- val buildSide = getSmallerSide(left, right)
+ val requiredBuildSide = getBroadcastNestedLoopJoinBuildSide(hint)
+ val buildSide = requiredBuildSide.getOrElse(getSmallerSide(left, right))
Review Comment:
Could you add a comment about these two-line change because this is more complex than a single `getSmallerSide`, please?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1222006770
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -354,27 +367,29 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
}
def createCartesianProduct() = {
- if (joinType.isInstanceOf[InnerLike]) {
+ if (joinType.isInstanceOf[InnerLike] && !hintToNotBroadcastAndReplicate(hint)) {
Review Comment:
Oh, this is for replicating?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581914771
Thank you, @dongjoon-hyun @viirya! I've created #41509 to add comments.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581365553
It seems that `sql` test pipeline is killed by `receiving shutdown signal` somehow.
```
...
2023-06-07T18:39:01.1867247Z ##[error]The runner has received a shutdown signal. This can happen when the runner service is stopped, or a manually started runner is canceled.
2023-06-07T18:39:01.5173829Z Session terminated, killing shell...
2023-06-07T18:39:01.7418237Z ##[error]The operation was canceled.
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1222005887
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -354,27 +367,29 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
}
def createCartesianProduct() = {
- if (joinType.isInstanceOf[InnerLike]) {
+ if (joinType.isInstanceOf[InnerLike] && !hintToNotBroadcastAndReplicate(hint)) {
Review Comment:
Is `CartesianProduct` related to broadcast?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1222006246
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -354,27 +367,29 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
}
def createCartesianProduct() = {
- if (joinType.isInstanceOf[InnerLike]) {
+ if (joinType.isInstanceOf[InnerLike] && !hintToNotBroadcastAndReplicate(hint)) {
Review Comment:
It is related to replication.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581827665
Unfortunately, `master` branch still has the issue on `sql - other tests` module and the last test of this PR seems to be running over 4h 40minutes as of now.


This PR passed `catalyst` and all hive modules. I verified `JoinSuite` (and new test cases) manually.
```
$ build/sbt "sql/testOnly *.JoinSuite"
...
[info] JoinSuite:
20:13:26.224 WARN org.apache.hadoop.util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[info] - equi-join is hash-join (69 milliseconds)
[info] - NO_BROADCAST_AND_REPLICATION hint is respected in cross joins (19 milliseconds)
...
[info] Run completed in 25 seconds, 333 milliseconds.
[info] Total number of tests run: 50
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 50, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 60 s, completed Jun 7, 2023, 8:13:50 PM
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1227086605
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -341,6 +341,16 @@ trait JoinSelectionHelper {
)
}
+ def getBroadcastNestedLoopJoinBuildSide(hint: JoinHint): Option[BuildSide] = {
+ if (hintToNotBroadcastAndReplicateLeft(hint)) {
+ Some(BuildRight)
+ } else if (hintToNotBroadcastAndReplicateRight(hint)) {
+ Some(BuildLeft)
+ } else {
+ None
+ }
+ }
Review Comment:
cc @aokolnychyi
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] aokolnychyi commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "aokolnychyi (via GitHub)" <gi...@apache.org>.
aokolnychyi commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1227428110
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -341,6 +341,16 @@ trait JoinSelectionHelper {
)
}
+ def getBroadcastNestedLoopJoinBuildSide(hint: JoinHint): Option[BuildSide] = {
+ if (hintToNotBroadcastAndReplicateLeft(hint)) {
+ Some(BuildRight)
+ } else if (hintToNotBroadcastAndReplicateRight(hint)) {
+ Some(BuildLeft)
+ } else {
+ None
+ }
+ }
Review Comment:
At the moment, the new hint can be only set on one side and never on both. BNLJ is considered as the default join strategy and having no broadcast and replicate hints on both sides would mean there is no applicable fallback join strategy to use. If we were to adapt the method above, we can't keep the existing default logic that picks the broadcast side based on size (that could cause a correctness problem). What about adding validation the new hint is set only on one side?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun closed pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
URL: https://github.com/apache/spark/pull/41499
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #41499:
URL: https://github.com/apache/spark/pull/41499#issuecomment-1581124957
Thank you, @aokolnychyi !
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1222006770
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -354,27 +367,29 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
}
def createCartesianProduct() = {
- if (joinType.isInstanceOf[InnerLike]) {
+ if (joinType.isInstanceOf[InnerLike] && !hintToNotBroadcastAndReplicate(hint)) {
Review Comment:
Oh, this is for replicating?
EDIT: saw your reply after adding this comment.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #41499: [SPARK-44000][SQL] Add hint to disable broadcasting and replicating one side of join
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #41499:
URL: https://github.com/apache/spark/pull/41499#discussion_r1221980418
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala:
##########
@@ -288,7 +288,8 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
.orElse(createCartesianProduct())
.getOrElse {
// This join could be very slow or OOM
- val buildSide = getSmallerSide(left, right)
+ val requiredBuildSide = getBroadcastNestedLoopJoinBuildSide(hint)
+ val buildSide = requiredBuildSide.getOrElse(getSmallerSide(left, right))
Review Comment:
NVM. We can add that later in the main PR.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org