Uh oh!
There was an error while loading. Please reload this page.
[SPARK-34707][SQL] Code-gen broadcast nested loop join (left outer/right outer) - #31931
[SPARK-34707][SQL] Code-gen broadcast nested loop join (left outer/right outer)#31931linzebing wants to merge 2 commits into
Conversation
c21
commented
Mar 22, 2021
Thanks @linzebing for working on this. Can you add |
c21
commented
Mar 22, 2021
I am looking this, also cc @cloud-fan and @maropu for review if you have time, thanks. |
c21
commented
Mar 22, 2021
Also the JIRA should be |
linzebing
commented
Mar 22, 2021
One unit test in SQLMetricsSuite failed. Let me check. |
maropu
commented
Mar 22, 2021
ok to test |
maropu
commented
Mar 22, 2021
I'll check it later, too. Thanks for your work, @linzebing ! |
e7f119b to
08e47d2Comparelinzebing
commented
Mar 22, 2021
Fixed test. |
| s""" | ||
| |boolean $foundMatch = false; | ||
| |for (int $arrayIndex = 0; $arrayIndex < $buildRowArrayTerm.length; $arrayIndex++) { |
There was a problem hiding this comment.
What about the broadcast side to be empty? It seems not right here because we still need to output one row for streamed side.
There was a problem hiding this comment.
Yes, you are right. Let me address this.
| .join(df3, $"k1" <= $"k3", "left_outer") | ||
| hasJoinInCodegen = twoJoinsDF.queryExecution.executedPlan.collect { | ||
| case WholeStageCodegenExec(BroadcastNestedLoopJoinExec( | ||
| _: BroadcastNestedLoopJoinExec, _, _, _, _)) => true |
| Seq(true, false).foreach { codegenEnabled => | ||
| withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> codegenEnabled.toString) { | ||
| // test left outer join |
There was a problem hiding this comment.
how about adding an extra test case for broadcast side being empty?
SparkQA
commented
Mar 23, 2021
Kubernetes integration test starting |
SparkQA
commented
Mar 23, 2021
Kubernetes integration test status success |
SparkQA
commented
Mar 23, 2021
Kubernetes integration test starting |
SparkQA
commented
Mar 23, 2021
Kubernetes integration test status failure |
SparkQA
commented
Mar 23, 2021
Test build #136367 has finished for PR 31931 at commit
|
SparkQA
commented
Mar 23, 2021
Test build #136374 has finished for PR 31931 at commit
|
cloud-fan
commented
Mar 23, 2021
thanks, merging to master! |
maropu
commented
Mar 23, 2021
late lgtm. |
What changes were proposed in this pull request?
This PR is to add code-gen support for left outer (build right) and right outer (build left). Reference:
BroadcastNestedLoopJoinExec.codegenInner()andBroadcastNestedLoopJoinExec.outerJoin()Why are the changes needed?
Improve query CPU performance.
Tested with a simple query:
Seeing 2x run time improvement:
Does this PR introduce any user-facing change?
No
How was this patch tested?
Changed existing unit tests in
OuterJoinSuiteto cover codegen use cases.Added unit test in WholeStageCodegenSuite.scala to make sure code-gen for broadcast nested loop join is taking effect, and test for multiple join case as well.
Example query:
Example generated code (
bnlj_doConsume_0method):