Commit e861b0d
[SPARK-36794][SQL] Ignore duplicated join keys when building relation for SEMI/ANTI shuffled hash join
### What changes were proposed in this pull request?
This is a re-proposal of #34034. Ignore duplicated join keys when building hash relation for LEFT SEMI / LEFT ANTI shuffled hash join. The original PR was also covering broadcast hash join, and caused regression for broadcast shuffle exchange reuse in #34034 (comment) . So here we do not covert broadcast hash join. Shuffled hash join do not have the shuffle reuse problem.
Make the deduplication work with broadcast exchange is kind of non-trivial for me now, because:
For two `BroadcastExchangeExec`, one with `ignoreDuplicatedKey` being true (called `exchange_A`), and the other with `ignoreDuplicatedKey` being false (called `exchange_B`):
* If we decide these two `BroadcastExchangeExec`s are not equal, then we have regression that we reuse fewer exchange after the change, as #34034 (comment) .
* If we decide these two `BroadcastExchangeExec`s are equal, then we might have correctness issue when `exchange_B` reuses result of `exchange_A`. Also these two `BroadcastExchangeExec`s should not be equal as they already have different results in underlying hash relations.
I still see it's valuable to have the optimization for shuffled hash join only. So leave the optimization for broadcast hash join as a followup as it needs more thoughts.
### Why are the changes needed?
Help reduce the hash table size of join for LEFT SEMI and LEFT ANTI, reduce OOM possibility of shuffled hash join.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Added unit test in `JoinSuite.scala`.
Closes #34247 from c21/shj-fix.
Authored-by: Cheng Su <chengsu@fb.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>1 parent 92caa75 commit e861b0d
3 files changed
Lines changed: 70 additions & 12 deletions
File tree
- sql/core/src
- main/scala/org/apache/spark/sql/execution/joins
- test/scala/org/apache/spark/sql
Lines changed: 19 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
130 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
138 | | - | |
| 141 | + | |
| 142 | + | |
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| |||
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
155 | | - | |
| 159 | + | |
| 160 | + | |
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| |||
450 | 455 | | |
451 | 456 | | |
452 | 457 | | |
453 | | - | |
| 458 | + | |
| 459 | + | |
454 | 460 | | |
455 | 461 | | |
456 | 462 | | |
| |||
471 | 477 | | |
472 | 478 | | |
473 | 479 | | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
480 | 488 | | |
481 | 489 | | |
482 | 490 | | |
| |||
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
62 | 73 | | |
63 | 74 | | |
64 | 75 | | |
| |||
72 | 83 | | |
73 | 84 | | |
74 | 85 | | |
75 | | - | |
| 86 | + | |
| 87 | + | |
76 | 88 | | |
77 | 89 | | |
78 | 90 | | |
| |||
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1402 | 1402 | | |
1403 | 1403 | | |
1404 | 1404 | | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
1405 | 1443 | | |
0 commit comments