Skip to content
Open
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
20 changes: 20 additions & 0 deletions src/iceberg/catalog/rest/endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ class ICEBERG_REST_EXPORT Endpoint {
return {HttpMethod::kPost, "/v1/{prefix}/transactions/commit"};
}

// Scan planning endpoints
static Endpoint PlanTableScan() {
return {HttpMethod::kPost, "/v1/{prefix}/namespaces/{namespace}/tables/{table}/plan"};
}

static Endpoint FetchPlanningResult() {
return {HttpMethod::kGet,
"/v1/{prefix}/namespaces/{namespace}/tables/{table}/plan/{plan-id}"};
}

static Endpoint CancelPlanning() {
return {HttpMethod::kDelete,
"/v1/{prefix}/namespaces/{namespace}/tables/{table}/plan/{plan-id}"};
}

static Endpoint FetchScanTasks() {
return {HttpMethod::kPost,
"/v1/{prefix}/namespaces/{namespace}/tables/{table}/tasks"};
}

private:
Endpoint(HttpMethod method, std::string_view path) : method_(method), path_(path) {}

Expand Down
51 changes: 51 additions & 0 deletions src/iceberg/catalog/rest/error_handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ namespace {
constexpr std::string_view kIllegalArgumentException = "IllegalArgumentException";
constexpr std::string_view kNoSuchNamespaceException = "NoSuchNamespaceException";
constexpr std::string_view kNamespaceNotEmptyException = "NamespaceNotEmptyException";
constexpr std::string_view kNoSuchTableException = "NoSuchTableException";
constexpr std::string_view kNoSuchPlanIdException = "NoSuchPlanIdException";
constexpr std::string_view kNoSuchPlanTaskException = "NoSuchPlanTaskException";

} // namespace

Expand Down Expand Up @@ -183,4 +186,52 @@ Status ViewCommitErrorHandler::Accept(const ErrorResponse& error) const {
return DefaultErrorHandler::Accept(error);
}

const std::shared_ptr<PlanErrorHandler>& PlanErrorHandler::Instance() {
static const std::shared_ptr<PlanErrorHandler> instance{new PlanErrorHandler()};
return instance;
}

Status PlanErrorHandler::Accept(const ErrorResponse& error) const {
switch (error.code) {
case 404:
if (error.type == kNoSuchNamespaceException) {
return NoSuchNamespace(error.message);
}
if (error.type == kNoSuchTableException) {
return NoSuchTable(error.message);
}
if (error.type == kNoSuchPlanIdException) {
return NoSuchPlanId(error.message);
}
return NotFound(error.message);
case 406:
return NotSupported(error.message);
}

return DefaultErrorHandler::Accept(error);
}

const std::shared_ptr<PlanTaskErrorHandler>& PlanTaskErrorHandler::Instance() {
static const std::shared_ptr<PlanTaskErrorHandler> instance{new PlanTaskErrorHandler()};
return instance;
}

Status PlanTaskErrorHandler::Accept(const ErrorResponse& error) const {
switch (error.code) {
case 404:
if (error.type == kNoSuchNamespaceException) {
return NoSuchNamespace(error.message);
}
if (error.type == kNoSuchTableException) {
return NoSuchTable(error.message);
}
if (error.type == kNoSuchPlanTaskException) {
return NoSuchPlanTask(error.message);
}
return NotFound(error.message);
}

return DefaultErrorHandler::Accept(error);
}

} // namespace iceberg::rest
22 changes: 22 additions & 0 deletions src/iceberg/catalog/rest/error_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,26 @@ class ICEBERG_REST_EXPORT ViewCommitErrorHandler final : public DefaultErrorHand
constexpr ViewCommitErrorHandler() = default;
};

/// \brief Plan operation error handler.
class ICEBERG_REST_EXPORT PlanErrorHandler final : public DefaultErrorHandler {
public:
static const std::shared_ptr<PlanErrorHandler>& Instance();

Status Accept(const ErrorResponse& error) const override;

private:
constexpr PlanErrorHandler() = default;
};

/// \brief Fetch scan tasks operation error handler.
class ICEBERG_REST_EXPORT PlanTaskErrorHandler final : public DefaultErrorHandler {
public:
static const std::shared_ptr<PlanTaskErrorHandler>& Instance();

Status Accept(const ErrorResponse& error) const override;

private:
constexpr PlanTaskErrorHandler() = default;
};

} // namespace iceberg::rest
Loading
Loading