Skip to content

Commit 652016c

Browse files
authored
Execute Calcite PPL query in thread pool (#3508)
Signed-off-by: Lantao Jin <[email protected]>
1 parent b5dda60 commit 652016c

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

opensearch/src/main/java/org/opensearch/sql/opensearch/executor/OpenSearchExecutionEngine.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,19 @@ public ExplainResponseNode visitTableScan(
111111
@Override
112112
public void execute(
113113
RelNode rel, CalcitePlanContext context, ResponseListener<QueryResponse> listener) {
114-
AccessController.doPrivileged(
115-
(PrivilegedAction<Void>)
116-
() -> {
117-
try (PreparedStatement statement = OpenSearchRelRunners.run(context, rel)) {
118-
ResultSet result = statement.executeQuery();
119-
buildResultSet(result, rel.getRowType(), listener);
120-
return null;
121-
} catch (SQLException e) {
122-
throw new RuntimeException(e);
123-
}
124-
});
114+
client.schedule(
115+
() ->
116+
AccessController.doPrivileged(
117+
(PrivilegedAction<Void>)
118+
() -> {
119+
try (PreparedStatement statement = OpenSearchRelRunners.run(context, rel)) {
120+
ResultSet result = statement.executeQuery();
121+
buildResultSet(result, rel.getRowType(), listener);
122+
} catch (SQLException e) {
123+
listener.onFailure(e);
124+
}
125+
return null;
126+
}));
125127
}
126128

127129
private void buildResultSet(

0 commit comments

Comments
 (0)