43class ICEBERG_EXPORT
Transaction :
public std::enable_shared_from_this<Transaction> {
56 std::shared_ptr<TransactionContext> ctx);
59 const std::shared_ptr<Table>&
table()
const;
143 explicit Transaction(std::shared_ptr<TransactionContext> ctx);
145 Status AddUpdate(
const std::shared_ptr<PendingUpdate>& update);
167 bool CanRetry()
const;
173 std::shared_ptr<TransactionContext> ctx_;
175 std::vector<std::shared_ptr<PendingUpdate>> pending_updates_;
178 bool last_update_committed_ =
true;
180 bool committed_ =
false;
194 std::string MetadataFileLocation(std::string_view filename)
const;
197 std::shared_ptr<Table> table;
198 std::unique_ptr<TableMetadataBuilder> metadata_builder;
202 std::optional<std::weak_ptr<Transaction>> transaction;
API for removing old snapshots from a table.
Definition expire_snapshots.h:68
Base class for all kinds of table metadata updates.
Definition pending_update.h:41
Sets the current snapshot directly or by rolling back.
Definition set_snapshot.h:37
API for table changes that produce snapshots.
Definition snapshot_update.h:49
Shared context between Transaction and PendingUpdate instances.
Definition transaction.h:184
A transaction for performing multiple updates to a table.
Definition transaction.h:43
Result< std::shared_ptr< UpdateSnapshotReference > > NewUpdateSnapshotReference()
Create a new UpdateSnapshotReference to update snapshot references (branches and tags) and commit the...
const TableMetadata * base() const
Returns the base metadata without any changes.
Result< std::shared_ptr< UpdateSortOrder > > NewUpdateSortOrder()
Create a new UpdateSortOrder to update the table sort order and commit the changes.
const TableMetadata & current() const
Return the current metadata with staged changes applied.
Result< std::shared_ptr< UpdatePartitionStatistics > > NewUpdatePartitionStatistics()
Create a new UpdatePartitionStatistics to update partition statistics and commit the changes.
static Result< std::shared_ptr< Transaction > > Make(std::shared_ptr< Table > table, TransactionKind kind)
Create a new transaction.
const std::shared_ptr< Table > & table() const
Return the Table that this transaction will update.
Result< std::shared_ptr< DeleteFiles > > NewDeleteFiles()
Create a new DeleteFiles to delete data files and commit the changes.
Result< std::shared_ptr< FastAppend > > NewFastAppend()
Create a new FastAppend to append data files and commit the changes.
Result< std::shared_ptr< SetSnapshot > > NewSetSnapshot()
Create a new SetSnapshot to set the current snapshot or rollback to a previous snapshot and commit th...
Result< std::shared_ptr< UpdateLocation > > NewUpdateLocation()
Create a new UpdateLocation to update the table location and commit the changes.
Result< std::shared_ptr< SnapshotManager > > NewSnapshotManager()
Create a new SnapshotManager to manage snapshots.
Result< std::shared_ptr< ExpireSnapshots > > NewExpireSnapshots()
Create a new ExpireSnapshots to remove expired snapshots and commit the changes.
std::string MetadataFileLocation(std::string_view filename) const
Return the location of the metadata file with the given filename.
Result< std::shared_ptr< Table > > Commit()
Apply the pending changes from all actions and commit.
Result< std::shared_ptr< UpdatePartitionSpec > > NewUpdatePartitionSpec()
Create a new UpdatePartitionSpec to update the partition spec of this table and commit the changes.
Result< std::shared_ptr< RowDelta > > NewRowDelta()
Create a new RowDelta to add rows and row-level deletes.
Result< std::shared_ptr< UpdateStatistics > > NewUpdateStatistics()
Create a new UpdateStatistics to update table statistics and commit the changes.
static Result< std::shared_ptr< Transaction > > Make(std::shared_ptr< TransactionContext > ctx)
Create a detached transaction from an existing context.
Result< std::shared_ptr< UpdateSchema > > NewUpdateSchema()
Create a new UpdateSchema to alter the columns of this table and commit the changes.
Result< std::shared_ptr< MergeAppend > > NewMergeAppend()
Create a new MergeAppend to append data files and merge manifests.
Result< std::shared_ptr< UpdateProperties > > NewUpdateProperties()
Create a new UpdateProperties to update table properties and commit the changes.
Result< std::shared_ptr< RewriteFiles > > NewRewriteFiles()
Create a new RewriteFiles to replace files in this table and commit the changes.
Result< std::shared_ptr< OverwriteFiles > > NewOverwrite()
Create a new OverwriteFiles to overwrite data files and commit the changes.
Updating table location with a new base location.
Definition update_location.h:34
API for partition spec evolution.
Definition update_partition_spec.h:44
Updates table partition statistics.
Definition update_partition_statistics.h:39
Updates table properties.
Definition update_properties.h:39
API for schema evolution.
Definition update_schema.h:45
Updates snapshot references.
Definition update_snapshot_reference.h:39
Updating table sort order with a newly created order.
Definition update_sort_order.h:37
Updates table statistics.
Definition update_statistics.h:39
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
TransactionKind
Whether a transaction creates a new table or updates an existing one.
Definition transaction.h:40
std::expected< T, E > Result
Result alias.
Definition result.h:88
Define Result, Status, and error helpers.