Skip to content

Commit ed051a7

Browse files
manuzhangcodex
andauthored
feat: add row delta update (#721)
Implements the RowDelta update builder, table and transaction factory methods, and focused tests for row-level add/delete flows. --------- Co-authored-by: Codex <codex@openai.com>
1 parent f6f9951 commit ed051a7

14 files changed

Lines changed: 830 additions & 6 deletions

src/iceberg/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ set(ICEBERG_SOURCES
106106
update/merge_append.cc
107107
update/merging_snapshot_update.cc
108108
update/pending_update.cc
109+
update/row_delta.cc
109110
update/set_snapshot.cc
110111
update/snapshot_manager.cc
111112
update/snapshot_update.cc

src/iceberg/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ iceberg_sources = files(
131131
'update/merge_append.cc',
132132
'update/merging_snapshot_update.cc',
133133
'update/pending_update.cc',
134+
'update/row_delta.cc',
134135
'update/set_snapshot.cc',
135136
'update/snapshot_manager.cc',
136137
'update/snapshot_update.cc',

src/iceberg/table.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "iceberg/update/expire_snapshots.h"
3636
#include "iceberg/update/fast_append.h"
3737
#include "iceberg/update/merge_append.h"
38+
#include "iceberg/update/row_delta.h"
3839
#include "iceberg/update/set_snapshot.h"
3940
#include "iceberg/update/snapshot_manager.h"
4041
#include "iceberg/update/update_location.h"
@@ -231,6 +232,12 @@ Result<std::shared_ptr<DeleteFiles>> Table::NewDeleteFiles() {
231232
return DeleteFiles::Make(name().name, std::move(ctx));
232233
}
233234

235+
Result<std::shared_ptr<RowDelta>> Table::NewRowDelta() {
236+
ICEBERG_ASSIGN_OR_RAISE(
237+
auto ctx, TransactionContext::Make(shared_from_this(), TransactionKind::kUpdate));
238+
return RowDelta::Make(name().name, std::move(ctx));
239+
}
240+
234241
Result<std::shared_ptr<UpdateStatistics>> Table::NewUpdateStatistics() {
235242
ICEBERG_ASSIGN_OR_RAISE(
236243
auto ctx, TransactionContext::Make(shared_from_this(), TransactionKind::kUpdate));
@@ -334,6 +341,14 @@ Result<std::shared_ptr<MergeAppend>> StaticTable::NewMergeAppend() {
334341
return NotSupported("Cannot create a merge append for a static table");
335342
}
336343

344+
Result<std::shared_ptr<DeleteFiles>> StaticTable::NewDeleteFiles() {
345+
return NotSupported("Cannot create delete files for a static table");
346+
}
347+
348+
Result<std::shared_ptr<RowDelta>> StaticTable::NewRowDelta() {
349+
return NotSupported("Cannot create a row delta for a static table");
350+
}
351+
337352
Result<std::shared_ptr<SnapshotManager>> StaticTable::NewSnapshotManager() {
338353
return NotSupported("Cannot create a snapshot manager for a static table");
339354
}

src/iceberg/table.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ class ICEBERG_EXPORT Table : public std::enable_shared_from_this<Table> {
182182
/// \brief Create a new DeleteFiles to delete data files and commit the changes.
183183
virtual Result<std::shared_ptr<DeleteFiles>> NewDeleteFiles();
184184

185+
/// \brief Create a new RowDelta to add rows and row-level deletes.
186+
virtual Result<std::shared_ptr<RowDelta>> NewRowDelta();
187+
185188
/// \brief Create a new SnapshotManager to manage snapshots and snapshot references.
186189
virtual Result<std::shared_ptr<SnapshotManager>> NewSnapshotManager();
187190

@@ -251,6 +254,10 @@ class ICEBERG_EXPORT StaticTable : public Table {
251254

252255
Result<std::shared_ptr<MergeAppend>> NewMergeAppend() override;
253256

257+
Result<std::shared_ptr<DeleteFiles>> NewDeleteFiles() override;
258+
259+
Result<std::shared_ptr<RowDelta>> NewRowDelta() override;
260+
254261
Result<std::shared_ptr<SnapshotManager>> NewSnapshotManager() override;
255262

256263
private:

src/iceberg/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ if(ICEBERG_BUILD_BUNDLE)
230230
merge_append_test.cc
231231
merging_snapshot_update_test.cc
232232
name_mapping_update_test.cc
233+
row_delta_test.cc
233234
snapshot_manager_test.cc
234235
transaction_test.cc
235236
update_location_test.cc

0 commit comments

Comments
 (0)