Created
November 8, 2018 11:18
-
-
Save andr83/6d873d03c201f8f4a635f097d3798606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val stream = KafkaUtils.createDirectStream[String, String, StringDecoder, StringDecoder](job.ssc, kafkaParams, topics) | |
stream.foreachRDD(rdd => | |
import sparkSession.implicits._ | |
val offsetRanges = rdd.asInstanceOf[HasOffsetRanges].offsetRanges | |
val df = rdd.toDF() | |
df.write.format("sequence").mode("append").save(s"$workDir/$targetFile") | |
stream.asInstanceOf[CanCommitOffsets].commitAsync(offsetRanges) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment