wgtmac commented on code in PR #261:
URL: https://github.com/apache/iceberg-cpp/pull/261#discussion_r2438387126
##########
src/iceberg/v1_metadata.cc:
##########
@@ -47,15 +50,14 @@ Status ManifestEntryAdapterV1::Init() {
DataFile::kSplitOffsets.field_id(),
DataFile::kSortOrderId.field_id(),
};
- // TODO(xiao.dong) schema to json
- metadata_["schema"] = "{}";
- // TODO(xiao.dong) partition spec to json
- metadata_["partition-spec"] = "{}";
+ ICEBERG_RETURN_UNEXPECTED(InitSchema(kManifestEntryFieldIds));
+ metadata_["schema"] = ToJson(*manifest_schema_).dump();
Review Comment:
```suggestion
metadata_["schema"] = ToJsonString(ToJson(*manifest_schema_));
```
##########
src/iceberg/v3_metadata.cc:
##########
@@ -19,6 +19,9 @@
#include "iceberg/v3_metadata.h"
+#include <nlohmann/json.hpp>
Review Comment:
ditto
##########
src/iceberg/v1_metadata.cc:
##########
@@ -47,15 +50,14 @@ Status ManifestEntryAdapterV1::Init() {
DataFile::kSplitOffsets.field_id(),
DataFile::kSortOrderId.field_id(),
};
- // TODO(xiao.dong) schema to json
- metadata_["schema"] = "{}";
- // TODO(xiao.dong) partition spec to json
- metadata_["partition-spec"] = "{}";
+ ICEBERG_RETURN_UNEXPECTED(InitSchema(kManifestEntryFieldIds));
+ metadata_["schema"] = ToJson(*manifest_schema_).dump();
if (partition_spec_ != nullptr) {
+ metadata_["partition-spec"] = ToJson(*partition_spec_).dump();
Review Comment:
```suggestion
metadata_["partition-spec"] = ToJsonString(ToJson(*partition_spec_));
```
##########
src/iceberg/v1_metadata.cc:
##########
@@ -47,15 +50,14 @@ Status ManifestEntryAdapterV1::Init() {
DataFile::kSplitOffsets.field_id(),
DataFile::kSortOrderId.field_id(),
};
- // TODO(xiao.dong) schema to json
- metadata_["schema"] = "{}";
- // TODO(xiao.dong) partition spec to json
- metadata_["partition-spec"] = "{}";
+ ICEBERG_RETURN_UNEXPECTED(InitSchema(kManifestEntryFieldIds));
+ metadata_["schema"] = ToJson(*manifest_schema_).dump();
Review Comment:
Or we can add the following to `json_internal.h`
```cpp
template <typename T>
ICEBERG_EXPORT Result<std::string> ToJsonString(const T& value)
requires requires { ToJson(value); }
{
return ToJsonString(ToJson(value));
}
```
##########
src/iceberg/v2_metadata.cc:
##########
@@ -19,9 +19,13 @@
#include "iceberg/v2_metadata.h"
+#include <nlohmann/json.hpp>
Review Comment:
ditto
##########
src/iceberg/v1_metadata.cc:
##########
@@ -19,6 +19,9 @@
#include "iceberg/v1_metadata.h"
+#include <nlohmann/json.hpp>
+
Review Comment:
```suggestion
```
I don't think we need this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]