Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
00e1799
Impl tx action for updata_location, update_properties, and upgrade_fo…
CTTY Jun 10, 2025
c46f288
minor
CTTY Jun 10, 2025
6e56ae1
build
CTTY Jun 10, 2025
37ce5b3
fmt
CTTY Jun 10, 2025
7598bdc
Fix tests
CTTY Jun 10, 2025
f929a2d
fmt
CTTY Jun 10, 2025
ffbfb31
impl default
CTTY Jun 10, 2025
eb71ada
add do_commit
CTTY Jun 10, 2025
7e40279
fmt
CTTY Jun 10, 2025
43fc17a
clippy
CTTY Jun 10, 2025
29e7255
err handling
CTTY Jun 10, 2025
550867a
fmt
CTTY Jun 11, 2025
8236596
fix update table test
CTTY Jun 11, 2025
edfc32e
fix test, mock get request
CTTY Jun 11, 2025
e365cb1
Update crates/iceberg/src/transaction/action.rs
CTTY Jun 11, 2025
3fd17f3
Update crates/iceberg/src/transaction/mod.rs
CTTY Jun 11, 2025
f9a4593
addressing comments
CTTY Jun 12, 2025
1f321f9
Remove unneeded format version check
CTTY Jun 12, 2025
4115efd
Merge branch 'main' into ctty/tx-impl-1
CTTY Jun 12, 2025
cbe28af
Update crates/iceberg/src/transaction/mod.rs
CTTY Jun 12, 2025
6047a06
remove allow dead code in action.rs
CTTY Jun 12, 2025
fc2efa0
fix build
CTTY Jun 12, 2025
a5ae3c6
check overlapping keys in commit
CTTY Jun 12, 2025
cbb52a3
fmt
CTTY Jun 12, 2025
f34e098
allow dead code for as_any
CTTY Jun 12, 2025
bdd54ad
minor
CTTY Jun 12, 2025
25125c3
Update crates/iceberg/src/transaction/update_properties.rs
CTTY Jun 13, 2025
af7ec1c
use ok or else to get format version
CTTY Jun 13, 2025
b093e81
Merge branch 'ctty/tx-impl-1' of github.com:CTTY/iceberg-rust into ct…
CTTY Jun 13, 2025
08e5f4f
use AsAny
CTTY Jun 13, 2025
ce85b64
clippy
CTTY Jun 13, 2025
65a2358
rerun CI
CTTY Jun 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ arrow-ord = { version = "55" }
arrow-schema = { version = "55" }
arrow-select = { version = "55" }
arrow-string = { version = "55" }
as-any = "0.3.2"
async-std = "1.12"
async-trait = "0.1.88"
aws-config = "1.6.1"
Expand Down
40 changes: 35 additions & 5 deletions crates/catalog/rest/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ mod tests {
SnapshotLog, SortDirection, SortField, SortOrder, Summary, Transform, Type,
UnboundPartitionField, UnboundPartitionSpec,
};
use iceberg::transaction::Transaction;
use iceberg::transaction::{ApplyTransactionAction, Transaction};
use mockito::{Mock, Server, ServerGuard};
use serde_json::json;
use uuid::uuid;
Expand Down Expand Up @@ -2093,6 +2093,17 @@ mod tests {

let config_mock = create_config_mock(&mut server).await;

let load_table_mock = server
.mock("GET", "/v1/namespaces/ns1/tables/test1")
.with_status(200)
.with_body_from_file(format!(
"{}/testdata/{}",
env!("CARGO_MANIFEST_DIR"),
"load_table_response.json"
))
.create_async()
.await;

let update_table_mock = server
.mock("POST", "/v1/namespaces/ns1/tables/test1")
.with_status(200)
Expand Down Expand Up @@ -2125,8 +2136,11 @@ mod tests {
.unwrap()
};

let table = Transaction::new(&table1)
.upgrade_table_version(FormatVersion::V2)
let tx = Transaction::new(&table1);
let table = tx
.upgrade_table_version()
.set_format_version(FormatVersion::V2)
.apply(tx)
.unwrap()
.commit(&catalog)
.await
Expand Down Expand Up @@ -2204,6 +2218,7 @@ mod tests {

config_mock.assert_async().await;
update_table_mock.assert_async().await;
load_table_mock.assert_async().await
}

#[tokio::test]
Expand All @@ -2212,6 +2227,17 @@ mod tests {

let config_mock = create_config_mock(&mut server).await;

let load_table_mock = server
.mock("GET", "/v1/namespaces/ns1/tables/test1")
.with_status(200)
.with_body_from_file(format!(
"{}/testdata/{}",
env!("CARGO_MANIFEST_DIR"),
"load_table_response.json"
))
.create_async()
.await;

let update_table_mock = server
.mock("POST", "/v1/namespaces/ns1/tables/test1")
.with_status(404)
Expand Down Expand Up @@ -2250,8 +2276,11 @@ mod tests {
.unwrap()
};

let table_result = Transaction::new(&table1)
.upgrade_table_version(FormatVersion::V2)
let tx = Transaction::new(&table1);
let table_result = tx
.upgrade_table_version()
.set_format_version(FormatVersion::V2)
.apply(tx)
.unwrap()
.commit(&catalog)
.await;
Expand All @@ -2267,5 +2296,6 @@ mod tests {

config_mock.assert_async().await;
update_table_mock.assert_async().await;
load_table_mock.assert_async().await;
}
}
9 changes: 6 additions & 3 deletions crates/catalog/rest/tests/rest_catalog_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::sync::RwLock;

use ctor::{ctor, dtor};
use iceberg::spec::{FormatVersion, NestedField, PrimitiveType, Schema, Type};
use iceberg::transaction::Transaction;
use iceberg::transaction::{ApplyTransactionAction, Transaction};
use iceberg::{Catalog, Namespace, NamespaceIdent, TableCreation, TableIdent};
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig};
use iceberg_test_utils::docker::DockerCompose;
Expand Down Expand Up @@ -346,9 +346,12 @@ async fn test_update_table() {
&TableIdent::new(ns.name().clone(), "t1".to_string())
);

