Transaction
CommitProperties and PostCommitHookProperties
deltalake.CommitProperties
dataclass
CommitProperties(custom_metadata: dict[str, Any] | None = None, max_commit_retries: int | None = None, app_transactions: list[Transaction] | None = None)
The commit properties. Controls the behaviour of the commit.
Custom metadata to be stored in the commit. Controls the number of retries for the commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
custom_metadata |
dict[str, Any] | None
|
custom metadata that will be added to the transaction commit. Top level keys must be strings and values must be JSON serializable. Values such as NaN and Infinity are rejected. Reserved commit info keys have stricter requirements: "operationParameters" must be a JSON object; "readVersion" must be an integer greater than or equal to zero, not a float; "userId", "userName", and "userMetadata" must be strings; "isolationLevel" must be one of "Serializable", "WriteSerializable", or "SnapshotIsolation"; "isBlindAppend" must be a boolean. The generated keys "timestamp", "operation", and "engineInfo" cannot be set through custom metadata. Callers may set "clientVersion", and it is preserved when provided. |
None
|
max_commit_retries |
int | None
|
maximum number of times to retry the transaction commit. |
None
|
deltalake.PostCommitHookProperties
dataclass
The post commit hook properties, only required for advanced usecases where you need to control this.
Checkpoints are by default created based on the delta.checkpointInterval config setting. cleanup_expired_logs can be set to override the delta.enableExpiredLogCleanup, otherwise the config setting will be used to decide whether to clean up logs automatically by taking also the delta.logRetentionDuration into account.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
create_checkpoint |
bool
|
to create checkpoints based on checkpoint interval. Defaults to True. |
True
|
cleanup_expired_logs |
Optional[bool]
|
to clean up logs based on interval. Defaults to None. |
None
|
Create write transactions
deltalake.transaction.AddAction
dataclass
AddAction(path: str, size: int, partition_values: Mapping[str, str | None], modification_time: int, data_change: bool, stats: str)
deltalake.transaction.RemoveAction
RemoveAction(path: str, data_change: bool, deletion_timestamp: int, size: int | None = None, partition_values: dict[str, str | None] | None = None)
deltalake.transaction.create_table_with_add_actions
create_table_with_add_actions(table_uri: str, schema: Schema, add_actions: list[AddAction], mode: Literal['error', 'append', 'overwrite', 'ignore'] = 'error', partition_by: list[str] | str | None = None, name: str | None = None, description: str | None = None, configuration: Mapping[str, str | None] | None = None, storage_options: dict[str, str] | None = None, *args: Any, commit_properties: CommitProperties | None = None, post_commithook_properties: PostCommitHookProperties | None = None) -> None
deltalake.DeltaTable.create_write_transaction
create_write_transaction(actions: list[AddAction | RemoveAction], mode: str, schema: DeltaSchema | ArrowSchemaExportable, partition_by: list[str] | str | None = None, partition_filters: FilterType | None = None, *args: Any, commit_properties: CommitProperties | None = None, post_commithook_properties: PostCommitHookProperties | None = None) -> None
Commit file actions to the table as a single transaction.
Files referenced by an AddAction must already exist in the table location.
A RemoveAction marks an existing file as removed and is only allowed with
mode="append"; mode="overwrite" derives its own remove actions from the
partition filters. A path cannot be both added and removed in the same
transaction, and tables with delta.appendOnly=true reject remove actions
that have data_change=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actions |
list[AddAction | RemoveAction]
|
|
required |
mode |
str
|
save mode of the write, |
required |
schema |
Schema | ArrowSchemaExportable
|
schema of the files being added. |
required |
partition_by |
list[str] | str | None
|
partition columns of the table. |
None
|
partition_filters |
FilterType | None
|
partitions to replace when |
None
|
commit_properties |
CommitProperties | None
|
properties of the transaction commit. |
None
|
post_commithook_properties |
PostCommitHookProperties | None
|
properties for the post commit hook. |
None
|