PySpark - Creating a new table from a Dataframe

25 views
Skip to first unread message

Vinit

unread,
Jun 3, 2022, 11:01:15 AM6/3/22
to DataStax Spark Connector for Apache Cassandra
Hi,

In the python docs I'm seeing ways to save a dataframe to an existing table, but I'd like to insert the dataframe values to a new one. Below is the snippet found in the doc for saving to an existing table.

df.write\ 
 .format("org.apache.spark.sql.cassandra")\
 .mode('append')\ # Is there an option for a new table?
 .options(table="kv", keyspace="test")\
 .save()

How might I do something similar to the above snippet but to create a new table from the Dataframe `df`?
Reply all
Reply to author
Forward
0 new messages