Commit 1436c5a
committed
[SPARK-44647][SQL] Support SPJ where join keys are less than cluster keys
### What changes were proposed in this pull request?
- Add new conf spark.sql.sources.v2.bucketing.allowJoinKeysSubsetOfPartitionKeys.enabled
- Change key compatibility checks in EnsureRequirements. Remove checks where all partition keys must be in join keys to allow isKeyCompatible = true in this case (if this flag is enabled)
- "Project" partitions by join keys in KeyGroupedPartitioning/KeyGroupedShuffleSpec
- Add join key grouping to the partition grouping in BatchScanExec
### Why are the changes needed?
- Support Storage Partition Join in cases where the join condition does not contain all the partition keys, but just some of them
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
-Added tests in KeyGroupedPartitioningSuite
-Because of apache#37886 we have to select all join keys to trigger SPJ in this case, otherwise DSV2 scan does not report KeyGroupedPartitioning and SPJ does not get triggered. Need to see how to relax this in separate PR.1 parent fd424ca commit 1436c5a
File tree
5 files changed
+375
-32
lines changed- sql
- catalyst/src/main/scala/org/apache/spark/sql
- catalyst/plans/physical
- internal
- core/src
- main/scala/org/apache/spark/sql/execution
- datasources/v2
- exchange
- test/scala/org/apache/spark/sql/connector
5 files changed
+375
-32
lines changedLines changed: 45 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
359 | 366 | | |
360 | 367 | | |
361 | 368 | | |
| |||
364 | 371 | | |
365 | 372 | | |
366 | 373 | | |
367 | | - | |
368 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
369 | 389 | | |
370 | 390 | | |
371 | 391 | | |
| |||
378 | 398 | | |
379 | 399 | | |
380 | 400 | | |
381 | | - | |
382 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
383 | 420 | | |
384 | 421 | | |
385 | 422 | | |
| |||
674 | 711 | | |
675 | 712 | | |
676 | 713 | | |
677 | | - | |
| 714 | + | |
| 715 | + | |
678 | 716 | | |
679 | 717 | | |
680 | 718 | | |
| |||
709 | 747 | | |
710 | 748 | | |
711 | 749 | | |
712 | | - | |
| 750 | + | |
713 | 751 | | |
714 | 752 | | |
715 | 753 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1530 | 1530 | | |
1531 | 1531 | | |
1532 | 1532 | | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
1533 | 1545 | | |
1534 | 1546 | | |
1535 | 1547 | | |
| |||
4936 | 4948 | | |
4937 | 4949 | | |
4938 | 4950 | | |
| 4951 | + | |
| 4952 | + | |
| 4953 | + | |
4939 | 4954 | | |
4940 | 4955 | | |
4941 | 4956 | | |
| |||
Lines changed: 39 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
124 | 129 | | |
125 | 130 | | |
126 | 131 | | |
| |||
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
135 | | - | |
136 | | - | |
137 | | - | |
| 140 | + | |
138 | 141 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
143 | 163 | | |
144 | 164 | | |
145 | 165 | | |
| |||
149 | 169 | | |
150 | 170 | | |
151 | 171 | | |
152 | | - | |
| 172 | + | |
153 | 173 | | |
154 | 174 | | |
155 | 175 | | |
156 | 176 | | |
157 | | - | |
| 177 | + | |
158 | 178 | | |
159 | 179 | | |
160 | 180 | | |
| |||
169 | 189 | | |
170 | 190 | | |
171 | 191 | | |
172 | | - | |
| 192 | + | |
173 | 193 | | |
174 | 194 | | |
175 | 195 | | |
176 | 196 | | |
177 | | - | |
| 197 | + | |
178 | 198 | | |
179 | 199 | | |
180 | 200 | | |
181 | | - | |
| 201 | + | |
182 | 202 | | |
183 | 203 | | |
184 | 204 | | |
185 | 205 | | |
186 | 206 | | |
187 | 207 | | |
188 | | - | |
| 208 | + | |
189 | 209 | | |
190 | 210 | | |
191 | 211 | | |
192 | 212 | | |
193 | 213 | | |
194 | 214 | | |
195 | | - | |
| 215 | + | |
196 | 216 | | |
197 | 217 | | |
198 | | - | |
| 218 | + | |
199 | 219 | | |
200 | 220 | | |
201 | 221 | | |
202 | | - | |
| 222 | + | |
203 | 223 | | |
204 | 224 | | |
205 | 225 | | |
| |||
234 | 254 | | |
235 | 255 | | |
236 | 256 | | |
| 257 | + | |
237 | 258 | | |
238 | 259 | | |
239 | 260 | | |
| |||
247 | 268 | | |
248 | 269 | | |
249 | 270 | | |
| 271 | + | |
250 | 272 | | |
251 | 273 | | |
252 | 274 | | |
| |||
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
| 384 | + | |
384 | 385 | | |
385 | 386 | | |
386 | 387 | | |
| |||
505 | 506 | | |
506 | 507 | | |
507 | 508 | | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
512 | 513 | | |
513 | 514 | | |
514 | 515 | | |
| |||
530 | 531 | | |
531 | 532 | | |
532 | 533 | | |
| 534 | + | |
533 | 535 | | |
534 | 536 | | |
535 | 537 | | |
536 | 538 | | |
537 | 539 | | |
538 | 540 | | |
| 541 | + | |
539 | 542 | | |
540 | 543 | | |
541 | 544 | | |
542 | 545 | | |
543 | 546 | | |
544 | 547 | | |
545 | | - | |
| 548 | + | |
546 | 549 | | |
547 | 550 | | |
548 | 551 | | |
| |||
0 commit comments