pyspark.sql.DataFrame.writeTo#
- DataFrame.writeTo(table)[source]#
- Create a write configuration builder for v2 sources. - This builder is used to configure and execute write operations. - For example, to append or create or replace existing tables. - New in version 3.1.0. - Changed in version 3.4.0: Supports Spark Connect. - Parameters
- tablestr
- Target table name to write to. 
 
- Returns
- DataFrameWriterV2
- DataFrameWriterV2 to use further to specify how to save the data 
 
 - Examples - >>> df = spark.createDataFrame( ... [(14, "Tom"), (23, "Alice"), (16, "Bob")], ["age", "name"]) >>> df.writeTo("catalog.db.table").append() >>> df.writeTo( ... "catalog.db.table" ... ).partitionedBy("col").createOrReplace()