Skip to content

Commit 433a900

Browse files
committed
docs: expand transaction mod with example
1 parent 44cd718 commit 433a900

File tree

1 file changed

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

1 file changed

+34
-0
lines changed

crates/iceberg/src/transaction/mod.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,40 @@
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+
//! ```
28+
//! // Create a transaction.
29+
//! let tx = Transaction::new(my_table);
30+
//!
31+
//! // Create a `FastAppendAction` which will not rewrite or append
32+
//! // to existing metadata. This will create a new manifest.
33+
//! let mut action = tx
34+
//! .fast_append(None, Vec::new())
35+
//! .expect("a transaction can be validated with this input");
36+
//!
37+
//! action
38+
//! .add_data_files(my_data_files)
39+
//! .unwrap();
40+
//!
41+
//! let tx = action
42+
//! .apply()
43+
//! .await
44+
//! .unwrap();
45+
//!
46+
//! // End the transaction by committing to an `iceberg::Catalog`
47+
//! // implementation. This will cause a table update to occur.
48+
//! let table = tx
49+
//! .commit(some_catalog_impl)
50+
//! .await
51+
//! .unwrap();
52+
//! ```
1953
2054
mod action;
2155
mod append;

0 commit comments

Comments
 (0)