Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/iceberg/catalog/rest/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct ICEBERG_REST_EXPORT CatalogConfig {

/// \brief Validates the CatalogConfig.
Status Validate() const { return {}; }

bool operator==(const CatalogConfig&) const = default;
};

/// \brief JSON error payload returned in a response with further details on the error.
Expand All @@ -66,6 +68,8 @@ struct ICEBERG_REST_EXPORT ErrorResponse {
// stack is optional, no validation needed
return {};
}

bool operator==(const ErrorResponse&) const = default;
};

/// \brief Request to create a namespace.
Expand All @@ -75,6 +79,8 @@ struct ICEBERG_REST_EXPORT CreateNamespaceRequest {

/// \brief Validates the CreateNamespaceRequest.
Status Validate() const { return {}; }

bool operator==(const CreateNamespaceRequest&) const = default;
};

/// \brief Update or delete namespace properties request.
Expand All @@ -91,6 +97,8 @@ struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesRequest {
}
return {};
}

bool operator==(const UpdateNamespacePropertiesRequest&) const = default;
};

/// \brief Request to register a table.
Expand All @@ -111,6 +119,8 @@ struct ICEBERG_REST_EXPORT RegisterTableRequest {

return {};
}

bool operator==(const RegisterTableRequest&) const = default;
};

/// \brief Request to rename a table.
Expand All @@ -124,6 +134,8 @@ struct ICEBERG_REST_EXPORT RenameTableRequest {
ICEBERG_RETURN_UNEXPECTED(destination.Validate());
return {};
}

bool operator==(const RenameTableRequest&) const = default;
};

/// \brief An opaque token that allows clients to make use of pagination for list APIs.
Expand All @@ -143,6 +155,8 @@ struct ICEBERG_REST_EXPORT LoadTableResult {
}
return {};
}

bool operator==(const LoadTableResult&) const = default;
};

/// \brief Alias of LoadTableResult used as the body of CreateTableResponse
Expand All @@ -158,6 +172,8 @@ struct ICEBERG_REST_EXPORT ListNamespacesResponse {

/// \brief Validates the ListNamespacesResponse.
Status Validate() const { return {}; }

bool operator==(const ListNamespacesResponse&) const = default;
};

/// \brief Response body after creating a namespace.
Expand All @@ -167,6 +183,8 @@ struct ICEBERG_REST_EXPORT CreateNamespaceResponse {

/// \brief Validates the CreateNamespaceResponse.
Status Validate() const { return {}; }

bool operator==(const CreateNamespaceResponse&) const = default;
};

/// \brief Response body for loading namespace properties.
Expand All @@ -176,6 +194,8 @@ struct ICEBERG_REST_EXPORT GetNamespaceResponse {

/// \brief Validates the GetNamespaceResponse.
Status Validate() const { return {}; }

bool operator==(const GetNamespaceResponse&) const = default;
};

/// \brief Response body after updating namespace properties.
Expand All @@ -186,6 +206,8 @@ struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesResponse {

/// \brief Validates the UpdateNamespacePropertiesResponse.
Status Validate() const { return {}; }

bool operator==(const UpdateNamespacePropertiesResponse&) const = default;
};

/// \brief Response body for listing tables in a namespace.
Expand All @@ -195,6 +217,8 @@ struct ICEBERG_REST_EXPORT ListTablesResponse {

/// \brief Validates the ListTablesResponse.
Status Validate() const { return {}; }

bool operator==(const ListTablesResponse&) const = default;
};

} // namespace iceberg::rest
70 changes: 0 additions & 70 deletions src/iceberg/test/rest_json_internal_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/

#include <string>
#include <unordered_map>
#include <vector>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
Expand All @@ -33,74 +31,6 @@

namespace iceberg::rest {

// TODO(gangwu): perhaps add these equality operators to the types themselves?
bool operator==(const CreateNamespaceRequest& lhs, const CreateNamespaceRequest& rhs) {
return lhs.namespace_.levels == rhs.namespace_.levels &&
lhs.properties == rhs.properties;
}

bool operator==(const UpdateNamespacePropertiesRequest& lhs,
const UpdateNamespacePropertiesRequest& rhs) {
return lhs.removals == rhs.removals && lhs.updates == rhs.updates;
}

bool operator==(const RegisterTableRequest& lhs, const RegisterTableRequest& rhs) {
return lhs.name == rhs.name && lhs.metadata_location == rhs.metadata_location &&
lhs.overwrite == rhs.overwrite;
}

bool operator==(const CreateNamespaceResponse& lhs, const CreateNamespaceResponse& rhs) {
return lhs.namespace_.levels == rhs.namespace_.levels &&
lhs.properties == rhs.properties;
}

bool operator==(const GetNamespaceResponse& lhs, const GetNamespaceResponse& rhs) {
return lhs.namespace_.levels == rhs.namespace_.levels &&
lhs.properties == rhs.properties;
}

bool operator==(const ListNamespacesResponse& lhs, const ListNamespacesResponse& rhs) {
if (lhs.namespaces.size() != rhs.namespaces.size()) return false;
for (size_t i = 0; i < lhs.namespaces.size(); ++i) {
if (lhs.namespaces[i].levels != rhs.namespaces[i].levels) return false;
}
return lhs.next_page_token == rhs.next_page_token;
}

bool operator==(const UpdateNamespacePropertiesResponse& lhs,
const UpdateNamespacePropertiesResponse& rhs) {
return lhs.updated == rhs.updated && lhs.removed == rhs.removed &&
lhs.missing == rhs.missing;
}

bool operator==(const ListTablesResponse& lhs, const ListTablesResponse& rhs) {
if (lhs.identifiers.size() != rhs.identifiers.size()) return false;
for (size_t i = 0; i < lhs.identifiers.size(); ++i) {
if (lhs.identifiers[i].ns.levels != rhs.identifiers[i].ns.levels ||
lhs.identifiers[i].name != rhs.identifiers[i].name) {
return false;
}
}
return lhs.next_page_token == rhs.next_page_token;
}

bool operator==(const RenameTableRequest& lhs, const RenameTableRequest& rhs) {
return lhs.source.ns.levels == rhs.source.ns.levels &&
lhs.source.name == rhs.source.name &&
lhs.destination.ns.levels == rhs.destination.ns.levels &&
lhs.destination.name == rhs.destination.name;
}

bool operator==(const CatalogConfig& lhs, const CatalogConfig& rhs) {
return lhs.overrides == rhs.overrides && lhs.defaults == rhs.defaults &&
lhs.endpoints == rhs.endpoints;
}

bool operator==(const ErrorResponse& lhs, const ErrorResponse& rhs) {
return lhs.message == rhs.message && lhs.type == rhs.type && lhs.code == rhs.code &&
lhs.stack == rhs.stack;
}

// Test parameter structure for roundtrip tests
template <typename Model>
struct JsonRoundTripParam {
Expand Down
Loading