Skip to content

Commit f63808c

Browse files
committed
fix confict and some bug
1 parent dbb2584 commit f63808c

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

src/iceberg/partition_spec.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ std::span<const PartitionField> PartitionSpec::fields() const { return fields_;
5959

6060
Result<std::unique_ptr<StructType>> PartitionSpec::PartitionType(const Schema& schema) {
6161
if (fields_.empty()) {
62-
return nullptr;
62+
return std::make_unique<StructType>(std::vector<SchemaField>{});
6363
}
6464

6565
std::vector<SchemaField> partition_fields;

src/iceberg/v1_metadata.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include "iceberg/v1_metadata.h"
21+
2122
#include <memory>
2223

2324
#include "iceberg/json_internal.h"
@@ -31,8 +32,10 @@
3132
namespace iceberg {
3233

3334
ManifestEntryAdapterV1::ManifestEntryAdapterV1(
34-
std::optional<int64_t> snapshot_id, std::shared_ptr<PartitionSpec> partition_spec, std::shared_ptr<Schema> current_schema)
35-
: ManifestEntryAdapter(std::move(partition_spec), std::move(current_schema), ManifestContent::kData),
35+
std::optional<int64_t> snapshot_id, std::shared_ptr<PartitionSpec> partition_spec,
36+
std::shared_ptr<Schema> current_schema)
37+
: ManifestEntryAdapter(std::move(partition_spec), std::move(current_schema),
38+
ManifestContent::kData),
3639
snapshot_id_(snapshot_id) {}
3740

3841
std::shared_ptr<Schema> ManifestEntryAdapterV1::EntrySchema(
@@ -74,16 +77,14 @@ std::shared_ptr<StructType> ManifestEntryAdapterV1::DataFileSchema(
7477
}
7578

7679
Status ManifestEntryAdapterV1::Init() {
77-
// TODO(gangwu): fix the schema to use current table schema.
78-
// ICEBERG_ASSIGN_OR_RAISE(metadata_["schema"], ToJsonString(*manifest_schema_))
80+
ICEBERG_ASSIGN_OR_RAISE(metadata_["schema"], ToJsonString(*current_schema_))
7981
ICEBERG_ASSIGN_OR_RAISE(metadata_["partition-spec"], ToJsonString(*partition_spec_));
8082
metadata_["partition-spec-id"] = std::to_string(partition_spec_->spec_id());
8183
metadata_["format-version"] = "1";
8284

83-
ICEBERG_ASSIGN_OR_RAISE(auto partition_type, partition_spec_->PartitionType());
84-
if (!partition_type) {
85-
partition_type = std::make_shared<StructType>(std::vector<SchemaField>{});
86-
}
85+
ICEBERG_ASSIGN_OR_RAISE(auto partition_type,
86+
partition_spec_->PartitionType(*current_schema_));
87+
8788
manifest_schema_ = EntrySchema(std::move(partition_type));
8889
return ToArrowSchema(*manifest_schema_, &schema_);
8990
}

src/iceberg/v2_metadata.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ namespace iceberg {
3030

3131
ManifestEntryAdapterV2::ManifestEntryAdapterV2(
3232
std::optional<int64_t> snapshot_id, std::shared_ptr<PartitionSpec> partition_spec,
33-
std::shared_ptr<Schema> current_schema, ManifestContent content)
34-
: ManifestEntryAdapter(std::move(partition_spec), std::move(current_schema), std::move(content)),
33+
std::shared_ptr<Schema> current_schema, ManifestContent content)
34+
: ManifestEntryAdapter(std::move(partition_spec), std::move(current_schema),
35+
std::move(content)),
3536
snapshot_id_(snapshot_id) {}
3637

3738
std::shared_ptr<Schema> ManifestEntryAdapterV2::EntrySchema(
@@ -74,16 +75,14 @@ std::shared_ptr<StructType> ManifestEntryAdapterV2::DataFileType(
7475
}
7576

7677
Status ManifestEntryAdapterV2::Init() {
77-
// ICEBERG_ASSIGN_OR_RAISE(metadata_["schema"], ToJsonString(*manifest_schema_))
78+
ICEBERG_ASSIGN_OR_RAISE(metadata_["schema"], ToJsonString(*current_schema_))
7879
ICEBERG_ASSIGN_OR_RAISE(metadata_["partition-spec"], ToJsonString(*partition_spec_));
7980
metadata_["partition-spec-id"] = std::to_string(partition_spec_->spec_id());
8081
metadata_["format-version"] = "2";
8182
metadata_["content"] = content_ == ManifestContent::kData ? "data" : "delete";
8283

83-
ICEBERG_ASSIGN_OR_RAISE(auto partition_type, partition_spec_->PartitionType());
84-
if (!partition_type) {
85-
partition_type = std::make_shared<StructType>(std::vector<SchemaField>{});
86-
}
84+
ICEBERG_ASSIGN_OR_RAISE(auto partition_type,
85+
partition_spec_->PartitionType(*current_schema_));
8786
manifest_schema_ = EntrySchema(std::move(partition_type));
8887
return ToArrowSchema(*manifest_schema_, &schema_);
8988
}

src/iceberg/v3_metadata.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include "iceberg/v3_metadata.h"
21+
2122
#include <memory>
2223

2324
#include "iceberg/json_internal.h"
@@ -31,10 +32,12 @@ namespace iceberg {
3132

3233
ManifestEntryAdapterV3::ManifestEntryAdapterV3(
3334
std::optional<int64_t> snapshot_id, std::optional<int64_t> first_row_id,
34-
std::shared_ptr<PartitionSpec> partition_spec, std::shared_ptr<Schema> current_schema, ManifestContent content)
35-
: ManifestEntryAdapter(std::move(partition_spec), std::move(current_schema),std::move(content)),
36-
snapshot_id_(snapshot_id),
37-
first_row_id_(first_row_id) {}
35+
std::shared_ptr<PartitionSpec> partition_spec, std::shared_ptr<Schema> current_schema,
36+
ManifestContent content)
37+
: ManifestEntryAdapter(std::move(partition_spec), std::move(current_schema),
38+
std::move(content)),
39+
snapshot_id_(snapshot_id),
40+
first_row_id_(first_row_id) {}
3841

3942
std::shared_ptr<Schema> ManifestEntryAdapterV3::EntrySchema(
4043
std::shared_ptr<StructType> partition_type) {
@@ -81,16 +84,14 @@ std::shared_ptr<StructType> ManifestEntryAdapterV3::DataFileType(
8184
}
8285

8386
Status ManifestEntryAdapterV3::Init() {
84-
// ICEBERG_ASSIGN_OR_RAISE(metadata_["schema"], ToJsonString(*manifest_schema_))
87+
ICEBERG_ASSIGN_OR_RAISE(metadata_["schema"], ToJsonString(*current_schema_))
8588
ICEBERG_ASSIGN_OR_RAISE(metadata_["partition-spec"], ToJsonString(*partition_spec_));
8689
metadata_["partition-spec-id"] = std::to_string(partition_spec_->spec_id());
8790
metadata_["format-version"] = "3";
8891
metadata_["content"] = content_ == ManifestContent::kData ? "data" : "delete";
8992

90-
ICEBERG_ASSIGN_OR_RAISE(auto partition_type, partition_spec_->PartitionType());
91-
if (!partition_type) {
92-
partition_type = std::make_shared<StructType>(std::vector<SchemaField>{});
93-
}
93+
ICEBERG_ASSIGN_OR_RAISE(auto partition_type,
94+
partition_spec_->PartitionType(*current_schema_));
9495
manifest_schema_ = EntrySchema(std::move(partition_type));
9596
return ToArrowSchema(*manifest_schema_, &schema_);
9697
}

0 commit comments

Comments
 (0)