Bug: Flaky Test: AdaptiveQueryExecSuite.multiple joins
Status: Resolved | Priority: Major | Resolution: Cannot Reproduce
Created: 14/Jul/20 11:41
Affects Version/s: 3.1.0

{code}
AdaptiveQueryExecSuite:
- Change merge join to broadcast join (313 milliseconds)
- Reuse the parallelism of CoalescedShuffleReaderExec in LocalShuffleReaderExec (265 milliseconds)
- Reuse the default parallelism in LocalShuffleReaderExec (230 milliseconds)
- Empty stage coalesced to 0-partition RDD (514 milliseconds)
- Scalar subquery (406 milliseconds)
- Scalar subquery in later stages (500 milliseconds)
- multiple joins *** FAILED *** (739 milliseconds)
  ArrayBuffer(BroadcastHashJoin [b#251429], [a#251438], Inner, BuildLeft
  :- BroadcastQueryStage 5
  :  +- BroadcastExchange HashedRelationBroadcastMode(List(cast(input[3, int, false] as bigint))), [id=#504817]
  :     +- CustomShuffleReader local
  :        +- ShuffleQueryStage 4
  :           +- Exchange hashpartitioning(b#251429, 5), true, [id=#504777]
  :              +- *(7) SortMergeJoin [key#251418], [a#251428], Inner
  :                 :- *(5) Sort [key#251418 ASC NULLS FIRST], false, 0
  :                 :  +- CustomShuffleReader coalesced
  :                 :     +- ShuffleQueryStage 0
  :                 :        +- Exchange hashpartitioning(key#251418, 5), true, [id=#504656]
  :                 :           +- *(1) Filter (isnotnull(value#251419) AND (cast(value#251419 as int) = 1))
  :                 :              +- *(1) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData, true])).key AS key#251418, staticinvoke(class org.apache.spark.unsafe.types.UTF8String, StringType, fromString, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData, true])).value, true, false) AS value#251419]
  :                 :                 +- Scan[obj#251417]
  :                 +- *(6) Sort [a#251428 ASC NULLS FIRST], false, 0
  :                    +- CustomShuffleReader coalesced
  :                       +- ShuffleQueryStage 1
  :                          +- Exchange hashpartitioning(a#251428, 5), true, [id=#504663]
  :                             +- *(2) Filter (b#251429 = 1)
  :                                +- *(2) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).a AS a#251428, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).b AS b#251429]
  :                                   +- Scan[obj#251427]
  +- BroadcastHashJoin [n#251498], [a#251438], Inner, BuildRight
     :- CustomShuffleReader local
     :  +- ShuffleQueryStage 2
     :     +- Exchange hashpartitioning(n#251498, 5), true, [id=#504680]
     :        +- *(3) Filter (n#251498 = 1)
     :           +- *(3) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$LowerCaseData, true])).n AS n#251498, staticinvoke(class org.apache.spark.unsafe.types.UTF8String, StringType, fromString, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$LowerCaseData, true])).l, true, false) AS l#251499]
     :              +- Scan[obj#251497]
     +- BroadcastQueryStage 6
        +- BroadcastExchange HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint))), [id=#504830]
           +- CustomShuffleReader local
              +- ShuffleQueryStage 3
                 +- Exchange hashpartitioning(a#251438, 5), true, [id=#504694]
                    +- *(4) Filter (a#251438 = 1)
                       +- *(4) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData3, true])).a AS a#251438, unwrapoption(IntegerType, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData3, true])).b) AS b#251439]
                          +- Scan[obj#251437]
  , BroadcastHashJoin [n#251498], [a#251438], Inner, BuildRight
  :- CustomShuffleReader local
  :  +- ShuffleQueryStage 2
  :     +- Exchange hashpartitioning(n#251498, 5), true, [id=#504680]
  :        +- *(3) Filter (n#251498 = 1)
  :           +- *(3) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$LowerCaseData, true])).n AS n#251498, staticinvoke(class org.apache.spark.unsafe.types.UTF8String, StringType, fromString, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$LowerCaseData, true])).l, true, false) AS l#251499]
  :              +- Scan[obj#251497]
  +- BroadcastQueryStage 6
     +- BroadcastExchange HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint))), [id=#504830]
        +- CustomShuffleReader local
           +- ShuffleQueryStage 3
              +- Exchange hashpartitioning(a#251438, 5), true, [id=#504694]
                 +- *(4) Filter (a#251438 = 1)
                    +- *(4) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData3, true])).a AS a#251438, unwrapoption(IntegerType, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData3, true])).b) AS b#251439]
                       +- Scan[obj#251437]
  ) had size 2 instead of expected size 3 (AdaptiveQueryExecSuite.scala:296)
  org.scalatest.exceptions.TestFailedException:
  at org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:530)
  at org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:529)
  at org.scalatest.FunSuite.newAssertionFailedException(FunSuite.scala:1560)
  at org.scalatest.Assertions$AssertionsHelper.macroAssert(Assertions.scala:503)
  at org.apache.spark.sql.execution.adaptive.AdaptiveQueryExecSuite.$anonfun$new$22(AdaptiveQueryExecSuite.scala:296)
  at org.apache.spark.sql.catalyst.plans.SQLHelper.withSQLConf(SQLHelper.scala:54)
  at org.apache.spark.sql.catalyst.plans.SQLHelper.withSQLConf$(SQLHelper.scala:38)
  at org.apache.spark.sql.execution.adaptive.AdaptiveQueryExecSuite.org$apache$spark$sql$test$SQLTestUtilsBase$$super$withSQLConf(AdaptiveQueryExecSuite.scala:40)
  at org.apache.spark.sql.test.SQLTestUtilsBase.withSQLConf(SQLTestUtils.scala:246)
  at org.apache.spark.sql.test.SQLTestUtilsBase.withSQLConf$(SQLTestUtils.scala:244)
  at org.apache.spark.sql.execution.adaptive.AdaptiveQueryExecSuite.withSQLConf(AdaptiveQueryExecSuite.scala:40)
  at org.apache.spark.sql.execution.adaptive.AdaptiveQueryExecSuite.$anonfun$new$21(AdaptiveQueryExecSuite.scala:282)
  at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
  at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
  at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
  at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
  at org.scalatest.Transformer.apply(Transformer.scala:22)
  at org.scalatest.Transformer.apply(Transformer.scala:20)
  at org.scalatest.FunSuiteLike$$anon$1.apply(FunSuiteLike.scala:186)
  at org.apache.spark.SparkFunSuite.withFixture(SparkFunSuite.scala:157)
  at org.scalatest.FunSuiteLike.invokeWithFixture$1(FunSuiteLike.scala:184)
  at org.scalatest.FunSuiteLike.$anonfun$runTest$1(FunSuiteLike.scala:196)
  at org.scalatest.SuperEngine.runTestImpl(Engine.scala:286)
  at org.scalatest.FunSuiteLike.runTest(FunSuiteLike.scala:196)
  at org.scalatest.FunSuiteLike.runTest$(FunSuiteLike.scala:178)
  at org.apache.spark.SparkFunSuite.org$scalatest$BeforeAndAfterEach$$super$runTest(SparkFunSuite.scala:59)
  at org.scalatest.BeforeAndAfterEach.runTest(BeforeAndAfterEach.scala:221)
  at org.scalatest.BeforeAndAfterEach.runTest$(BeforeAndAfterEach.scala:214)
  at org.apache.spark.SparkFunSuite.runTest(SparkFunSuite.scala:59)
  at org.scalatest.FunSuiteLike.$anonfun$runTests$1(FunSuiteLike.scala:229)
  at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:393)
  at scala.collection.immutable.List.foreach(List.scala:392)
  at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:381)
  at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:376)
  at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:458)
  at org.scalatest.FunSuiteLike.runTests(FunSuiteLike.scala:229)
  at org.scalatest.FunSuiteLike.runTests$(FunSuiteLike.scala:228)
  at org.scalatest.FunSuite.runTests(FunSuite.scala:1560)
  at org.scalatest.Suite.run(Suite.scala:1124)
  at org.scalatest.Suite.run$(Suite.scala:1106)
  at org.scalatest.FunSuite.org$scalatest$FunSuiteLike$$super$run(FunSuite.scala:1560)
  at org.scalatest.FunSuiteLike.$anonfun$run$1(FunSuiteLike.scala:233)
  at org.scalatest.SuperEngine.runImpl(Engine.scala:518)
  at org.scalatest.FunSuiteLike.run(FunSuiteLike.scala:233)
  at org.scalatest.FunSuiteLike.run$(FunSuiteLike.scala:232)
  at org.apache.spark.SparkFunSuite.org$scalatest$BeforeAndAfterAll$$super$run(SparkFunSuite.scala:59)
  at org.scalatest.BeforeAndAfterAll.liftedTree1$1(BeforeAndAfterAll.scala:213)
  at org.scalatest.BeforeAndAfterAll.run(BeforeAndAfterAll.scala:210)
  at org.scalatest.BeforeAndAfterAll.run$(BeforeAndAfterAll.scala:208)
  at org.apache.spark.SparkFunSuite.run(SparkFunSuite.scala:59)
  at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:317)
  at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:510)
  at sbt.ForkMain$Run$2.call(ForkMain.java:296)
  at sbt.ForkMain$Run$2.call(ForkMain.java:286)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  at java.lang.Thread.run(Thread.java:748)
{code}