Q: single data frame parallel execution on multiple methods I have a SparkSQL dataframe having collection of employee records 
i.e id, name, salary, dept. I need to perform multiple operations parallel operations
on the same dataframe.
I implemented  this using Scala features but i don't know whether this code will work in cluster properly.
Code:
val pool = Executors.newFixedThreadPool(2)
implicit val xc=ExecutionContext.fromExecutorService(pool)

val taskC = findEmpRank(df)
    val taskA = doEmpDistinct(df)
    val taskB = doEmpSum(df)
    Await.result(Future.sequence(Seq(taskC, taskA, taskB)), Duration.Inf)
    }

def doEmpDistinct(df: DataFrame)(implicit xc: ExecutionContext) = Future {
    println("get distinct empno list")
    df.distinct.select("empno").show
}

def doEmpSum(df: DataFrame)(implicit xc: ExecutionContext) = Future {
    println("get AGGREGATE empno list")
    df.agg(sum("sal")).show()
}

def findEmpRank(df: DataFrame)(implicit xc: ExecutionContext) = Future {
    println("get EMP RANK")
    val partitionWindow =  
       Window.partitionBy(col("deptno")).orderBy(col("sal").desc) 
    val rankTest = rank().over(partitionWindow)
    df.select(col("*"), rankTest as "rank").show                       
}

Whether without Scala API is there anyway to perform this task parallel using spark.

A: Yes,  we can use Fair Scheduler but my question is can it give guarantee will wait until all the functions will complete like await.result in scala? 
