Runtime and AppContext
AppContext[C] is what your run, extract, transform, or load methods receive.
Fields
final case class AppContext[C](
spark: SparkSession,
config: C,
args: Seq[String],
logger: Logger
)
IO Helpers
If your config exposes inputs and outputs, AppContext also gives you:
ctx.input("customers")
ctx.output("customer_orders")
ctx.readInput("customers")
ctx.writeOutput(customerOrders, "customer_orders")
When to Use It
ctx.sparkfor reads, transforms, and writesctx.configfor typed application settingsctx.argsfor extra runtime flags outside the framework corectx.loggerfor application-level loggingctx.readInput(...)andctx.writeOutput(...)for simple config-driven IO
Hooks Around Runtime
SparkApp gives you a few extension points before job logic runs:
validateConfigfor semantic checksbeforeSparkStartfor startup-side checks or loggingconfigureSparkfor Spark builder customization
These hooks keep setup code out of your actual business logic.