pub struct Transaction { /* private fields */ }Expand description
A transaction represents a unit of work against a table.
Transactions track:
- The base state (snapshot) at transaction start
- Files to be added
- Files to be deleted
- Schema changes (if any)
At commit time, the transaction validates that no conflicting changes have been made and atomically updates the table metadata.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new(metadata: TableMetadata) -> Self
pub fn new(metadata: TableMetadata) -> Self
Creates a new transaction based on the current table state.
Sourcepub fn with_operation(self, operation: Operation) -> Self
pub fn with_operation(self, operation: Operation) -> Self
Sets the operation type.
Sourcepub fn with_isolation_level(self, level: IsolationLevel) -> Self
pub fn with_isolation_level(self, level: IsolationLevel) -> Self
Sets the isolation level.
Sourcepub fn with_retry_config(self, config: RetryConfig) -> Self
pub fn with_retry_config(self, config: RetryConfig) -> Self
Sets the retry configuration.
Sourcepub fn add_files(&mut self, files: impl IntoIterator<Item = DataFile>)
pub fn add_files(&mut self, files: impl IntoIterator<Item = DataFile>)
Adds data files to be committed.
Sourcepub fn delete_files(&mut self, paths: impl IntoIterator<Item = String>)
pub fn delete_files(&mut self, paths: impl IntoIterator<Item = String>)
Marks files for deletion.
Sourcepub fn delete_file(&mut self, path: impl Into<String>)
pub fn delete_file(&mut self, path: impl Into<String>)
Marks a single file for deletion.
Sourcepub fn set_schema(&mut self, schema: Schema)
pub fn set_schema(&mut self, schema: Schema)
Sets a new schema to be applied.
Sourcepub fn with_summary_property(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_summary_property( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a custom summary property.
Sourcepub fn has_changes(&self) -> bool
pub fn has_changes(&self) -> bool
Returns true if this transaction has changes to commit.
Sourcepub fn added_files_count(&self) -> usize
pub fn added_files_count(&self) -> usize
Returns the number of files to be added.
Sourcepub fn deleted_files_count(&self) -> usize
pub fn deleted_files_count(&self) -> usize
Returns the number of files to be deleted.
Sourcepub fn added_records_count(&self) -> i64
pub fn added_records_count(&self) -> i64
Returns the total records to be added.
Sourcepub async fn commit(
self,
catalog: Arc<dyn Catalog>,
) -> TransactionResult<Snapshot>
pub async fn commit( self, catalog: Arc<dyn Catalog>, ) -> TransactionResult<Snapshot>
Commits the transaction to the catalog.
Sourcepub fn prepare_commit(&self) -> TransactionResult<PreparedCommit>
pub fn prepare_commit(&self) -> TransactionResult<PreparedCommit>
Prepares the transaction for commit.
This method:
- Validates the transaction
- Builds manifest files for new data
- Creates the new snapshot
- Returns the updated metadata ready for atomic commit
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more