pyspark.sql.DataFrameWriter.mode

DataFrameWriter.mode(saveMode: Optional[str]) → pyspark.sql.readwriter.DataFrameWriter[source]

Specifies the behavior when data or table already exists.

Options include:

  • append: Append contents of this DataFrame to existing data.

  • overwrite: Overwrite existing data.

  • error or errorifexists: Throw an exception if data already exists.

  • ignore: Silently ignore this operation if data already exists.

New in version 1.4.0.

Examples

>>> df.write.mode('append').parquet(os.path.join(tempfile.mkdtemp(), 'data'))