Skip to content

Commit e6ba4e1

Browse files
committed
fix build error
1 parent 30dceec commit e6ba4e1

9 files changed

Lines changed: 485 additions & 27 deletions

src/iceberg/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ set(ICEBERG_SOURCES
4747
table.cc
4848
table_metadata.cc
4949
table_properties.cc
50+
table_requirement.cc
51+
table_requirements.cc
5052
table_scan.cc
53+
table_update.cc
5154
transform.cc
5255
transform_function.cc
5356
type.cc

src/iceberg/table_metadata.cc

Lines changed: 181 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "iceberg/schema.h"
3333
#include "iceberg/snapshot.h"
3434
#include "iceberg/sort_order.h"
35-
#include "iceberg/table_update.h"
3635
#include "iceberg/util/gzip_internal.h"
3736
#include "iceberg/util/macros.h"
3837

@@ -198,4 +197,185 @@ Status TableMetadataUtil::Write(FileIO& io, const std::string& location,
198197
return io.WriteFile(location, json_string);
199198
}
200199

200+
// TableMetadataBuilder implementation
201+
202+
struct TableMetadataBuilder::Impl {};
203+
204+
TableMetadataBuilder::TableMetadataBuilder(int8_t format_version)
205+
: impl_(std::make_unique<Impl>()) {}
206+
207+
TableMetadataBuilder::TableMetadataBuilder(const TableMetadata* base)
208+
: impl_(std::make_unique<Impl>()) {}
209+
210+
TableMetadataBuilder::~TableMetadataBuilder() = default;
211+
212+
TableMetadataBuilder::TableMetadataBuilder(TableMetadataBuilder&&) noexcept = default;
213+
214+
TableMetadataBuilder& TableMetadataBuilder::operator=(TableMetadataBuilder&&) noexcept =
215+
default;
216+
217+
std::unique_ptr<TableMetadataBuilder> TableMetadataBuilder::BuildFromEmpty(
218+
int8_t format_version) {
219+
return std::unique_ptr<TableMetadataBuilder>(
220+
new TableMetadataBuilder(format_version)); // NOLINT
221+
}
222+
223+
std::unique_ptr<TableMetadataBuilder> TableMetadataBuilder::BuildFrom(
224+
const TableMetadata* base) {
225+
return std::unique_ptr<TableMetadataBuilder>(new TableMetadataBuilder(base)); // NOLINT
226+
}
227+
228+
TableMetadataBuilder& TableMetadataBuilder::SetMetadataLocation(
229+
std::string_view metadata_location) {
230+
return *this;
231+
}
232+
233+
TableMetadataBuilder& TableMetadataBuilder::SetPreviousMetadataLocation(
234+
std::string_view previous_metadata_location) {
235+
return *this;
236+
}
237+
238+
TableMetadataBuilder& TableMetadataBuilder::AssignUUID() { return *this; }
239+
240+
TableMetadataBuilder& TableMetadataBuilder::AssignUUID(std::string_view uuid) {
241+
return *this;
242+
}
243+
244+
TableMetadataBuilder& TableMetadataBuilder::UpgradeFormatVersion(
245+
int8_t new_format_version) {
246+
return *this;
247+
}
248+
249+
TableMetadataBuilder& TableMetadataBuilder::SetCurrentSchema(
250+
std::shared_ptr<Schema> schema, int32_t new_last_column_id) {
251+
return *this;
252+
}
253+
254+
TableMetadataBuilder& TableMetadataBuilder::SetCurrentSchema(int32_t schema_id) {
255+
return *this;
256+
}
257+
258+
TableMetadataBuilder& TableMetadataBuilder::AddSchema(std::shared_ptr<Schema> schema) {
259+
return *this;
260+
}
261+
262+
TableMetadataBuilder& TableMetadataBuilder::SetDefaultPartitionSpec(
263+
std::shared_ptr<PartitionSpec> spec) {
264+
return *this;
265+
}
266+
267+
TableMetadataBuilder& TableMetadataBuilder::SetDefaultPartitionSpec(int32_t spec_id) {
268+
return *this;
269+
}
270+
271+
TableMetadataBuilder& TableMetadataBuilder::AddPartitionSpec(
272+
std::shared_ptr<PartitionSpec> spec) {
273+
return *this;
274+
}
275+
276+
TableMetadataBuilder& TableMetadataBuilder::RemovePartitionSpecs(
277+
const std::vector<int32_t>& spec_ids) {
278+
return *this;
279+
}
280+
281+
TableMetadataBuilder& TableMetadataBuilder::RemoveSchemas(
282+
const std::vector<int32_t>& schema_ids) {
283+
return *this;
284+
}
285+
286+
TableMetadataBuilder& TableMetadataBuilder::SetDefaultSortOrder(
287+
std::shared_ptr<SortOrder> order) {
288+
return *this;
289+
}
290+
291+
TableMetadataBuilder& TableMetadataBuilder::SetDefaultSortOrder(int32_t order_id) {
292+
return *this;
293+
}
294+
295+
TableMetadataBuilder& TableMetadataBuilder::AddSortOrder(
296+
std::shared_ptr<SortOrder> order) {
297+
return *this;
298+
}
299+
300+
TableMetadataBuilder& TableMetadataBuilder::AddSnapshot(
301+
std::shared_ptr<Snapshot> snapshot) {
302+
return *this;
303+
}
304+
305+
TableMetadataBuilder& TableMetadataBuilder::SetBranchSnapshot(int64_t snapshot_id,
306+
const std::string& branch) {
307+
return *this;
308+
}
309+
310+
TableMetadataBuilder& TableMetadataBuilder::SetRef(const std::string& name,
311+
std::shared_ptr<SnapshotRef> ref) {
312+
return *this;
313+
}
314+
315+
TableMetadataBuilder& TableMetadataBuilder::RemoveRef(const std::string& name) {
316+
return *this;
317+
}
318+
319+
TableMetadataBuilder& TableMetadataBuilder::RemoveSnapshots(
320+
const std::vector<std::shared_ptr<Snapshot>>& snapshots_to_remove) {
321+
return *this;
322+
}
323+
324+
TableMetadataBuilder& TableMetadataBuilder::RemoveSnapshots(
325+
const std::vector<int64_t>& snapshot_ids) {
326+
return *this;
327+
}
328+
329+
TableMetadataBuilder& TableMetadataBuilder::suppressHistoricalSnapshots() {
330+
return *this;
331+
}
332+
333+
TableMetadataBuilder& TableMetadataBuilder::SetStatistics(
334+
const std::shared_ptr<StatisticsFile>& statistics_file) {
335+
return *this;
336+
}
337+
338+
TableMetadataBuilder& TableMetadataBuilder::RemoveStatistics(int64_t snapshot_id) {
339+
return *this;
340+
}
341+
342+
TableMetadataBuilder& TableMetadataBuilder::SetPartitionStatistics(
343+
const std::shared_ptr<PartitionStatisticsFile>& partition_statistics_file) {
344+
return *this;
345+
}
346+
347+
TableMetadataBuilder& TableMetadataBuilder::RemovePartitionStatistics(
348+
int64_t snapshot_id) {
349+
return *this;
350+
}
351+
352+
TableMetadataBuilder& TableMetadataBuilder::SetProperties(
353+
const std::unordered_map<std::string, std::string>& updated) {
354+
return *this;
355+
}
356+
357+
TableMetadataBuilder& TableMetadataBuilder::RemoveProperties(
358+
const std::vector<std::string>& removed) {
359+
return *this;
360+
}
361+
362+
TableMetadataBuilder& TableMetadataBuilder::SetLocation(std::string_view location) {
363+
return *this;
364+
}
365+
366+
TableMetadataBuilder& TableMetadataBuilder::AddEncryptionKey(
367+
std::shared_ptr<EncryptedKey> key) {
368+
return *this;
369+
}
370+
371+
TableMetadataBuilder& TableMetadataBuilder::RemoveEncryptionKey(std::string_view key_id) {
372+
return *this;
373+
}
374+
375+
TableMetadataBuilder& TableMetadataBuilder::DiscardChanges() { return *this; }
376+
377+
Result<std::unique_ptr<TableMetadata>> TableMetadataBuilder::Build() {
378+
return NotImplemented("TableMetadataBuilder::Build not implemented");
379+
}
380+
201381
} // namespace iceberg

