Struct TableTransaction

Source
pub struct TableTransaction<'table> { /* private fields */ }
Expand description

A transaction that can perform multiple operations on a table atomically

TableTransaction allows grouping multiple table operations (like schema updates, appends, overwrites) into a single atomic transaction. The transaction must be committed for changes to take effect.

§Type Parameters

  • 'table - Lifetime of the reference to the table being modified

§Examples

let mut table = // ... get table reference
table.new_transaction(None)
    .add_schema(new_schema)
    .append(data_files)
    .commit()
    .await?;

Implementations§

Source§

impl<'table> TableTransaction<'table>

Source

pub fn add_schema(self, schema: Schema) -> Self

Adds a new schema to the table

This operation adds a new schema version to the table. The schema ID will be automatically assigned when the transaction is committed.

§Arguments
  • schema - The new schema to add to the table
§Returns
  • Self - The transaction builder for method chaining
Source

pub fn set_default_spec(self, spec_id: i32) -> Self

Sets the default partition specification ID for the table

§Arguments
  • spec_id - The ID of the partition specification to set as default
§Returns
  • Self - The transaction builder for method chaining

The specified partition specification must already exist in the table metadata.

Source

pub fn append_data(self, files: Vec<DataFile>) -> Self

Appends new data files to the table

This operation adds new data files to the table’s current snapshot. Multiple append operations in the same transaction will be combined.

§Arguments
  • files - Vector of data files to append to the table
§Returns
  • Self - The transaction builder for method chaining
§Examples
let transaction = table.new_transaction(None)
    .append_data(data_files)
    .commit()
    .await?;
Source

pub fn append_delete(self, files: Vec<DataFile>) -> Self

Appends delete files to the table

This operation adds files that mark records for deletion in the table’s current snapshot. Multiple delete operations in the same transaction will be combined. The delete files specify which records should be removed when reading the table.

§Arguments
  • files - Vector of delete files to append to the table
§Returns
  • Self - The transaction builder for method chaining
§Examples
let transaction = table.new_transaction(None)
    .append_delete(delete_files)
    .commit()
    .await?;
Source

pub fn replace(self, files: Vec<DataFile>) -> Self

Replaces all data files in the table with new ones

This operation removes all existing data files and replaces them with the provided files. Multiple replace operations in the same transaction will be combined.

§Arguments
  • files - Vector of data files that will replace the existing ones
§Returns
  • Self - The transaction builder for method chaining
§Examples
let transaction = table.new_transaction(None)
    .replace(new_files)
    .commit()
    .await?;
Source

pub fn replace_with_lineage( self, files: Vec<DataFile>, additional_summary: HashMap<String, String>, ) -> Self

Quickly append files to the table

Source

pub fn update_properties(self, entries: Vec<(String, String)>) -> Self

Updates the table properties with new key-value pairs

This operation adds or updates table properties. Multiple update operations in the same transaction will be combined.

§Arguments
  • entries - Vector of (key, value) pairs to update in the table properties
§Returns
  • Self - The transaction builder for method chaining
§Examples
let transaction = table.new_transaction(None)
    .update_properties(vec![
        ("write.format.default".to_string(), "parquet".to_string()),
        ("write.metadata.compression-codec".to_string(), "gzip".to_string())
    ])
    .commit()
    .await?;
Source

pub fn set_snapshot_ref(self, entry: (String, SnapshotReference)) -> Self

Sets a snapshot reference for the table

This operation creates or updates a named reference to a specific snapshot, allowing for features like branches and tags.

§Arguments
  • entry - Tuple of (reference name, snapshot reference) defining the reference
§Returns
  • Self - The transaction builder for method chaining
§Examples
let transaction = table.new_transaction(None)
    .set_snapshot_ref((
        "test-branch".to_string(),
        SnapshotReference {
            snapshot_id: 123,
            retention: SnapshotRetention::default(),
        }
    ))
    .commit()
    .await?;
Source

pub async fn commit(self) -> Result<(), Error>

Commits all operations in this transaction atomically

This method executes all operations in the transaction and updates the table metadata. The changes are atomic - either all operations succeed or none do. After commit, the transaction is consumed and the table is updated with the new metadata.

§Returns
  • Result<(), Error> - Ok(()) if the commit succeeds, Error if it fails
§Errors

Returns an error if:

  • Any operation fails to execute
  • The catalog update fails
  • Cleanup of old data files fails (for replace operations)
§Examples
let result = table.new_transaction(None)
    .append(data_files)
    .update_properties(properties)
    .commit()
    .await?;

Auto Trait Implementations§

§

impl<'table> Freeze for TableTransaction<'table>

§

impl<'table> !RefUnwindSafe for TableTransaction<'table>

§

impl<'table> Send for TableTransaction<'table>

§

impl<'table> Sync for TableTransaction<'table>

§

impl<'table> Unpin for TableTransaction<'table>

§

impl<'table> !UnwindSafe for TableTransaction<'table>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,