You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2022/02/24 17:25:19 UTC

[GitHub] [drill] cgivre opened a new pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

cgivre opened a new pull request #2474:
URL: https://github.com/apache/drill/pull/2474


   # [DRILL-8140](https://issues.apache.org/jira/browse/DRILL-8140): Add JSON Post Body to HTTP Rest Storage Plugin
   
   ## Description
   This PR allows the user to control where parameters are pushed down during `POST` requests.  The choices are:
   * `query_string`:  `POST` parameters (both filters and static) are pushed to the query string. 
   * `post_body`: `POST` parameters (both filters and static) are pushed to the post body as key/value pairs
   * `json_body`: `POST` parameters (both filters and static) are pushed to the post body as JSON.
   
   The user can set this by adding the `postParameterLocation` parameter to an API configuration.  The default is `query_string`. 
   
   ## Documentation
   
   ### Set the POST destination
   The user can set the destination and format of POST parameters by adding the `postParameterLocation` parameter to an API configuration.  The default is `query_string`. 
   
   The choices are:
   * `query_string`:  `POST` parameters (both filters and static) are pushed to the query string. 
   * `post_body`: `POST` parameters (both filters and static) are pushed to the post body as key/value pairs
   * `json_body`: `POST` parameters (both filters and static) are pushed to the post body as JSON.
   
   ## Testing
   Added unit tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] cgivre commented on a change in pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

Posted by GitBox <gi...@apache.org>.
cgivre commented on a change in pull request #2474:
URL: https://github.com/apache/drill/pull/2474#discussion_r818613526



##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/util/SimpleHttp.java
##########
@@ -88,8 +92,9 @@
   private final CustomErrorContext errorContext;
   private final Paginator paginator;
   private final HttpUrl url;
-  private final StoragePluginRegistry registry;
   private final PersistentTokenTable tokenTable;
+  private final Map<String,String> filters;

Review comment:
       Fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] cgivre commented on a change in pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

Posted by GitBox <gi...@apache.org>.
cgivre commented on a change in pull request #2474:
URL: https://github.com/apache/drill/pull/2474#discussion_r816846371



##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpApiConfig.java
##########
@@ -271,6 +282,10 @@ private HttpApiConfig(HttpApiConfig.HttpApiConfigBuilder builder) {
     // Accept either basic or none.  The default is none.
     this.authType = StringUtils.defaultIfEmpty(builder.authType, "none");
     this.postBody = builder.postBody;
+
+    // Default to query string to avoid breaking changes
+    this.postParameterLocation = StringUtils.defaultIfEmpty(builder.postParameterLocation.trim().toLowerCase(), QUERY_STRING_POST_LOCATION);

Review comment:
       @luocooong I addressed all your comments and updated the documentation.  This should be ready to go.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] cgivre commented on a change in pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

Posted by GitBox <gi...@apache.org>.
cgivre commented on a change in pull request #2474:
URL: https://github.com/apache/drill/pull/2474#discussion_r818611058



