This post gives Sample Code - Spark Structured Streaming vs Spark Streaming . Major differences between Spark Structured Streaming vs Spark Streaming are -
val lines \= spark.readStream
.format("socket")
.option("host","localhost")
.option("port",9999)
.load()
val data \= lines.as(String).flatMap(\_split(" "))
val countOfWords \= data.groupby("value").count()
counOfWords.writeStream
.format("console")
.option("truncate","false")
.start()
.awaitTermination()
val streamContext \= new StreamingContext(conf,Seconds(1))
val data \= ssc.socketTextStream("localhost", 9999)
val wordCounts \= data.map(\_.value) // split the message into lines
.flatMap(\_.split(" ")) //split into words
.filter(w \=> w.length() \> 0) // remove empty words
.map(w \=> (w, 1L)).reduceByKey(\_ + \_) // count by word
wordCounts.print()
streamContext.start()
https://spark.apache.org/docs/latest/streaming-programming-guide.html Additional Read - Sample Code for PySpark Cassandra Application Sample Code for Spark Cassandra Scala Application