let tx = Transaction::new(&table);
// Update table by committing transaction
let table2 = Transaction::new(&table)
.set_properties(HashMap::from([("prop1".to_string(), "v1".to_string())]))
let table2 = tx
.update_table_properties()
.set("prop1".to_string(), "v1".to_string())
.apply(tx)
.unwrap()
.commit(&catalog)
.await
Expand Down
1 change: 1 addition & 0 deletions crates/iceberg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ arrow-ord = { workspace = true }
arrow-schema = { workspace = true }
arrow-select = { workspace = true }
arrow-string = { workspace = true }
as-any = { workspace = true }
async-std = { workspace = true, optional = true, features = ["attributes"] }
async-trait = { workspace = true }
base64 = { workspace = true }
Expand Down
12 changes: 8 additions & 4 deletions crates/iceberg/src/transaction/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
// specific language governing permissions and limitations
// under the License.

#![allow(dead_code)]
use std::mem::take;
use std::sync::Arc;

use as_any::AsAny;
use async_trait::async_trait;

use crate::table::Table;
use crate::transaction::Transaction;
use crate::{Result, TableRequirement, TableUpdate};

/// A boxed, thread-safe reference to a `TransactionAction`.
pub type BoxedTransactionAction = Arc<dyn TransactionAction>;
pub(crate) type BoxedTransactionAction = Arc<dyn TransactionAction>;

/// A trait representing an atomic action that can be part of a transaction.
///
/// Implementors of this trait define how a specific action is committed to a table.
/// Each action is responsible for generating the updates and requirements needed
/// to modify the table metadata.
#[async_trait]
pub(crate) trait TransactionAction: Sync + Send {
pub(crate) trait TransactionAction: AsAny + Sync + Send {
/// Commits this action against the provided table and returns the resulting updates.
/// NOTE: This function is intended for internal use only and should not be called directly by users.
///
Expand Down Expand Up @@ -108,6 +108,7 @@ mod tests {
use std::str::FromStr;
use std::sync::Arc;

use as_any::Downcast;
use async_trait::async_trait;
use uuid::Uuid;

Expand Down Expand Up @@ -158,9 +159,12 @@ mod tests {
let tx = Transaction::new(&table);

let updated_tx = action.apply(tx).unwrap();

// There should be one action in the transaction now
assert_eq!(updated_tx.actions.len(), 1);

(*updated_tx.actions[0])
.downcast_ref::<TestAction>()
.expect("TestAction was not applied to Transaction!");
}

#[test]
Expand Down
Loading
Loading