wgtmac commented on code in PR #64: URL: https://github.com/apache/iceberg-cpp/pull/64#discussion_r2036416336
########## src/iceberg/json_internal.h: ########## @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include <memory> + +#include <nlohmann/json.hpp> Review Comment: ```suggestion #include <nlohmann/json_fwd.hpp> ``` ########## src/iceberg/transform.h: ########## @@ -82,6 +82,9 @@ class ICEBERG_EXPORT TransformFunction : public util::Formattable { TransformType transform_type_; }; +expected<std::unique_ptr<TransformFunction>, Error> TransformFunctionFromString( + const std::string& str); + class IdentityTransformFunction : public TransformFunction { Review Comment: ```suggestion class ICEBERG_EXPORT IdentityTransformFunction : public TransformFunction { ``` ########## src/iceberg/type_fwd.h: ########## @@ -97,6 +97,7 @@ class HistoryEntry; class PartitionSpec; class Snapshot; class SortOrder; +class SortField; Review Comment: Sort alphabetically. ########## src/iceberg/sort_field.h: ########## @@ -41,13 +43,49 @@ enum class SortDirection { /// Descending kDescending, }; +/// \brief Get the relative sort direction name +constexpr std::string_view SortDirectionToString(SortDirection direction) { + switch (direction) { + case SortDirection::kAscending: + return "asc"; + case SortDirection::kDescending: + return "desc"; + default: + return "invalid"; + } +} +/// \brief Get the relative sort direction from name +constexpr expected<SortDirection, Error> SortDirectionFromString(const std::string& str) { + if (str == "asc") return SortDirection::kAscending; + if (str == "desc") return SortDirection::kDescending; + return unexpected<Error>({.kind = ErrorKind::kInvalidArgument, + .message = "Invalid SortDirection string: " + str}); +} enum class NullOrder { /// Nulls are sorted first kFirst, /// Nulls are sorted last kLast, }; +/// \brief Get the relative null order name +constexpr std::string_view NullOrderToString(NullOrder null_order) { Review Comment: ```suggestion ICEBERG_EXPORT constexpr std::string_view NullOrderToString(NullOrder null_order) { ``` ########## src/iceberg/transform.h: ########## @@ -82,6 +82,9 @@ class ICEBERG_EXPORT TransformFunction : public util::Formattable { TransformType transform_type_; }; +expected<std::unique_ptr<TransformFunction>, Error> TransformFunctionFromString( Review Comment: Can we use `std::string_view`? ########## src/iceberg/transform.h: ########## @@ -82,6 +82,9 @@ class ICEBERG_EXPORT TransformFunction : public util::Formattable { TransformType transform_type_; }; +expected<std::unique_ptr<TransformFunction>, Error> TransformFunctionFromString( Review Comment: ```suggestion ICEBERG_EXPORT expected<std::unique_ptr<TransformFunction>, Error> TransformFunctionFromString( ``` ########## src/iceberg/sort_field.h: ########## @@ -41,13 +43,49 @@ enum class SortDirection { /// Descending kDescending, }; +/// \brief Get the relative sort direction name +constexpr std::string_view SortDirectionToString(SortDirection direction) { + switch (direction) { + case SortDirection::kAscending: + return "asc"; + case SortDirection::kDescending: + return "desc"; + default: + return "invalid"; + } +} +/// \brief Get the relative sort direction from name +constexpr expected<SortDirection, Error> SortDirectionFromString(const std::string& str) { + if (str == "asc") return SortDirection::kAscending; + if (str == "desc") return SortDirection::kDescending; + return unexpected<Error>({.kind = ErrorKind::kInvalidArgument, + .message = "Invalid SortDirection string: " + str}); +} enum class NullOrder { /// Nulls are sorted first kFirst, /// Nulls are sorted last kLast, }; +/// \brief Get the relative null order name +constexpr std::string_view NullOrderToString(NullOrder null_order) { + switch (null_order) { + case NullOrder::kFirst: + return "nulls-first"; + case NullOrder::kLast: + return "nulls-last"; + default: + return "invalid"; + } +} +/// \brief Get the relative null order from name +constexpr expected<NullOrder, Error> NullOrderFromString(const std::string& str) { Review Comment: ```suggestion ICEBERG_EXPORT constexpr expected<NullOrder, Error> NullOrderFromString(const std::string& str) { ``` -- 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]
