From 74b1e9448ab36854bde65a8026420cce1b0f32d6 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Wed, 15 Feb 2023 17:18:38 -0800 Subject: [PATCH] Add `explain` request handlers. Signed-off-by: Yury-Fridlyand --- .../opensearch/sql/executor/execution/PaginatedPlan.java | 3 ++- sql/src/main/java/org/opensearch/sql/sql/SQLService.java | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/opensearch/sql/executor/execution/PaginatedPlan.java b/core/src/main/java/org/opensearch/sql/executor/execution/PaginatedPlan.java index 62c913ee67..36b1b23e5e 100644 --- a/core/src/main/java/org/opensearch/sql/executor/execution/PaginatedPlan.java +++ b/core/src/main/java/org/opensearch/sql/executor/execution/PaginatedPlan.java @@ -39,6 +39,7 @@ public void execute() { @Override public void explain(ResponseListener listener) { - throw new UnsupportedOperationException("implement PaginatedPlan.explain"); + listener.onFailure(new UnsupportedOperationException( + "`explain` feature for paginated requests is not implemented yet.")); } } diff --git a/sql/src/main/java/org/opensearch/sql/sql/SQLService.java b/sql/src/main/java/org/opensearch/sql/sql/SQLService.java index 0912bf3482..908f03e4f2 100644 --- a/sql/src/main/java/org/opensearch/sql/sql/SQLService.java +++ b/sql/src/main/java/org/opensearch/sql/sql/SQLService.java @@ -67,6 +67,12 @@ private AbstractPlan plan( Optional> explainListener) { if (request.getCursor().isPresent()) { // Handle v2 cursor here -- legacy cursor was handled earlier. + if (queryListener.isEmpty() && explainListener.isPresent()) { // explain request + explainListener.get().onFailure(new UnsupportedOperationException( + "`explain` request for cursor requests is not supported. " + + "Use `explain` for the initial query request.")); + } + // non-explain request return queryExecutionFactory.create(request.getCursor().get(), queryListener.get()); } else { // 1.Parse query and convert parse tree (CST) to abstract syntax tree (AST)