@@ -361,6 +361,46 @@ class SQLListenerSuite extends SparkFunSuite with SharedSQLContext with JsonTest
361361 assertJobs(store.execution(0 ), failed = Seq (0 ))
362362 }
363363
364+ sqlStoreTest(" handle one execution with multiple jobs" ) { (store, bus) =>
365+ val executionId = 0
366+ val df = createTestDataFrame
367+ bus.postToAll(SparkListenerSQLExecutionStart (
368+ executionId,
369+ " test" ,
370+ " test" ,
371+ df.queryExecution.toString,
372+ SparkPlanInfo .fromSparkPlan(df.queryExecution.executedPlan),
373+ System .currentTimeMillis()))
374+
375+ var stageId = 0
376+ def twoStageJob (jobId : Int ): Unit = {
377+ val stages = Seq (stageId, stageId + 1 ).map { id => createStageInfo(id, 0 )}
378+ stageId += 2
379+ bus.postToAll(SparkListenerJobStart (
380+ jobId = jobId,
381+ time = System .currentTimeMillis(),
382+ stageInfos = stages,
383+ createProperties(executionId)))
384+ stages.foreach { s =>
385+ bus.postToAll(SparkListenerStageSubmitted (s))
386+ bus.postToAll(SparkListenerStageCompleted (s))
387+ }
388+ bus.postToAll(SparkListenerJobEnd (
389+ jobId = jobId,
390+ time = System .currentTimeMillis(),
391+ JobSucceeded
392+ ))
393+ }
394+ // submit two jobs with the same executionId
395+ twoStageJob(0 )
396+ twoStageJob(1 )
397+ bus.postToAll(SparkListenerSQLExecutionEnd (
398+ executionId, System .currentTimeMillis()))
399+
400+ assertJobs(store.execution(0 ), completed = 0 to 1 )
401+ assert(store.execution(0 ).get.stages === (0 to 3 ).toSet)
402+ }
403+
364404 test(" SPARK-11126: no memory leak when running non SQL jobs" ) {
365405 val previousStageNumber = statusStore.executionsList().size
366406 spark.sparkContext.parallelize(1 to 10 ).foreach(i => ())
0 commit comments