You can use the code below to read in the message flow from Kafka, extract the JSON values ββand convert them to a DataFrame:
val messages = KafkaUtils.createDirectStream[String, String, StringDecoder, StringDecoder](ssc, kafkaParams, topicsSet) messages.foreachRDD { rdd => //extracting the values only val df = sqlContext.read.json(rdd.map(x => x._2)) df.show() }
radek1st
source share