Skip to content

DataFrameWriterV2

Defined in: data-frame-writer-v2.ts:30

Writes a DataFrame to a catalog table using the DataSource V2 API.

Obtained via df.writeTo(tableName). Unlike the path-oriented DataFrameWriter, V2 is catalog-aware and supports atomic table operations (create, replace, createOrReplace) and partition-level writes (append, overwrite, overwritePartitions).

await df.writeTo("analytics.events").using("iceberg").create();
await df.writeTo("analytics.events").append();
await df.writeTo("analytics.events").overwrite(col("day").eq(lit("2026-04-21")));

Spark source: DataFrameWriterV2.scala

new DataFrameWriterV2(df, tableName): DataFrameWriterV2;

Defined in: data-frame-writer-v2.ts:39

ParameterType
dfDataFrame
tableNamestring

DataFrameWriterV2

append(): Promise<void>;

Defined in: data-frame-writer-v2.ts:125

Append the DataFrame’s data to the table.

Promise<void>


clusterBy(...columns): this;

Defined in: data-frame-writer-v2.ts:81

Cluster the output table by the given column names. Applies to create, replace, and createOrReplace.

ParameterType
columnsstring[]

this


create(): Promise<void>;

Defined in: data-frame-writer-v2.ts:101

Create a new table with the DataFrame’s data and schema.

Promise<void>


createOrReplace(): Promise<void>;

Defined in: data-frame-writer-v2.ts:117

Create a table or replace it if it already exists.

Promise<void>


option(key, value): this;

Defined in: data-frame-writer-v2.ts:51

Set a single write option.

ParameterType
keystring
valuestring

this


options(opts): this;

Defined in: data-frame-writer-v2.ts:57

Set multiple write options.

ParameterType
optsRecord<string, string>

this


overwrite(condition): Promise<void>;

Defined in: data-frame-writer-v2.ts:136

Overwrite rows matching the given condition. Rows in the table that match the condition are replaced; others are kept.

ParameterType
conditionColumn

Promise<void>


overwritePartitions(): Promise<void>;

Defined in: data-frame-writer-v2.ts:148

Dynamically overwrite partitions: replaces only the partitions present in the DataFrame, leaving other partitions untouched.

Promise<void>


partitionedBy(...columns): this;

Defined in: data-frame-writer-v2.ts:72

Partition the output table by the given Column expressions. Applies to create, replace, and createOrReplace.

ParameterType
columnsColumn[]

this


replace(): Promise<void>;

Defined in: data-frame-writer-v2.ts:109

Replace an existing table with the DataFrame’s data and schema.

Promise<void>


tableProperty(key, value): this;

Defined in: data-frame-writer-v2.ts:63

Set a single table property.

ParameterType
keystring
valuestring

this


using(provider): this;

Defined in: data-frame-writer-v2.ts:45

Specify the data source provider (e.g. “iceberg”, “delta”, “parquet”).

ParameterType
providerstring

this