0

I was trying to use different builders to build the SparkSession and AmmoniteSparkSession requires repl.

This won't work, i think it is because repl is a compile time error.

val sparkSessionBuilder =
  try {
    repl
    AmmoniteSparkSession.builder
  } catch {
    case e: Exception => SparkSession.builder
  }
Dyno Fu
  • 8,753
  • 4
  • 39
  • 64

1 Answers1

1

as it is compile time, we have to use the Multi-stageScripts to load different script according to the context. it should work something like here

val sparkSessionModule = sys.env.get("AMMONITE_REPL") match {
  case None => pwd / RelPath("libs/_SparkSession.sc")
  case Some(_) => pwd / RelPath("libs/_AmmoniteSparkSession.sc")
}
interp.load.module(sparkSessionModule)
@
Dyno Fu
  • 8,753
  • 4
  • 39
  • 64