Skip to content

Commit fea772e

Browse files
committed
update
1 parent c16b422 commit fea772e

File tree

8 files changed

+366
-7
lines changed

8 files changed

+366
-7
lines changed

src/iceberg/catalog/rest/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ set(ICEBERG_REST_SOURCES
2323
json_internal.cc
2424
resource_paths.cc
2525
rest_catalog.cc
26-
rest_util.cc)
26+
rest_util.cc
27+
types.cc)
2728

2829
set(ICEBERG_REST_STATIC_BUILD_INTERFACE_LIBS)
2930
set(ICEBERG_REST_SHARED_BUILD_INTERFACE_LIBS)

src/iceberg/catalog/rest/json_internal.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ Result<CreateTableRequest> CreateTableRequestFromJson(const nlohmann::json& json
364364
ICEBERG_ASSIGN_OR_RAISE(request.name, GetJsonValue<std::string>(json, kName));
365365
ICEBERG_ASSIGN_OR_RAISE(request.location,
366366
GetJsonValueOrDefault<std::string>(json, kLocation));
367-
ICEBERG_ASSIGN_OR_RAISE(auto schema_json, GetJsonValue<nlohmann::json>(json, kSchema));
368-
ICEBERG_ASSIGN_OR_RAISE(request.schema, SchemaFromJson(schema_json));
367+
ICEBERG_ASSIGN_OR_RAISE(auto schema, GetJsonValue<nlohmann::json>(json, kSchema));
368+
ICEBERG_ASSIGN_OR_RAISE(request.schema, SchemaFromJson(schema));
369369

370370
if (json.contains(kPartitionSpec)) {
371371
ICEBERG_ASSIGN_OR_RAISE(auto partition_spec,
@@ -375,10 +375,10 @@ Result<CreateTableRequest> CreateTableRequestFromJson(const nlohmann::json& json
375375
PartitionSpec::kInitialSpecId));
376376
}
377377
if (json.contains(kWriteOrder)) {
378-
ICEBERG_ASSIGN_OR_RAISE(auto sort_order_json,
378+
ICEBERG_ASSIGN_OR_RAISE(auto sort_order,
379379
GetJsonValue<nlohmann::json>(json, kWriteOrder));
380380
ICEBERG_ASSIGN_OR_RAISE(request.write_order,
381-
SortOrderFromJson(sort_order_json, request.schema));
381+
SortOrderFromJson(sort_order, request.schema));
382382
}
383383

384384
ICEBERG_ASSIGN_OR_RAISE(request.stage_create,

src/iceberg/catalog/rest/rest_catalog.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ RestCatalog::~RestCatalog() = default;
8181
Result<std::shared_ptr<RestCatalog>> RestCatalog::Make(
8282
const RestCatalogProperties& config, std::shared_ptr<FileIO> file_io) {
8383
ICEBERG_ASSIGN_OR_RAISE(auto uri, config.Uri());
84+
if (!file_io) {
85+
return RestError("FileIO instance is required to create RestCatalog");
86+
}
8487
ICEBERG_ASSIGN_OR_RAISE(
8588
auto paths, ResourcePaths::Make(std::string(TrimTrailingSlash(uri)),
8689
config.Get(RestCatalogProperties::kPrefix)));

src/iceberg/catalog/rest/types.cc

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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/catalog/rest/types.h"
21+
22+
#include "iceberg/partition_spec.h"
23+
#include "iceberg/schema.h"
24+
#include "iceberg/sort_order.h"
25+
#include "iceberg/table_metadata.h"
26+
27+
namespace iceberg::rest {
28+
29+
bool CreateTableRequest::operator==(const CreateTableRequest& other) const {
30+
if (name != other.name || location != other.location ||
31+
stage_create != other.stage_create || properties != other.properties) {
32+
return false;
33+
}
34+
35+
if (!schema != !other.schema) {
36+
return false;
37+
}
38+
if (schema && *schema != *other.schema) {
39+
return false;
40+
}
41+
42+
if (!partition_spec != !other.partition_spec) {
43+
return false;
44+
}
45+
if (partition_spec && *partition_spec != *other.partition_spec) {
46+
return false;
47+
}
48+
49+
if (!write_order != !other.write_order) {
50+
return false;
51+
}
52+
if (write_order && *write_order != *other.write_order) {
53+
return false;
54+
}
55+
56+
return true;
57+
}
58+
59+
bool LoadTableResult::operator==(const LoadTableResult& other) const {
60+
// Compare primitive fields
61+
if (metadata_location != other.metadata_location || config != other.config) {
62+
return false;
63+
}
64+
65+
// Compare metadata (required) - deep comparison
66+
if (!metadata != !other.metadata) {
67+
return false; // One is null, the other isn't
68+
}
69+
if (metadata && *metadata != *other.metadata) {
70+
return false;
71+
}
72+
73+
return true;
74+
}
75+
76+
} // namespace iceberg::rest

src/iceberg/catalog/rest/types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ struct ICEBERG_REST_EXPORT CreateTableRequest {
159159
}
160160
return {};
161161
}
162+
163+
bool operator==(const CreateTableRequest& other) const;
162164
};
163165

164166
/// \brief An opaque token that allows clients to make use of pagination for list APIs.
@@ -179,7 +181,7 @@ struct ICEBERG_REST_EXPORT LoadTableResult {
179181
return {};
180182
}
181183

182-
bool operator==(const LoadTableResult&) const = default;
184+
bool operator==(const LoadTableResult& other) const;
183185
};
184186

185187
/// \brief Alias of LoadTableResult used as the body of CreateTableResponse

src/iceberg/table_metadata.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ bool operator==(const TableMetadata& lhs, const TableMetadata& rhs) {
157157
lhs.last_column_id == rhs.last_column_id &&
158158
lhs.current_schema_id == rhs.current_schema_id &&
159159
SharedPtrVectorEquals(lhs.schemas, rhs.schemas) &&
160+
SharedPtrVectorEquals(lhs.partition_specs, rhs.partition_specs) &&
160161
lhs.default_spec_id == rhs.default_spec_id &&
161162
lhs.last_partition_id == rhs.last_partition_id &&
162163
lhs.properties == rhs.properties &&

src/iceberg/test/rest_catalog_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class RestCatalogIntegrationTest : public ::testing::Test {
133133
.Set(RestCatalogProperties::kName, std::string(kCatalogName))
134134
.Set(RestCatalogProperties::kWarehouse, std::string(kWarehouseName));
135135
auto file_io = std::make_shared<test::StdFileIO>();
136-
return RestCatalog::Make(*config, file_io);
136+
return RestCatalog::Make(*config, std::make_shared<test::StdFileIO>());
137137
}
138138

139139
static inline std::unique_ptr<DockerCompose> docker_compose_;

0 commit comments

Comments
 (0)