title: Cassandra Sink for PySpark Structured Streaming from Kafka topic
body: <p>I want to write Structure Streaming Data into Cassandra using PySpark Structured Streaming API.</p>
  
  <p>My data flow is like below:</p>
  
  <p>REST API -> Kafka -> Spark Structured Streaming (PySpark) -> Cassandra</p>
  
  <p>Source and Version in below:
  Spark version: 2.4.3
  DataStax DSE: 6.7.6-1</p>
  
  <p>initialize spark:</p>
  
  <pre><code>spark = SparkSession.builder\
  .master("local[*]")\
  .appName("Analytics")\
  .config("kafka.bootstrap.servers", "localhost:9092")\
  .config("spark.cassandra.connection.host","localhost:9042")\
  .getOrCreate()
  </code></pre>
  
  <p>subscribe topic from Kafka:</p>
  
  <pre><code>df = spark.readStream.format("kafka")\
      .option("kafka.bootstrap.servers", "localhost:9092")\
      .option("subscribe", "topic") \
      .load()
  </code></pre>
  
  <p>Write into Cassandra:</p>
  
  <pre><code>    w_df_3 = df...
  
      write_db = w_df_3.writeStream \
      .option("checkpointLocation", '/tmp/check_point/') \
      .format("org.apache.spark.sql.cassandra") \
      .option("keyspace", "analytics") \
      .option("table", "table") \
      .outputMode(outputMode="update")\
      .start()
  </code></pre>
  
  <p>executed with the following command:</p>
  
  <pre><code>$spark-submit --packages org.apache.spark:spark-sql-kafka-0-10_2.11:2.4.0,datastax:spark-cassandra-connector:2.4.0-s_2.11 Analytics.py localhost:9092 topic
  </code></pre>
  
  <p>I am facing below issue/exception while writestream into Cassandra:</p>
  
  <pre><code>py4j.protocol.Py4JJavaError: An error occurred while calling o81.start.
  : java.lang.UnsupportedOperationException: Data source org.apache.spark.sql.cassandra does not support streamed writing
      at org.apache.spark.sql.execution.datasources.DataSource.createSink(DataSource.scala:297)
      at org.apache.spark.sql.streaming.DataStreamWriter.start(DataStreamWriter.scala:322)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
      at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
      at py4j.Gateway.invoke(Gateway.java:282)
      at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
      at py4j.commands.CallCommand.execute(CallCommand.java:79)
      at py4j.GatewayConnection.run(GatewayConnection.java:238)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>
  
  <p>Could anyone help me out on how to resolve and proceed further? Any help will be appreciated.</p>
  
  <p>Thanks in advance.</p>