Skip to content

Commit 06b6e72

Browse files
committed
feat: update partition spec
1 parent 09f26b6 commit 06b6e72

14 files changed

Lines changed: 1787 additions & 2 deletions

src/iceberg/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ set(ICEBERG_SOURCES
7272
transform.cc
7373
transform_function.cc
7474
type.cc
75+
update/update_partition_spec.cc
7576
update/update_properties.cc
7677
util/bucket_util.cc
7778
util/conversions.cc

src/iceberg/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ iceberg_sources = files(
9494
'transform.cc',
9595
'transform_function.cc',
9696
'type.cc',
97+
'update/update_partition_spec.cc',
9798
'update/update_properties.cc',
9899
'util/bucket_util.cc',
99100
'util/conversions.cc',

src/iceberg/table.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "iceberg/table_metadata.h"
2727
#include "iceberg/table_properties.h"
2828
#include "iceberg/table_scan.h"
29+
#include "iceberg/update/update_partition_spec.h"
2930
#include "iceberg/update/update_properties.h"
3031
#include "iceberg/util/macros.h"
3132

@@ -93,6 +94,8 @@ const TableProperties& Table::properties() const { return *properties_; }
9394

9495
const std::string& Table::location() const { return metadata_->location; }
9596

97+
const TableMetadata& Table::metadata() const { return *metadata_; }
98+
9699
Result<std::shared_ptr<Snapshot>> Table::current_snapshot() const {
97100
return metadata_->Snapshot();
98101
}
@@ -113,6 +116,10 @@ std::unique_ptr<UpdateProperties> Table::UpdateProperties() const {
113116
return std::make_unique<iceberg::UpdateProperties>(identifier_, catalog_, metadata_);
114117
}
115118

119+
std::unique_ptr<UpdatePartitionSpec> Table::UpdateSpec() {
120+
return std::make_unique<UpdatePartitionSpec>(identifier_, catalog_, metadata_);
121+
}
122+
116123
std::unique_ptr<Transaction> Table::NewTransaction() const {
117124
throw NotImplemented("Table::NewTransaction is not implemented");
118125
}

src/iceberg/table.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ class ICEBERG_EXPORT Table {
8787
/// \brief Return the table's base location
8888
const std::string& location() const;
8989

90+
/// \brief Return the table's metadata
91+
const TableMetadata& metadata() const;
92+
9093
/// \brief Return the table's current snapshot, return NotFoundError if not found
9194
Result<std::shared_ptr<Snapshot>> current_snapshot() const;
9295

@@ -110,6 +113,11 @@ class ICEBERG_EXPORT Table {
110113
/// \return a new UpdateProperties instance
111114
virtual std::unique_ptr<iceberg::UpdateProperties> UpdateProperties() const;
112115

116+
/// \brief Create a new UpdatePartitionSpec to alter the partition spec of this table
117+
/// and commit the changes.
118+
/// \return a pointer to the new UpdatePartitionSpec
119+
virtual std::unique_ptr<UpdatePartitionSpec> UpdateSpec();
120+
113121
/// \brief Create a new table scan builder for this table
114122
///
115123
/// Once a table scan builder is created, it can be refined to project columns and

src/iceberg/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ add_iceberg_test(table_test
7777
table_requirement_test.cc
7878
table_requirements_test.cc
7979
table_update_test.cc
80+
update_partition_spec_test.cc
8081
update_properties_test.cc)
8182

8283
add_iceberg_test(expression_test

src/iceberg/test/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ iceberg_tests = {
5353
'table_requirement_test.cc',
5454
'table_test.cc',
5555
'table_update_test.cc',
56+
'update_partition_spec_test.cc',
5657
'update_properties_test.cc',
5758
),
5859
},

src/iceberg/test/mock_catalog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <gtest/gtest.h>
2424

2525
#include "iceberg/catalog.h"
26+
#include "iceberg/table.h"
27+
#include "iceberg/transaction.h"
2628

2729
namespace iceberg {
2830

0 commit comments

Comments
 (0)