Skip to content

Commit c3850c6

Browse files
committed
feat: update partition spec
1 parent dba8f92 commit c3850c6

16 files changed

+1570
-1
lines changed

src/iceberg/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ set(ICEBERG_SOURCES
7777
transform_function.cc
7878
type.cc
7979
update/pending_update.cc
80+
update/update_partition_spec.cc
8081
update/update_properties.cc
8182
util/bucket_util.cc
8283
util/conversions.cc

src/iceberg/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ iceberg_sources = files(
9999
'transform_function.cc',
100100
'type.cc',
101101
'update/pending_update.cc',
102+
'update/update_partition_spec.cc',
102103
'update/update_properties.cc',
103104
'util/bucket_util.cc',
104105
'util/conversions.cc',

src/iceberg/table.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "iceberg/table.h"
2121

22+
#include <memory>
23+
2224
#include "iceberg/catalog.h"
2325
#include "iceberg/partition_spec.h"
2426
#include "iceberg/result.h"
@@ -28,6 +30,7 @@
2830
#include "iceberg/table_properties.h"
2931
#include "iceberg/table_scan.h"
3032
#include "iceberg/transaction.h"
33+
#include "iceberg/update/update_partition_spec.h"
3134
#include "iceberg/update/update_properties.h"
3235
#include "iceberg/util/macros.h"
3336

@@ -154,6 +157,13 @@ Result<std::shared_ptr<UpdateProperties>> Table::NewUpdateProperties() {
154157
return transaction->NewUpdateProperties();
155158
}
156159

160+
Result<std::shared_ptr<UpdatePartitionSpec>> Table::NewUpdateSpec() {
161+
ICEBERG_ASSIGN_OR_RAISE(
162+
auto transaction, Transaction::Make(shared_from_this(), Transaction::Kind::kUpdate,
163+
/*auto_commit=*/true));
164+
return transaction->NewUpdateSpec();
165+
}
166+
157167
Result<std::shared_ptr<StagedTable>> StagedTable::Make(
158168
TableIdentifier identifier, std::shared_ptr<TableMetadata> metadata,
159169
std::string metadata_location, std::shared_ptr<FileIO> io,

src/iceberg/table.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ class ICEBERG_EXPORT Table : public std::enable_shared_from_this<Table> {
132132
/// changes.
133133
virtual Result<std::shared_ptr<UpdateProperties>> NewUpdateProperties();
134134

135+
/// \brief Create a new UpdatePartitionSpec to update the partition spec of this table
136+
/// and commit the changes.
137+
virtual Result<std::shared_ptr<UpdatePartitionSpec>> NewUpdateSpec();
138+
135139
protected:
136140
Table(TableIdentifier identifier, std::shared_ptr<TableMetadata> metadata,
137141
std::string metadata_location, std::shared_ptr<FileIO> io,

src/iceberg/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ if(ICEBERG_BUILD_BUNDLE)
153153
USE_BUNDLE
154154
SOURCES
155155
transaction_test.cc
156+
update_partition_spec_test.cc
156157
update_properties_test.cc)
157158

158159
endif()

0 commit comments

Comments
 (0)