Skip to content

Commit 6c25387

Browse files
authored
docs: add Transaction example (#1436)
## Which issue does this PR close? N/A, although I can link this to the Write support epic is that is useful? ## What changes are included in this PR? Adding additional documentation to the `transaction` module to provide a basic example of the `FastAppendAction` usage. Other actions are not included at this time. <details> <summary> it looks like this </summary> ![image](https://github.com/user-attachments/assets/8f357408-e26a-4216-81b9-4594adf8f7ad) </details> ## Are these changes tested? N/A
1 parent 2d4407d commit 6c25387

File tree

1 file changed

+31
-0
lines changed
  • crates/iceberg/src/transaction

1 file changed

+31
-0
lines changed

crates/iceberg/src/transaction/mod.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,37 @@
1616
// under the License.
1717

1818
//! This module contains transaction api.
19+
//!
20+
//! The transaction API enables changes to be made to an existing table.
21+
//!
22+
//! Note that this may also have side effects, such as producing new manifest
23+
//! files.
24+
//!
25+
//! Below is a basic example using the "fast-append" action:
26+
//!
27+
//! ```ignore
28+
//! use iceberg::transaction::{ApplyTransactionAction, Transaction};
29+
//! use iceberg::Catalog;
30+
//!
31+
//! // Create a transaction.
32+
//! let tx = Transaction::new(my_table);
33+
//!
34+
//! // Create a `FastAppendAction` which will not rewrite or append
35+
//! // to existing metadata. This will create a new manifest.
36+
//! let action = tx.fast_append().add_data_files(my_data_files);
37+
//!
38+
//! // Apply the fast-append action to the given transaction, returning
39+
//! // the newly updated `Transaction`.
40+
//! let tx = action.apply(tx).unwrap();
41+
//!
42+
//!
43+
//! // End the transaction by committing to an `iceberg::Catalog`
44+
//! // implementation. This will cause a table update to occur.
45+
//! let table = tx
46+
//! .commit(&some_catalog_impl)
47+
//! .await
48+
//! .unwrap();
49+
//! ```
1950
2051
/// The `ApplyTransactionAction` trait provides an `apply` method
2152
/// that allows users to apply a transaction action to a `Transaction`.

0 commit comments

Comments
 (0)