Skip to content

Commit 4159c75

Browse files
author
shuxu.li
committed
feat: transactional UpdateProperties method support
1 parent b069251 commit 4159c75

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/iceberg/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ configure_file(
4141
iceberg_include_dir = include_directories('..')
4242
iceberg_sources = files(
4343
'arrow_c_data_guard_internal.cc',
44+
'base_transaction.cc',
4445
'catalog/memory/in_memory_catalog.cc',
4546
'expression/aggregate.cc',
4647
'expression/binder.cc',
@@ -71,6 +72,7 @@ iceberg_sources = files(
7172
'partition_field.cc',
7273
'partition_spec.cc',
7374
'partition_summary.cc',
75+
'pending_update.cc',
7476
'row/arrow_array_wrapper.cc',
7577
'row/manifest_wrapper.cc',
7678
'row/partition_values.cc',

src/iceberg/pending_update.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ PropertiesUpdate& PropertiesUpdate::Remove(std::string const& key) {
3939
}
4040

4141
Result<PropertiesUpdateChanges> PropertiesUpdate::Apply() {
42-
return PropertiesUpdateChanges{updates_, removals_};
42+
return PropertiesUpdateChanges{
43+
.updates = updates_,
44+
.removals = removals_,
45+
};
4346
}
4447

4548
Status PropertiesUpdate::ApplyResult(TableMetadataBuilder& builder,

src/iceberg/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ add_iceberg_test(table_test
7171
SOURCES
7272
json_internal_test.cc
7373
metrics_config_test.cc
74+
base_transaction_test.cc
75+
pending_update_test.cc
7476
schema_json_test.cc
7577
table_test.cc
7678
table_metadata_builder_test.cc

src/iceberg/test/transaction_pending_update_test.cc renamed to src/iceberg/test/base_transaction_test.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
* under the License.
1818
*/
1919

20+
#include "iceberg/base_transaction.h"
21+
2022
#include <gtest/gtest.h>
2123

22-
#include "iceberg/base_transaction.h"
2324
#include "iceberg/partition_spec.h"
2425
#include "iceberg/pending_update.h"
2526
#include "iceberg/sort_order.h"
@@ -68,7 +69,7 @@ std::shared_ptr<Table> CreateTestTable(const TableIdentifier& identifier,
6869
}
6970
} // namespace
7071

71-
TEST(TransactionPendingUpdateTest, CommitSetPropertiesUsesCatalog) {
72+
TEST(BaseTransactionTest, CommitSetPropertiesUsesCatalog) {
7273
auto metadata = CreateBaseMetadata();
7374
const auto identifier = MakeIdentifier();
7475
auto catalog = std::make_shared<NiceMock<MockCatalog>>();
@@ -93,13 +94,13 @@ TEST(TransactionPendingUpdateTest, CommitSetPropertiesUsesCatalog) {
9394
auto it = updated.find("new-key");
9495
EXPECT_NE(it, updated.end());
9596
EXPECT_EQ("new-value", it->second);
96-
return Result<std::unique_ptr<Table>>(std::unique_ptr<Table>());
97+
return {std::unique_ptr<Table>()};
9798
});
9899

99100
EXPECT_THAT(transaction->CommitTransaction(), IsOk());
100101
}
101102

102-
TEST(TransactionPendingUpdateTest, RemovePropertiesSkipsMissingKeys) {
103+
TEST(BaseTransactionTest, RemovePropertiesSkipsMissingKeys) {
103104
auto metadata = CreateBaseMetadata();
104105
const auto identifier = MakeIdentifier();
105106
auto catalog = std::make_shared<NiceMock<MockCatalog>>();
@@ -121,13 +122,13 @@ TEST(TransactionPendingUpdateTest, RemovePropertiesSkipsMissingKeys) {
121122
dynamic_cast<const table::RemoveProperties*>(updates.front().get());
122123
EXPECT_NE(remove_update, nullptr);
123124
EXPECT_THAT(remove_update->removed(), ElementsAre("existing"));
124-
return Result<std::unique_ptr<Table>>(std::unique_ptr<Table>());
125+
return {std::unique_ptr<Table>()};
125126
});
126127

127128
EXPECT_THAT(transaction->CommitTransaction(), IsOk());
128129
}
129130

130-
TEST(TransactionPendingUpdateTest, AggregatesMultiplePendingUpdates) {
131+
TEST(BaseTransactionTest, AggregatesMultiplePendingUpdates) {
131132
auto metadata = CreateBaseMetadata();
132133
const auto identifier = MakeIdentifier();
133134
auto catalog = std::make_shared<NiceMock<MockCatalog>>();
@@ -159,7 +160,7 @@ TEST(TransactionPendingUpdateTest, AggregatesMultiplePendingUpdates) {
159160
EXPECT_NE(remove_update, nullptr);
160161
EXPECT_THAT(remove_update->removed(), ElementsAre("existing"));
161162

162-
return Result<std::unique_ptr<Table>>(std::unique_ptr<Table>());
163+
return {std::unique_ptr<Table>()};
163164
});
164165

165166
EXPECT_THAT(transaction->CommitTransaction(), IsOk());

0 commit comments

Comments
 (0)