Skip to content

Commit 5fa69f2

Browse files
LantaoJinxinyual
authored andcommitted
Execute Calcite PPL query in thread pool (#3508)
Signed-off-by: Lantao Jin <[email protected]> Signed-off-by: xinyual <[email protected]>
1 parent f96d7ab commit 5fa69f2

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
@@ -113,17 +113,19 @@ public ExplainResponseNode visitTableScan(
113113
@Override
114114
public void execute(
115115
RelNode rel, CalcitePlanContext context, ResponseListener<QueryResponse> listener) {
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-
return null;
123-
} catch (SQLException e) {
124-
throw new RuntimeException(e);
125-
}
126-
});
116+
client.schedule(
117+
() ->
118+
AccessController.doPrivileged(
119+
(PrivilegedAction<Void>)
120+
() -> {
121+
try (PreparedStatement statement = OpenSearchRelRunners.run(context, rel)) {
122+
ResultSet result = statement.executeQuery();
123+
buildResultSet(result, rel.getRowType(), listener);
124+
} catch (SQLException e) {
125+
listener.onFailure(e);
126+
}
127+
return null;
128+
}));
127129
}
128130

129131
private void buildResultSet(

0 commit comments

Comments
 (0)