Skip to content

Commit 8a8264d

Browse files
committed
redo the fix for ppl too
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
1 parent 14a1f3d commit 8a8264d

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

plugin/src/main/java/org/opensearch/sql/plugin/request/PPLQueryRequestFactory.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,24 @@ private static PPLQueryRequest parsePPLRequestFromPayload(RestRequest restReques
5959
boolean pretty = getPrettyOption(restRequest.params());
6060
try {
6161
jsonContent = new JSONObject(content);
62+
PPLQueryRequest pplRequest =
63+
new PPLQueryRequest(
64+
jsonContent.getString(PPL_FIELD_NAME),
65+
jsonContent,
66+
restRequest.path(),
67+
format.getFormatName());
68+
// set sanitize option if csv format
69+
if (format.equals(Format.CSV)) {
70+
pplRequest.sanitize(getSanitizeOption(restRequest.params()));
71+
}
72+
// set pretty option
73+
if (pretty) {
74+
pplRequest.style(JsonResponseFormatter.Style.PRETTY);
75+
}
76+
return pplRequest;
6277
} catch (JSONException e) {
6378
throw new IllegalArgumentException("Failed to parse request payload", e);
6479
}
65-
PPLQueryRequest pplRequest =
66-
new PPLQueryRequest(
67-
jsonContent.getString(PPL_FIELD_NAME),
68-
jsonContent,
69-
restRequest.path(),
70-
format.getFormatName());
71-
// set sanitize option if csv format
72-
if (format.equals(Format.CSV)) {
73-
pplRequest.sanitize(getSanitizeOption(restRequest.params()));
74-
}
75-
// set pretty option
76-
if (pretty) {
77-
pplRequest.style(JsonResponseFormatter.Style.PRETTY);
78-
}
79-
return pplRequest;
8080
}
8181

8282
private static Format getFormat(Map<String, String> requestParams, String path) {

plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLQueryAction.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import java.util.Set;
1717
import org.apache.logging.log4j.LogManager;
1818
import org.apache.logging.log4j.Logger;
19-
import org.json.JSONException;
2019
import org.opensearch.OpenSearchException;
2120
import org.opensearch.core.action.ActionListener;
2221
import org.opensearch.core.rest.RestStatus;
@@ -60,8 +59,7 @@ private static boolean isClientError(Exception e) {
6059
|| e instanceof QueryEngineException
6160
|| e instanceof SyntaxCheckException
6261
|| e instanceof DataSourceClientException
63-
|| e instanceof IllegalAccessException
64-
|| e instanceof JSONException;
62+
|| e instanceof IllegalAccessException;
6563
}
6664

6765
@Override

0 commit comments

Comments
 (0)