src/iceberg/table_requirement.cc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include "iceberg/table_requirement.h"
21+
22+
#include "iceberg/table_metadata.h"
23+
24+
namespace iceberg {
25+
26+
Status AssertTableDoesNotExist::Validate(const TableMetadata* base) const {
27+
return NotImplemented("AssertTableDoesNotExist::Validate not implemented");
28+
}
29+
30+
Status AssertTableUUID::Validate(const TableMetadata* base) const {
31+
return NotImplemented("AssertTableUUID::Validate not implemented");
32+
}
33+
34+
Status AssertRefSnapshotID::Validate(const TableMetadata* base) const {
35+
return NotImplemented("AssertRefSnapshotID::Validate not implemented");
36+
}
37+
38+
Status AssertLastAssignedFieldId::Validate(const TableMetadata* base) const {
39+
return NotImplemented("AssertLastAssignedFieldId::Validate not implemented");
40+
}
41+
42+
Status AssertCurrentSchemaID::Validate(const TableMetadata* base) const {
43+
return NotImplemented("AssertCurrentSchemaID::Validate not implemented");
44+
}
45+
46+
Status AssertLastAssignedPartitionId::Validate(const TableMetadata* base) const {
47+
return NotImplemented("AssertLastAssignedPartitionId::Validate not implemented");
48+
}
49+
50+
Status AssertDefaultSpecID::Validate(const TableMetadata* base) const {
51+
return NotImplemented("AssertDefaultSpecID::Validate not implemented");
52+
}
53+
54+
Status AssertDefaultSortOrderID::Validate(const TableMetadata* base) const {
55+
return NotImplemented("AssertDefaultSortOrderID::Validate not implemented");
56+
}
57+
58+
} // namespace iceberg

