pyspark.sql.DataFrameWriter.mode

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

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.

Examples

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