diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/PrettyFormatRestExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/PrettyFormatRestExecutor.java index 5f758e7d87..f79051b92e 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/PrettyFormatRestExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/PrettyFormatRestExecutor.java @@ -134,7 +134,9 @@ private Protocol buildProtocolForDefaultQuery(Client client, DefaultQueryAction private boolean isDefaultCursor(SearchResponse searchResponse, DefaultQueryAction queryAction) { if (LocalClusterState.state().getSettingValue(SQL_PAGINATION_API_SEARCH_AFTER)) { - if (searchResponse.getHits().getTotalHits().value < queryAction.getSqlRequest().fetchSize()) { + if (queryAction.getSqlRequest().fetchSize() == 0 + || searchResponse.getHits().getTotalHits().value + < queryAction.getSqlRequest().fetchSize()) { return false; } else { return true; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java index c589edcf50..e5011d1af8 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java @@ -99,6 +99,7 @@ public void run() throws IOException, SqlParseException { this.metaResults.setTookImMilli(joinTimeInMilli); } catch (Exception e) { LOG.error("Failed during join query run.", e); + throw new IllegalStateException("Error occurred during join query run", e); } finally { if (LocalClusterState.state().getSettingValue(SQL_PAGINATION_API_SEARCH_AFTER)) { try {