问题
I have queried Cassandra using spark in Scala. Below is the result:
Is there any way to write this result back to Cassandra tables ?
回答1:
df.write
.format("org.apache.spark.sql.cassandra")
.options(Map( "table" -> "t_payu_df", "keyspace" -> "ks_payu"))
.save()
This will work.
You can also specify SaveMode (overwrite,append,ErrorIfExists).
Example with SaveMode:
df.write
.format("org.apache.spark.sql.cassandra")
.mode(SaveMode.Overwrite)
.options(Map( "table" -> "t_payu_df", "keyspace" -> "ks_payu"))
.save()
For more details visit Dataframe
来源:https://stackoverflow.com/questions/42994053/is-there-any-way-to-load-spark-sql-resultset-data-frames-back-to-cassandra