55
66package org .opensearch .sql .sql ;
77
8- import static org .opensearch .sql .legacy .TestUtils .getResponseBody ;
98import static org .opensearch .sql .legacy .TestUtils .isIndexExist ;
109import static org .opensearch .sql .util .MatcherUtils .rows ;
1110import static org .opensearch .sql .util .MatcherUtils .schema ;
1615import org .json .JSONObject ;
1716import org .junit .Test ;
1817import org .opensearch .client .Request ;
19- import org .opensearch .client .RequestOptions ;
20- import org .opensearch .client .Response ;
2118import org .opensearch .client .ResponseException ;
2219import org .opensearch .sql .legacy .SQLIntegTestCase ;
2320
@@ -57,17 +54,9 @@ private void createParquetLogsIndex() throws IOException {
5754 client ().performRequest (request );
5855 }
5956
60- private JSONObject executeSqlQuery (String sql ) throws IOException {
61- Request request = new Request ("POST" , "/_plugins/_sql" );
62- request .setJsonEntity ("{\" query\" : \" " + sql + "\" }" );
63- request .setOptions (RequestOptions .DEFAULT );
64- Response response = client ().performRequest (request );
65- return new JSONObject (getResponseBody (response ));
66- }
67-
6857 @ Test
6958 public void testSelectStarSchemaAndData () throws IOException {
70- JSONObject result = executeSqlQuery ("SELECT * FROM parquet_logs" );
59+ JSONObject result = executeQuery ("SELECT * FROM parquet_logs" );
7160 verifySchema (
7261 result ,
7362 schema ("ip_addr" , "string" ),
@@ -85,7 +74,7 @@ public void testSelectStarSchemaAndData() throws IOException {
8574
8675 @ Test
8776 public void testSelectSpecificColumns () throws IOException {
88- JSONObject result = executeSqlQuery ("SELECT status, message FROM parquet_logs" );
77+ JSONObject result = executeQuery ("SELECT status, message FROM parquet_logs" );
8978 verifySchema (result , schema ("status" , "integer" ), schema ("message" , "string" ));
9079 verifyDataRows (
9180 result ,
@@ -96,6 +85,6 @@ public void testSelectSpecificColumns() throws IOException {
9685
9786 @ Test (expected = ResponseException .class )
9887 public void testSyntaxError () throws IOException {
99- executeSqlQuery ("SELEC * FROM parquet_logs" );
88+ executeQuery ("SELEC * FROM parquet_logs" );
10089 }
10190}
0 commit comments