@@ -356,21 +356,33 @@ class SQLMetricsSuite extends SparkFunSuite with SharedSQLContext {
356356 )
357357 assert(res2 === (150L , 0L , 150L ) :: (0L , 150L , 10L ) :: Nil )
358358
359- withTempDir { tempDir =>
360- val dir = new File (tempDir, " pqS" ).getCanonicalPath
359+ Seq (true , false ).foreach { executorBroadcast =>
360+ withSQLConf(SQLConf .EXECUTOR_SIDE_BROADCAST_ENABLED .key -> executorBroadcast.toString) {
361+ withTempDir { tempDir =>
362+ val dir = new File (tempDir, " pqS" ).getCanonicalPath
361363
362- spark.range(10 ).write.parquet(dir)
363- spark.read.parquet(dir).createOrReplaceTempView(" pqS" )
364+ spark.range(10 ).write.parquet(dir)
365+ spark.read.parquet(dir).createOrReplaceTempView(" pqS" )
364366
365- val res3 = InputOutputMetricsHelper .run(
366- spark.range(30 ).repartition(3 ).crossJoin(sql(" select * from pqS" )).repartition(2 ).toDF()
367- )
368- // The query above is executed in the following stages:
369- // 1. sql("select * from pqS") => (10, 0, 10)
370- // 2. range(30) => (30, 0, 30)
371- // 3. crossJoin(...) of 1. and 2. => (0, 30, 300)
372- // 4. shuffle & return results => (0, 300, 0)
373- assert(res3 === (10L , 0L , 10L ) :: (30L , 0L , 30L ) :: (0L , 30L , 300L ) :: (0L , 300L , 0L ) :: Nil )
367+ val res3 = InputOutputMetricsHelper .run(
368+ spark.range(30 ).repartition(3 ).crossJoin(sql(" select * from pqS" )).repartition(2 ).toDF()
369+ )
370+ // The query above is executed in the following stages:
371+ // 1a. sql("select * from pqS") => (10, 0, 10)
372+ // 1b. (only when `SQLConf.EXECUTOR_SIDE_BROADCAST_ENABLED` is enabled)
373+ // executor-size-broadcast => (0, 0, 0)
374+ // 2. range(30) => (30, 0, 30)
375+ // 3. crossJoin(...) of 1. and 2. => (0, 30, 300)
376+ // 4. shuffle & return results => (0, 300, 0)
377+ val expected = if (executorBroadcast) {
378+ (10L , 0L , 10L ) :: (0L , 0L , 0L ) :: (30L , 0L , 30L ) :: (0L , 30L , 300L ) ::
379+ (0L , 300L , 0L ) :: Nil
380+ } else {
381+ (10L , 0L , 10L ) :: (30L , 0L , 30L ) :: (0L , 30L , 300L ) :: (0L , 300L , 0L ) :: Nil
382+ }
383+ assert(res3 === expected)
384+ }
385+ }
374386 }
375387 }
376388}
0 commit comments