In scala you can write a a function like:
object Add extends ((Int, Int) => Int) {
def apply(a: Int, b: Int) = a + b
}
I want to write a function like above, but i also want to use imlicit. something like:
object DoSomething extends (Configuration, ??? => Dataframe) {
override def apply(config: Configuration)(implicit sparkSession: SparkSession): DataFrame = {
...
}
}
Does anyone know, how I can do this?
Edit:
object DoSomething extends (Configuration => SparkSession) {
override def apply(config: Configuration)(implicit sparkSession: SparkSession): DataFrame = {
val bootstrapServers = configuration.bootstrapServers
val topic = configuration.topic
sparkSession.readStream
.format("kafka")
.option("kafka.bootstrap.servers", bootstrapServers)
.option("subscribe", topic)
.load()
}
}