Experiments around executing spark queries in parallel.
Three methods are used here: -
-
ParallelWithFutures uses standard Scala Futures and callbacks.
-
ParallelWithCats uses Cats Effect library to wrap the spark context in a Resource and
parTraverseNto control level of parallelism. -
ParallelWithZIO uses ZIO to wrap the spark context in a ZIO Scope and use
foreachParto run the queries in parallel. The ZIOAspect.parallel aspect controls the level of parallelism.
Uncomment the line : -
// Uncomment the following line to pause the code and allow the Spark UI to be viewed
//scala.io.StdIn.readLine()to view the Spark UI.
Note: Use method closeSparkSessionWithPause to keep the Spark UI active.
Add the following to Java options to run : -
--add-exports java.base/sun.nio.ch=ALL-UNNAMED
- Lift the SparkEnv config into a ZIO layer also. See zio.config package.

