zhjwpku commented on code in PR #553:
URL: https://github.com/apache/iceberg-cpp/pull/553#discussion_r2757404651


##########
src/iceberg/expression/json_serde.cc:
##########
@@ -123,6 +130,41 @@ nlohmann::json ToJson(Expression::Operation op) {
   return json;
 }
 
+nlohmann::json ToJson(const NamedReference& ref) { return 
std::string(ref.name()); }
+
+Result<std::shared_ptr<NamedReference>> NamedReferenceFromJson(
+    const nlohmann::json& json) {
+  if (!json.is_string()) {

Review Comment:
   add a [[unlikely]] hint?



##########
src/iceberg/expression/json_serde.cc:
##########
@@ -123,6 +130,41 @@ nlohmann::json ToJson(Expression::Operation op) {
   return json;
 }
 
+nlohmann::json ToJson(const NamedReference& ref) { return 
std::string(ref.name()); }
+
+Result<std::shared_ptr<NamedReference>> NamedReferenceFromJson(
+    const nlohmann::json& json) {
+  if (!json.is_string()) {
+    return JsonParseError("Expected string for named reference");
+  }
+  ICEBERG_ASSIGN_OR_RAISE(auto ref, 
NamedReference::Make(json.get<std::string>()));
+  return std::shared_ptr<NamedReference>(std::move(ref));
+}
+
+nlohmann::json ToJson(const UnboundTransform& transform) {
+  auto& mutable_transform = const_cast<UnboundTransform&>(transform);
+  nlohmann::json json;
+  json[kType] = std::string(kTransform);

Review Comment:
   ```suggestion
     json[kType] = kTransform;
   ```
   
   I don't think the string ctor around kTransform is necessary. The same 
applies to other places as well.



##########
src/iceberg/expression/json_serde.cc:
##########
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+#include <cctype>

Review Comment:
   do we need this header?



-- 
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]

Reply via email to