Skip to content

Commit 74e20c4

Browse files
committed
feat: update partition spec
1 parent 9805fae commit 74e20c4

7 files changed

Lines changed: 733 additions & 0 deletions

File tree

src/iceberg/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ set(ICEBERG_SOURCES
6666
transform.cc
6767
transform_function.cc
6868
type.cc
69+
update_partition_spec.cc
6970
util/bucket_util.cc
7071
util/conversions.cc
7172
util/decimal.cc

src/iceberg/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ iceberg_sources = files(
8888
'transform.cc',
8989
'transform_function.cc',
9090
'type.cc',
91+
'update_partition_spec.cc',
9192
'util/bucket_util.cc',
9293
'util/conversions.cc',
9394
'util/decimal.cc',

src/iceberg/table.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "iceberg/table_metadata.h"
2929
#include "iceberg/table_properties.h"
3030
#include "iceberg/table_scan.h"
31+
#include "iceberg/update_partition_spec.h"
3132
#include "iceberg/util/macros.h"
3233

3334
namespace iceberg {
@@ -94,6 +95,8 @@ const TableProperties& Table::properties() const { return *properties_; }
9495

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

98+
const TableMetadata& Table::metadata() const { return *metadata_; }
99+
97100
Result<std::shared_ptr<Snapshot>> Table::current_snapshot() const {
98101
return metadata_->Snapshot();
99102
}
@@ -110,6 +113,10 @@ const std::vector<SnapshotLogEntry>& Table::history() const {
110113
return metadata_->snapshot_log;
111114
}
112115

116+
std::unique_ptr<UpdatePartitionSpec> Table::UpdateSpec() {
117+
return std::make_unique<UpdatePartitionSpec>(this);
118+
}
119+
113120
std::unique_ptr<Transaction> Table::NewTransaction() const {
114121
throw NotImplemented("Table::NewTransaction is not implemented");
115122
}

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

@@ -104,6 +107,11 @@ class ICEBERG_EXPORT Table {
104107
/// \return a vector of history entries
105108
const std::vector<SnapshotLogEntry>& history() const;
106109

110+
/// \brief Create a new UpdatePartitionSpec to alter the partition spec of this table
111+
/// and commit the changes.
112+
/// \return a pointer to the new UpdatePartitionSpec
113+
std::unique_ptr<UpdatePartitionSpec> UpdateSpec();
114+
107115
/// \brief Create a new table scan builder for this table
108116
///
109117
/// Once a table scan builder is created, it can be refined to project columns and

src/iceberg/type_fwd.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ class PendingUpdate;
161161
template <typename T>
162162
class PendingUpdateTyped;
163163

164+
class BoundPredicate;
165+
class UnboundPredicate;
166+
167+
class BoundReference;
168+
class BoundTransform;
169+
template <typename B>
170+
class UnboundTerm;
171+
172+
class UpdatePartitionSpec;
173+
164174
/// ----------------------------------------------------------------------------
165175
/// TODO: Forward declarations below are not added yet.
166176
/// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)