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).
Examples
Section titled “Examples”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
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DataFrameWriterV2(df, tableName): DataFrameWriterV2;Defined in: data-frame-writer-v2.ts:39
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
df | DataFrame |
tableName | string |
Returns
Section titled “Returns”DataFrameWriterV2
Methods
Section titled “Methods”append()
Section titled “append()”append(): Promise<void>;Defined in: data-frame-writer-v2.ts:125
Append the DataFrame’s data to the table.
Returns
Section titled “Returns”Promise<void>
clusterBy()
Section titled “clusterBy()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…columns | string[] |
Returns
Section titled “Returns”this
create()
Section titled “create()”create(): Promise<void>;Defined in: data-frame-writer-v2.ts:101
Create a new table with the DataFrame’s data and schema.
Returns
Section titled “Returns”Promise<void>
createOrReplace()
Section titled “createOrReplace()”createOrReplace(): Promise<void>;Defined in: data-frame-writer-v2.ts:117
Create a table or replace it if it already exists.
Returns
Section titled “Returns”Promise<void>
option()
Section titled “option()”option(key, value): this;Defined in: data-frame-writer-v2.ts:51
Set a single write option.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key | string |
value | string |
Returns
Section titled “Returns”this
options()
Section titled “options()”options(opts): this;Defined in: data-frame-writer-v2.ts:57
Set multiple write options.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts | Record<string, string> |
Returns
Section titled “Returns”this
overwrite()
Section titled “overwrite()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
condition | Column |
Returns
Section titled “Returns”Promise<void>
overwritePartitions()
Section titled “overwritePartitions()”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.
Returns
Section titled “Returns”Promise<void>
partitionedBy()
Section titled “partitionedBy()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…columns | Column[] |
Returns
Section titled “Returns”this
replace()
Section titled “replace()”replace(): Promise<void>;Defined in: data-frame-writer-v2.ts:109
Replace an existing table with the DataFrame’s data and schema.
Returns
Section titled “Returns”Promise<void>
tableProperty()
Section titled “tableProperty()”tableProperty(key, value): this;Defined in: data-frame-writer-v2.ts:63
Set a single table property.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key | string |
value | string |
Returns
Section titled “Returns”this
using()
Section titled “using()”using(provider): this;Defined in: data-frame-writer-v2.ts:45
Specify the data source provider (e.g. “iceberg”, “delta”, “parquet”).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
provider | string |
Returns
Section titled “Returns”this