src/iceberg/table_requirement.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919

2020
#pragma once
2121

22-
/// \file iceberg/update_requirement.h
22+
/// \file iceberg/table_requirement.h
2323
/// Update requirements for Iceberg table operations.
2424
///
25-
/// Update requirements are conditions that must be satisfied before
25+
/// Table requirements are conditions that must be satisfied before
2626
/// applying metadata updates to a table. They are used for optimistic
2727
/// concurrency control in table operations.
2828

29-
#include <memory>
3029
#include <optional>
3130
#include <string>
3231

src/iceberg/table_requirements.cc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include "iceberg/table_requirements.h"
21+
22+
#include "iceberg/table_metadata.h"
23+
#include "iceberg/table_update.h"
24+
25+
namespace iceberg {
26+
27+
void MetadataUpdateContext::AddRequirement(
28+
std::unique_ptr<TableRequirement> requirement) {
29+
requirements_.push_back(std::move(requirement));
30+
}
31+
32+
Result<std::vector<std::unique_ptr<TableRequirement>>> MetadataUpdateContext::Build() {
33+
return std::move(requirements_);
34+
}
35+
36+
Result<std::vector<std::unique_ptr<TableRequirement>>> TableRequirements::ForCreateTable(
37+
const std::vector<std::unique_ptr<TableUpdate>>& table_updates) {
38+
return NotImplemented("TableRequirements::ForCreateTable not implemented");
39+
}
40+
41+
Result<std::vector<std::unique_ptr<TableRequirement>>> TableRequirements::ForReplaceTable(
42+
const TableMetadata& base,
43+
const std::vector<std::unique_ptr<TableUpdate>>& table_updates) {
44+
return NotImplemented("TableRequirements::ForReplaceTable not implemented");
45+
}
46+
47+
Result<std::vector<std::unique_ptr<TableRequirement>>> TableRequirements::ForUpdateTable(
48+
const TableMetadata& base,
49+
const std::vector<std::unique_ptr<TableUpdate>>& table_updates) {
50+
return NotImplemented("TableRequirements::ForUpdateTable not implemented");
51+
}
52+
53+
} // namespace iceberg

src/iceberg/table_requirements.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class ICEBERG_EXPORT TableRequirements {
8787
///
8888
/// \param table_updates The list of metadata updates for table creation
8989
/// \return A list of update requirements to validate before creation
90-
static std::vector<std::unique_ptr<TableRequirement>> ForCreateTable(
90+
static Result<std::vector<std::unique_ptr<TableRequirement>>> ForCreateTable(
9191
const std::vector<std::unique_ptr<TableUpdate>>& table_updates);
9292

9393
/// \brief Generate requirements for replacing an existing table
@@ -98,7 +98,7 @@ class ICEBERG_EXPORT TableRequirements {
9898
/// \param base The base table metadata
9999
/// \param table_updates The list of metadata updates for replacement
100100
/// \return A list of update requirements to validate before replacement
101-
static std::vector<std::unique_ptr<TableRequirement>> ForReplaceTable(
101+
static Result<std::vector<std::unique_ptr<TableRequirement>>> ForReplaceTable(
102102
const TableMetadata& base,
103103
const std::vector<std::unique_ptr<TableUpdate>>& table_updates);
104104

@@ -110,7 +110,7 @@ class ICEBERG_EXPORT TableRequirements {
110110
/// \param base The base table metadata
111111
/// \param table_updates The list of metadata updates
112112
/// \return A list of update requirements to validate before update
113-
static std::vector<std::unique_ptr<TableRequirement>> ForUpdateTable(
113+
static Result<std::vector<std::unique_ptr<TableRequirement>>> ForUpdateTable(
114114
const TableMetadata& base,
115115
const std::vector<std::unique_ptr<TableUpdate>>& table_updates);
116116
};

0 commit comments

Comments
 (0)