File tree Expand file tree Collapse file tree
plugin/src/main/java/org/opensearch/sql/plugin Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff line change 1616import java .util .Set ;
1717import org .apache .logging .log4j .LogManager ;
1818import org .apache .logging .log4j .Logger ;
19- import org .json .JSONException ;
2019import org .opensearch .OpenSearchException ;
2120import org .opensearch .core .action .ActionListener ;
2221import 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
You can’t perform that action at this time.
0 commit comments