snowflake.snowpark.DataFrameWriter

class snowflake.snowpark.DataFrameWriter(dataframe: DataFrame)[source]

Bases: object

Provides methods for writing data from a DataFrame to supported output destinations.

To use this object:

  1. Create an instance of a DataFrameWriter by accessing the DataFrame.write property.

  2. (Optional) Specify the save mode by calling mode(), which returns the same DataFrameWriter that is configured to save data using the specified mode. The default mode is “errorifexists”.

  3. Call save_as_table() or copy_into_location() to save the data to the specified destination.

Methods

copy_into_location()

Executes a COPY INTO <location> to unload data from a DataFrame into one or more files in a stage or external stage.

csv(location, *[, partition_by, ...])

Executes internally a COPY INTO <location> to unload data from a DataFrame into one or more CSV files in a stage or external stage.

format(file_format_name)

Specifies the file format type to use for unloading data from the table.

json(location, *[, partition_by, ...])

Executes internally a COPY INTO <location> to unload data from a DataFrame into a JSON file in a stage or external stage.

mode(save_mode)

Set the save mode of this DataFrameWriter.

option(key, value)

Depending on the file_format_type specified, you can include more format specific options.

options([configs])

Sets multiple specified options for this DataFrameWriter.

parquet(location, *[, partition_by, ...])

Executes internally a COPY INTO <location> to unload data from a DataFrame into a PARQUET file in a stage or external stage.

partition_by(expr)

Specifies an expression used to partition the unloaded table rows into separate files.

save(location, *[, partition_by, ...])

Executes internally a COPY INTO <location> to unload data from a DataFrame into a file in a stage or external stage.

saveAsTable(table_name, *[, mode, ...])

Writes the data to the specified table in a Snowflake database.

save_as_table()

Writes the data to the specified table in a Snowflake database.