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).

Create a new Iceberg table

await df.writeTo("analytics.events").using("iceberg").create();

Append to an existing table

await df.writeTo("analytics.events").append();

Overwrite a specific partition

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

Parameter Type
df DataFrame
tableName string

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.

Parameter Type
columns string[]

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.

Parameter Type
key string
value string

this


options(opts): this;

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

Set multiple write options.

Parameter Type
opts Record<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.

Parameter Type
condition Column

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.

Parameter Type
columns Column[]

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.

Parameter Type
key string
value string

this


using(provider): this;

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

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

Parameter Type
provider string

this