Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.calcite.sql.validate.SqlUserDefinedFunction;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.OpenSearchTimeoutException;
import org.opensearch.sql.ast.statement.Explain.ExplainFormat;
import org.opensearch.sql.calcite.CalcitePlanContext;
import org.opensearch.sql.calcite.utils.CalciteToolsHelper.OpenSearchRelRunners;
Expand Down Expand Up @@ -215,6 +216,11 @@ public void execute(
buildResultSet(
result, rel.getRowType(), context.sysLimit.querySizeLimit(), listener);
} catch (SQLException e) {
if (e.getCause() instanceof OpenSearchTimeoutException) {
// Special case: execution failed due to timing, not other generic runtime
// issues
throw (OpenSearchTimeoutException) e.getCause();
}
throw new RuntimeException(e);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import javax.annotation.Nullable;
import org.opensearch.OpenSearchTimeoutException;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.exception.NonFallbackCalciteException;
import org.opensearch.sql.opensearch.client.OpenSearchClient;
Expand Down Expand Up @@ -104,11 +105,16 @@ private OpenSearchResponse getCurrentResponse(OpenSearchRequest request) {
if (isAsync()) {
try {
return nextBatchFuture.get();
} catch (InterruptedException | ExecutionException e) {
} catch (ExecutionException e) {
throw new NonFallbackCalciteException(
"Failed to fetch data from the index: the background task failed or interrupted.\n"
+ " Inner error: "
+ e.getMessage());
} catch (InterruptedException e) {
throw new OpenSearchTimeoutException(
new InterruptedException(
"Execution of the index search timed out. Increase the timeout via the"
+ " `ppl.query.timeout` setting."));
}
} else {
return client.search(request);
Expand Down
Loading