maropu commented on a change in pull request #28330:
URL: https://github.com/apache/spark/pull/28330#discussion_r415179658



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/metric/SQLMetricsSuite.scala
##########
@@ -341,6 +341,62 @@ class SQLMetricsSuite extends SharedSparkSession with 
SQLMetricsTestUtils
     }
   }
 
+  test("ShuffledHashJoin(outer) metrics") {
+    withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "40",
+      SQLConf.SHUFFLE_PARTITIONS.key -> "2",
+      SQLConf.PREFER_SORTMERGEJOIN.key -> "false") {
+      val df1 = Seq((1, "1"), (2, "2")).toDF("key", "value")
+      val df2 = (1 to 10).map(i => (i, i.toString)).toSeq.toDF("key2", "value")
+
+      Seq(("right_outer", 0L, df1, df2, false), ("left_outer", 0L, df2, df1, 
false),
+        ("right_outer", 0L, df1, df2, true), ("left_outer", 0L, df2, df1, 
true))
+        .foreach { case (joinType, nodeId, df1, df2, enableWholeStage) =>
+          val df = df1.join(df2, $"key" === $"key2", joinType)
+          testSparkPlanMetrics(df, 1, Map(
+            nodeId -> (("ShuffledHashJoin", Map(
+              "number of output rows" -> 10L)))),
+            enableWholeStage
+          )
+        }
+    }
+  }
+
+  test("ShuffledHashJoin(left-anti) metrics") {
+    withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+      SQLConf.SHUFFLE_PARTITIONS.key -> "2",
+      SQLConf.PREFER_SORTMERGEJOIN.key -> "false") {
+      val df1 = Seq((1, "1"), (2, "2")).toDF("key", "value")
+      val df2 = (1 to 10).map(i => (i, i.toString)).toSeq.toDF("key2", "value")
+
+      Seq((2L, true), (1L, false)).foreach { case (nodeId, enableWholeStage) =>
+        val df = df2.join(df1.hint("shuffle_hash"), $"key" === $"key2", 
"left_anti")
+        testSparkPlanMetrics(df, 1, Map(
+          nodeId -> (("ShuffledHashJoin", Map(
+            "number of output rows" -> 8L)))),
+          enableWholeStage
+        )
+      }
+    }
+  }
+
+  test("ShuffledHashJoin(left-semi) metrics") {
+    withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+      SQLConf.SHUFFLE_PARTITIONS.key -> "2",
+      SQLConf.PREFER_SORTMERGEJOIN.key -> "false") {
+      val df1 = Seq((1, "1"), (2, "2")).toDF("key", "value")
+      val df2 = (1 to 10).map(i => (i, i.toString)).toSeq.toDF("key2", "value")
+
+      Seq((1L, false), (2L, true)).foreach { case (nodeId, enableWholeStage) =>
+        val df = df2.join(df1.hint("shuffle_hash"), $"key" === $"key2", 
"left_semi")
+        testSparkPlanMetrics(df, 1, Map(
+          nodeId -> (("ShuffledHashJoin", Map(
+            "number of output rows" -> 2L)))),

Review comment:
       We need to split this join test into three parts? It seems the only 
metric value is different between them.




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to