Skip to main content
The RowDelta interface provides an API for encoding row-level changes to an Iceberg table, including inserts, updates, and deletes using delete files.

Overview

RowDelta accumulates data and delete file changes, produces a new snapshot of the table, and commits that snapshot as the current. This is the primary interface for implementing UPDATE, DELETE, and MERGE operations at the row level.

Interface

Core Methods

addRows()

Adds a data file of rows to insert.
Parameters:
  • inserts - A data file of rows to insert
Returns: This for method chaining Example:

addDeletes()

Adds a delete file of rows to delete.
Parameters:
  • deletes - A delete file of rows to delete
Returns: This for method chaining Example:

removeRows()

Removes a data file from the table.
Parameters:
  • file - A data file to remove
Returns: This for method chaining Example:

removeDeletes()

Removes a rewritten delete file from the table.
Parameters:
  • deletes - A delete file that can be removed from the table
Returns: This for method chaining Description: Used when rewriting or consolidating delete files.

Validation Methods

validateFromSnapshot()

Sets the snapshot ID used in any reads for this operation.
Parameters:
  • snapshotId - A snapshot ID
Returns: This for method chaining Description: Validations will check changes after this snapshot ID. If not set, all ancestor snapshots through the table’s initial snapshot are validated.

caseSensitive()

Enables or disables case sensitive expression binding.
Parameters:
  • caseSensitive - Whether expression binding should be case sensitive
Returns: This for method chaining

validateDataFilesExist()

Adds data file paths that must not be removed by conflicting commits.
Parameters:
  • referencedFiles - File paths that are referenced by a position delete file
Returns: This for method chaining Description: If any path has been removed by a conflicting commit since the snapshot passed to validateFromSnapshot(), the operation will fail with a ValidationException. By default, this validation checks only rewrite and overwrite commits. To apply validation to delete commits, call validateDeletedFiles().

validateDeletedFiles()

Enables validation that referenced data files have not been removed by a delete operation.
Returns: This for method chaining Description: If a data file has a row deleted using a position delete file, deleting the data file concurrently could be part of a transaction that reads and re-appends a row. This method validates deletes for the transaction case.

conflictDetectionFilter()

Sets a conflict detection filter for validating concurrent changes.
Parameters:
  • conflictDetectionFilter - An expression on rows in the table
Returns: This for method chaining Description: If not called, a true literal will be used as the conflict detection filter.

validateNoConflictingDataFiles()

Enables validation that concurrently added data files do not conflict.
Returns: This for method chaining Description: Required to maintain serializable isolation for update/delete operations. Otherwise, the isolation level will be snapshot isolation. Validation uses the conflict detection filter and applies to operations that happened after the snapshot passed to validateFromSnapshot().

validateNoConflictingDeleteFiles()

Enables validation that concurrently added delete files do not conflict.
Returns: This for method chaining Description: Must be called when the table is queried to produce a row delta for UPDATE and MERGE operations independently of the isolation level. Not required for DELETE operations.

Examples

Basic Row Delete

Update Operation (Delete + Insert)

Merge Operation

Row Delta with Validation

Serializable Update

Position Delete with File References

Rewriting Delete Files

File Rewrite with Row Delta

Equality Delete

Concurrent Modification Protection

Delete with File Existence Validation

Complex Merge with Multiple Deltas

Isolation Levels

Snapshot Isolation (Default)

Serializable Isolation

Delete File Types

Position Deletes

Delete specific rows by file and position:

Equality Deletes

Delete rows matching equality conditions:

See Also