##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpBatchReader.java
##########
@@ -218,6 +219,14 @@ protected HttpUrl buildUrl() {
   protected void addFilters(Builder urlBuilder, List<String> params,
       Map<String, String> filters) {
 
+    // If the request is a POST query and the user selected to push the filters to either JSON body
+    // or the post body, do not add to the query string.
+    if (subScan.tableSpec().connectionConfig().getMethodType() == HttpApiConfig.HttpMethod.POST &&
+      (subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.POST_BODY_POST_LOCATION) ||

Review comment:
       Fixed

##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpBatchReader.java
##########
@@ -218,6 +219,14 @@ protected HttpUrl buildUrl() {
   protected void addFilters(Builder urlBuilder, List<String> params,
       Map<String, String> filters) {
 
+    // If the request is a POST query and the user selected to push the filters to either JSON body
+    // or the post body, do not add to the query string.
+    if (subScan.tableSpec().connectionConfig().getMethodType() == HttpApiConfig.HttpMethod.POST &&
+      (subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.POST_BODY_POST_LOCATION) ||
+        subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.JSON_BODY_POST_LOCATION))

Review comment:
       Fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] cgivre merged pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

Posted by GitBox <gi...@apache.org>.
cgivre merged pull request #2474:
URL: https://github.com/apache/drill/pull/2474


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] cgivre commented on a change in pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

Posted by GitBox <gi...@apache.org>.
cgivre commented on a change in pull request #2474:
URL: https://github.com/apache/drill/pull/2474#discussion_r816439185



##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpBatchReader.java
##########
@@ -218,6 +219,14 @@ protected HttpUrl buildUrl() {
   protected void addFilters(Builder urlBuilder, List<String> params,
       Map<String, String> filters) {
 
+    // If the request is a POST query and the user selected to push the filters to either JSON body
+    // or the post body, do not add to the query string.
+    if (subScan.tableSpec().connectionConfig().getMethodType() == HttpApiConfig.HttpMethod.POST &&
+      (subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.POST_BODY_POST_LOCATION) ||
+        subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.JSON_BODY_POST_LOCATION) )

Review comment:
       Fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] cgivre commented on a change in pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

Posted by GitBox <gi...@apache.org>.
cgivre commented on a change in pull request #2474:
URL: https://github.com/apache/drill/pull/2474#discussion_r816438686



##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpApiConfig.java
##########
@@ -172,6 +179,8 @@ public HttpPaginatorConfig paginator() {
     return this.paginator;
   }
 
+  public String getPostParameterLocation() { return postParameterLocation; }

Review comment:
       Fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] luocooong commented on a change in pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

Posted by GitBox <gi...@apache.org>.
luocooong commented on a change in pull request #2474:
URL: https://github.com/apache/drill/pull/2474#discussion_r818409982



##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/util/SimpleHttp.java
##########
@@ -88,8 +92,9 @@
   private final CustomErrorContext errorContext;
   private final Paginator paginator;
   private final HttpUrl url;
-  private final StoragePluginRegistry registry;
   private final PersistentTokenTable tokenTable;
+  private final Map<String,String> filters;

Review comment:
       ```suggestion
     private final Map<String, String> filters;
   ```

##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpBatchReader.java
##########
@@ -218,6 +219,14 @@ protected HttpUrl buildUrl() {
   protected void addFilters(Builder urlBuilder, List<String> params,
       Map<String, String> filters) {
 
+    // If the request is a POST query and the user selected to push the filters to either JSON body
+    // or the post body, do not add to the query string.
+    if (subScan.tableSpec().connectionConfig().getMethodType() == HttpApiConfig.HttpMethod.POST &&
+      (subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.POST_BODY_POST_LOCATION) ||

Review comment:
       ```suggestion 
         (subScan.tableSpec().connectionConfig().getPostLocation() == PostLocation.POST_BODY) ||
   ```

##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpBatchReader.java
##########
@@ -218,6 +219,14 @@ protected HttpUrl buildUrl() {
   protected void addFilters(Builder urlBuilder, List<String> params,
       Map<String, String> filters) {
 
+    // If the request is a POST query and the user selected to push the filters to either JSON body
+    // or the post body, do not add to the query string.
+    if (subScan.tableSpec().connectionConfig().getMethodType() == HttpApiConfig.HttpMethod.POST &&
+      (subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.POST_BODY_POST_LOCATION) ||
+        subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.JSON_BODY_POST_LOCATION))

Review comment:
       ```suggestion
           subScan.tableSpec().connectionConfig().getPostLocation() == PostLocation.JSON_BODY
   ```

##########
File path: contrib/storage-http/README.md
##########
@@ -137,6 +137,11 @@ postBody: "key1=value1
 key2=value2"
 ```
 
+`postBodyLocation`:  If the API uses the `POST` method, you can send parameters in several different ways:

Review comment:
       Thanks for the updating the docs.

##########
File path: contrib/storage-http/src/test/java/org/apache/drill/exec/store/http/TestHttpPlugin.java
##########
@@ -1218,6 +1260,211 @@ public void testHeaders() throws Exception {
     }
   }
 
+  @Test
+  public void testJsonPostWithMockServer() throws Exception {
+    try (MockWebServer server = startServer()) {
+      server.enqueue(
+        new MockResponse()
+          .setResponseCode(200)
+          .setBody(TEST_JSON_RESPONSE)
+      );
+
+      String sql = "SELECT * FROM local.mockJsonPost";
+      RowSet results = client.queryBuilder().sql(sql).rowSet();
+
+      TupleMetadata expectedSchema = new SchemaBuilder()
+        .addMap("results")
+        .add("sunrise", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("sunset", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("solar_noon", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("day_length", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("civil_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("civil_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("nautical_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("nautical_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("astronomical_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("astronomical_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .resumeSchema()
+        .add("status", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .build();
+
+      RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema)
+        .addRow(mapValue("6:13:58 AM", "5:59:55 PM", "12:06:56 PM", "11:45:57", "5:48:14 AM", "6:25:38 PM", "5:18:16 AM", "6:55:36 PM", "4:48:07 AM", "7:25:45 PM"), "OK")
+        .build();
+
+      RowSetUtilities.verify(expected, results);
+
+      RecordedRequest recordedRequest = server.takeRequest();
+      assertEquals("POST", recordedRequest.getMethod());
+      String resultJsonString = recordedRequest.getBody().toString();
+      assertEquals("[text={\"key1\":\"value1\",\"key2\":\"value2\"}]", resultJsonString);
+    }
+  }
+
+  @Test
+  public void testJsonPostWithFiltersAndMockServer() throws Exception {
+    try (MockWebServer server = startServer()) {
+      server.enqueue(
+        new MockResponse()
+          .setResponseCode(200)
+          .setBody(TEST_JSON_RESPONSE)
+      );
+
+      String sql = "SELECT * FROM local.mockJsonPost WHERE lat=36.7201600 AND lng=-4.4203400";
+      RowSet results = client.queryBuilder().sql(sql).rowSet();
+
+      TupleMetadata expectedSchema = new SchemaBuilder()
+        .addMap("results")
+        .add("sunrise", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("sunset", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("solar_noon", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("day_length", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("civil_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("civil_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("nautical_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("nautical_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("astronomical_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("astronomical_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .resumeSchema()
+        .add("status", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .build();
+
+      RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema)
+        .addRow(mapValue("6:13:58 AM", "5:59:55 PM", "12:06:56 PM", "11:45:57", "5:48:14 AM", "6:25:38 PM", "5:18:16 AM", "6:55:36 PM", "4:48:07 AM", "7:25:45 PM"), "OK")
+        .build();
+
+      RowSetUtilities.verify(expected, results);
+
+      RecordedRequest recordedRequest = server.takeRequest();
+      assertEquals("POST", recordedRequest.getMethod());
+      String resultJsonString = recordedRequest.getBody().toString();
+      assertEquals("[size=71 text={\"key1\":\"value1\",\"key2\":\"value2\",\"lng\":\"-4.4203400\",\"lat\":\"36.72…]", resultJsonString);
+    }
+  }
+
+  @Test
+  public void testJsonPostWithFiltersAndNullPostBodyMockServer() throws Exception {
+    try (MockWebServer server = startServer()) {
+      server.enqueue(
+        new MockResponse()
+          .setResponseCode(200)
+          .setBody(TEST_JSON_RESPONSE)
+      );
+
+      String sql = "SELECT * FROM local.mockJsonNullBodyPost WHERE lat=36.7201600 AND lng=-4.4203400";
+      RowSet results = client.queryBuilder().sql(sql).rowSet();
+
+      TupleMetadata expectedSchema = new SchemaBuilder()
+        .addMap("results")
+        .add("sunrise", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("sunset", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("solar_noon", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("day_length", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("civil_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("civil_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("nautical_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("nautical_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("astronomical_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("astronomical_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .resumeSchema()
+        .add("status", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .build();
+
+      RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema)
+        .addRow(mapValue("6:13:58 AM", "5:59:55 PM", "12:06:56 PM", "11:45:57", "5:48:14 AM", "6:25:38 PM", "5:18:16 AM", "6:55:36 PM", "4:48:07 AM", "7:25:45 PM"), "OK")
+        .build();
+
+      RowSetUtilities.verify(expected, results);
+
+      RecordedRequest recordedRequest = server.takeRequest();
+      assertEquals("POST", recordedRequest.getMethod());
+      String resultJsonString = recordedRequest.getBody().toString();
+      assertEquals("[text={\"lng\":\"-4.4203400\",\"lat\":\"36.7201600\"}]", resultJsonString);
+    }
+  }
+
+  @Test
+  public void testParamsInPostBody() throws Exception {
+    try (MockWebServer server = startServer()) {
+      server.enqueue(
+        new MockResponse()
+          .setResponseCode(200)
+          .setBody(TEST_JSON_RESPONSE)
+      );
+
+      String sql = "SELECT * FROM local.mockPostPushdown WHERE lat=36.7201600 AND lng=-4.4203400";
+      RowSet results = client.queryBuilder().sql(sql).rowSet();
+
+      TupleMetadata expectedSchema = new SchemaBuilder()
+        .addMap("results")
+        .add("sunrise", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("sunset", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("solar_noon", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("day_length", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("civil_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("civil_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("nautical_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("nautical_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("astronomical_twilight_begin", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .add("astronomical_twilight_end", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .resumeSchema()
+        .add("status", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL)
+        .build();
+
+      RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema)
+        .addRow(mapValue("6:13:58 AM", "5:59:55 PM", "12:06:56 PM", "11:45:57", "5:48:14 AM", "6:25:38 PM", "5:18:16 AM", "6:55:36 PM", "4:48:07 AM", "7:25:45 PM"), "OK")
+        .build();
+
+      RowSetUtilities.verify(expected, results);
+
+      RecordedRequest recordedRequest = server.takeRequest();
+      assertEquals("POST", recordedRequest.getMethod());
+      String resultJsonString = recordedRequest.getBody().toString();
+      assertEquals("[text=lng=-4.4203400&lat=36.7201600]", resultJsonString);
+    }
+  }
+
+  @Test
+  public void testParamsInPostBodyAndStaticParams() throws Exception {

Review comment:
       Thanks for adding these great unit tests.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] luocooong commented on a change in pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

Posted by GitBox <gi...@apache.org>.
luocooong commented on a change in pull request #2474:
URL: https://github.com/apache/drill/pull/2474#discussion_r815848665



##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpApiConfig.java
##########
@@ -172,6 +179,8 @@ public HttpPaginatorConfig paginator() {
     return this.paginator;
   }
 
+  public String getPostParameterLocation() { return postParameterLocation; }

Review comment:
       It is recommended that the code style be consistent.
   ```suggestion
     public String postParameterLocation() {
       return this.postParameterLocation;
     }
   ```

##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpBatchReader.java
##########
@@ -218,6 +219,14 @@ protected HttpUrl buildUrl() {
   protected void addFilters(Builder urlBuilder, List<String> params,
       Map<String, String> filters) {
 
+    // If the request is a POST query and the user selected to push the filters to either JSON body
+    // or the post body, do not add to the query string.
+    if (subScan.tableSpec().connectionConfig().getMethodType() == HttpApiConfig.HttpMethod.POST &&
+      (subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.POST_BODY_POST_LOCATION) ||
+        subScan.tableSpec().connectionConfig().getPostParameterLocation().equalsIgnoreCase(HttpApiConfig.JSON_BODY_POST_LOCATION) )

Review comment:
       There is an extra whitespace.

##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpApiConfig.java
##########
@@ -271,6 +282,10 @@ private HttpApiConfig(HttpApiConfig.HttpApiConfigBuilder builder) {
     // Accept either basic or none.  The default is none.
     this.authType = StringUtils.defaultIfEmpty(builder.authType, "none");
     this.postBody = builder.postBody;
+
+    // Default to query string to avoid breaking changes
+    this.postParameterLocation = StringUtils.defaultIfEmpty(builder.postParameterLocation.trim().toLowerCase(), QUERY_STRING_POST_LOCATION);

Review comment:
       Is it possible to use enum type to define the `postParameterLocation` like `method` variable? In this case, we can compare values using an '==' instead of using postParameterLocation().equalsIgnoreCase().
   ```java
   public enum PostParameterLocation {
     // query_string, json_body, post_body
   }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [drill] cgivre commented on a change in pull request #2474: DRILL-8140: Add JSON Post Body to HTTP Rest Storage Plugin

Posted by GitBox <gi...@apache.org>.
cgivre commented on a change in pull request #2474:
URL: https://github.com/apache/drill/pull/2474#discussion_r816834060



##########
File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpApiConfig.java
##########
@@ -271,6 +282,10 @@ private HttpApiConfig(HttpApiConfig.HttpApiConfigBuilder builder) {
     // Accept either basic or none.  The default is none.
     this.authType = StringUtils.defaultIfEmpty(builder.authType, "none");
     this.postBody = builder.postBody;
+
+    // Default to query string to avoid breaking changes
+    this.postParameterLocation = StringUtils.defaultIfEmpty(builder.postParameterLocation.trim().toLowerCase(), QUERY_STRING_POST_LOCATION);

Review comment:
       Thanks @luocooong !  I changed this to an `enum` type.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org