c21 commented on a change in pull request #31931:
URL: https://github.com/apache/spark/pull/31931#discussion_r599129435
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala
##########
@@ -211,6 +211,44 @@ class WholeStageCodegenSuite extends QueryTest with
SharedSparkSession
}
}
+ test("Left/Right outer BroadcastNestedLoopJoinExec should be included in
WholeStageCodegen") {
+ val df1 = spark.range(4).select($"id".as("k1"))
+ val df2 = spark.range(3).select($"id".as("k2"))
+ val df3 = spark.range(2).select($"id".as("k3"))
+
+ Seq(true, false).foreach { codegenEnabled =>
+ withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key ->
codegenEnabled.toString) {
+ // test left outer join
+ val leftOuterJoinDF = df1.join(df2, $"k1" > $"k2", "left_outer")
+ var hasJoinInCodegen =
leftOuterJoinDF.queryExecution.executedPlan.collect {
+ case WholeStageCodegenExec(_: BroadcastNestedLoopJoinExec) => true
+ }.size === 1
+ assert(hasJoinInCodegen == codegenEnabled)
+ checkAnswer(leftOuterJoinDF,
+ Seq(Row(0, null), Row(1, 0), Row(2, 0), Row(2, 1), Row(3, 0), Row(3,
1), Row(3, 2)))
+
+ // test right outer join
+ val rightOuterJoinDF = df1.join(df2, $"k1" < $"k2", "right_outer")
+ hasJoinInCodegen =
rightOuterJoinDF.queryExecution.executedPlan.collect {
+ case WholeStageCodegenExec(_: BroadcastNestedLoopJoinExec) => true
+ }.size === 1
+ assert(hasJoinInCodegen == codegenEnabled)
+ checkAnswer(rightOuterJoinDF, Seq(Row(null, 0), Row(0, 1), Row(0, 2),
Row(1, 2)))
+
+ // test a combination of left outer and right outer joins
+ val twoJoinsDF = df1.join(df2, $"k1" > $"k2" + 1, "right_outer")
+ .join(df3, $"k1" <= $"k3", "left_outer")
+ hasJoinInCodegen = twoJoinsDF.queryExecution.executedPlan.collect {
+ case WholeStageCodegenExec(BroadcastNestedLoopJoinExec(
+ _: BroadcastNestedLoopJoinExec, _, _, _, _)) => true
Review comment:
nit: seems indentation is off.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]