Skip to content

Commit 80e32ed

Browse files
committed
1
1 parent 8a59220 commit 80e32ed

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/iceberg/test/transaction_test.cc

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919

2020
#include "iceberg/transaction.h"
2121

22+
#include "iceberg/expression/term.h"
2223
#include "iceberg/test/matchers.h"
2324
#include "iceberg/test/update_test_base.h"
25+
#include "iceberg/transform.h"
2426
#include "iceberg/update/update_properties.h"
27+
#include "iceberg/update/update_sort_order.h"
2528

2629
namespace iceberg {
2730

@@ -57,24 +60,35 @@ TEST_F(TransactionTest, CommitTransactionWithPropertyUpdate) {
5760
TEST_F(TransactionTest, MultipleUpdatesInTransaction) {
5861
ICEBERG_UNWRAP_OR_FAIL(auto txn, table_->NewTransaction());
5962

60-
// First update
63+
// First update: set property
6164
ICEBERG_UNWRAP_OR_FAIL(auto update1, txn->NewUpdateProperties());
62-
update1->Set("key1", "value1");
65+
update1->Set("key1", "value1").Set("key2", "value2");
6366
EXPECT_THAT(update1->Commit(), IsOk());
6467

65-
// Second update
66-
ICEBERG_UNWRAP_OR_FAIL(auto update2, txn->NewUpdateProperties());
67-
update2->Set("key2", "value2");
68+
// Second update: update sort order
69+
ICEBERG_UNWRAP_OR_FAIL(auto update2, txn->NewUpdateSortOrder());
70+
auto ref = NamedReference::Make("x").value();
71+
auto term = UnboundTransform::Make(std::move(ref), Transform::Identity()).value();
72+
update2->AddSortField(std::move(term), SortDirection::kAscending, NullOrder::kFirst);
6873
EXPECT_THAT(update2->Commit(), IsOk());
6974

7075
// Commit transaction
7176
ICEBERG_UNWRAP_OR_FAIL(auto updated_table, txn->Commit());
7277

73-
// Verify both properties were set
78+
// Verify properties were set
7479
ICEBERG_UNWRAP_OR_FAIL(auto reloaded, catalog_->LoadTable(table_ident_));
7580
const auto& props = reloaded->properties().configs();
7681
EXPECT_EQ(props.at("key1"), "value1");
7782
EXPECT_EQ(props.at("key2"), "value2");
83+
84+
// Verify sort order was updated
85+
ICEBERG_UNWRAP_OR_FAIL(auto sort_order, reloaded->sort_order());
86+
EXPECT_FALSE(sort_order->is_unsorted());
87+
const auto& fields = sort_order->fields();
88+
ASSERT_EQ(fields.size(), 1);
89+
EXPECT_EQ(fields[0].source_id(), 1); // field id for "x"
90+
EXPECT_EQ(fields[0].direction(), SortDirection::kAscending);
91+
EXPECT_EQ(fields[0].null_order(), NullOrder::kFirst);
7892
}
7993

8094
} // namespace iceberg

0 commit comments

Comments
 (0)