wgtmac commented on code in PR #438:
URL: https://github.com/apache/iceberg-cpp/pull/438#discussion_r2647566627
##########
src/iceberg/catalog/rest/rest_catalog.cc:
##########
@@ -294,24 +301,75 @@ Result<std::shared_ptr<Transaction>>
RestCatalog::StageCreateTable(
return NotImplemented("Not implemented");
}
-Status RestCatalog::DropTable([[maybe_unused]] const TableIdentifier&
identifier,
- [[maybe_unused]] bool purge) {
- return NotImplemented("Not implemented");
+Result<bool> RestCatalog::DropTable(const TableIdentifier& identifier, bool
purge) {
+ ICEBERG_RETURN_UNEXPECTED(CheckEndpoint(supported_endpoints_,
Endpoint::DeleteTable()));
+ ICEBERG_ASSIGN_OR_RAISE(auto path, paths_->Table(identifier));
+
+ std::unordered_map<std::string, std::string> params;
+ if (purge) {
+ params["purgeRequested"] = "true";
+ }
+ auto response_or_error =
+ client_->Delete(path, params, /*headers=*/{},
*TableErrorHandler::Instance());
+ if (!response_or_error.has_value()) {
+ const auto& error = response_or_error.error();
+ if (error.kind == ErrorKind::kNoSuchTable) {
+ return false;
+ }
+ ICEBERG_RETURN_UNEXPECTED(response_or_error);
+ }
+ return true;
}
-Result<bool> RestCatalog::TableExists(
- [[maybe_unused]] const TableIdentifier& identifier) const {
- return NotImplemented("Not implemented");
+Result<bool> RestCatalog::TableExists(const TableIdentifier& identifier) const
{
+ auto check = CheckEndpoint(supported_endpoints_, Endpoint::TableExists());
+ if (!check.has_value()) {
+ // Fall back to LoadTable endpoint (GET)
+ ICEBERG_ASSIGN_OR_RAISE(auto path, paths_->Table(identifier));
Review Comment:
Please reuse `LoadTable` instead of calling the client.
--
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]