Skip to content

Commit aa4cadb

Browse files
author
shuxu.li
committed
feat: transactional UpdateProperties method support
1 parent c7d2459 commit aa4cadb

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
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/binder.cc',
4647
'expression/evaluator.cc',
@@ -65,6 +66,7 @@ iceberg_sources = files(
6566
'partition_field.cc',
6667
'partition_spec.cc',
6768
'partition_summary.cc',
69+
'pending_update.cc',
6870
'row/arrow_array_wrapper.cc',
6971
'row/manifest_wrapper.cc',
7072
'row/struct_like.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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ add_iceberg_test(schema_test
8080
add_iceberg_test(table_test
8181
SOURCES
8282
json_internal_test.cc
83+
base_transaction_test.cc
8384
pending_update_test.cc
8485
schema_json_test.cc
8586
table_test.cc
8687
table_metadata_builder_test.cc
8788
table_requirement_test.cc
8889
table_update_test.cc
89-
test_common.cc
90-
transaction_pending_update_test.cc)
90+
test_common.cc)
9191

9292
add_iceberg_test(expression_test
9393
SOURCES

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)