Commit d95f1da
committed
[SPARK-55973][SS] LeftSemi optimization for stream-stream join
### What changes were proposed in this pull request?
This PR proposes to apply a couple optimizations which stream-stream join with LeftSemi join type currently misses, mostly for state store.
The current implementation has below issues:
1. The operator bypasses storing the left side of the row when there is a match in the right side. But since the operator processes left side -> right side, we can't leverage this optimization when there is a match in the same batch.
2. The operator keeps the rows in the left side till watermark passes by, even though they were already matched and they won't be used as output ever again.
This PR proposes the below changes based on the observation:
1. The operator processes right side first, and then left side for LeftSemi join type. It actually doesn't matter for other join types to change the order, but they don't get the benefit so we don't introduce that change.
2. The operator aggressively removes the rows in the state on left side as long as it realizes they are matched with new row in the right side, rather than waiting for watermark to pass by.
The code change for the verification of the metrics from the tests for LeftSemi shows the impact of this optimization.
### Why are the changes needed?
Explained the above section.
### Does this PR introduce _any_ user-facing change?
It's mostly an internal change. There is user-facing change if they ever change the join type during the restart, but that is an area of "undocumented" and we do not define any behavior with it.
### How was this patch tested?
Existing tests and new tests.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude 4.6 opus (co-authored)
Closes #54769 from HeartSaVioR/SPARK-55973.
Authored-by: Jungtaek Lim <kabhwan.opensource@gmail.com>
Signed-off-by: Jungtaek Lim <kabhwan.opensource@gmail.com>1 parent 5fa8dc7 commit d95f1da
4 files changed
Lines changed: 488 additions & 136 deletions
File tree
- sql/core/src
- main/scala/org/apache/spark/sql/execution/streaming/operators/stateful/join
- test/scala/org/apache/spark/sql
- execution/streaming/state
- streaming
Lines changed: 43 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
397 | 401 | | |
398 | 402 | | |
399 | 403 | | |
| |||
412 | 416 | | |
413 | 417 | | |
414 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
415 | 422 | | |
416 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
417 | 426 | | |
418 | 427 | | |
419 | 428 | | |
| |||
535 | 544 | | |
536 | 545 | | |
537 | 546 | | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
538 | 552 | | |
539 | 553 | | |
540 | 554 | | |
| |||
664 | 678 | | |
665 | 679 | | |
666 | 680 | | |
| 681 | + | |
667 | 682 | | |
668 | 683 | | |
669 | 684 | | |
| |||
699 | 714 | | |
700 | 715 | | |
701 | 716 | | |
702 | | - | |
703 | | - | |
704 | 717 | | |
705 | 718 | | |
706 | 719 | | |
| |||
719 | 732 | | |
720 | 733 | | |
721 | 734 | | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
722 | 738 | | |
723 | 739 | | |
724 | 740 | | |
| |||
727 | 743 | | |
728 | 744 | | |
729 | 745 | | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
735 | 763 | | |
736 | 764 | | |
737 | 765 | | |
| |||
877 | 905 | | |
878 | 906 | | |
879 | 907 | | |
| 908 | + | |
| 909 | + | |
880 | 910 | | |
881 | 911 | | |
882 | 912 | | |
| |||
886 | 916 | | |
887 | 917 | | |
888 | 918 | | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
889 | 924 | | |
890 | 925 | | |
891 | 926 | | |
| |||
0 commit comments