Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions contrib/storage-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ on 400 series errors, `false` will return an empty result set (with implicit fie
Default is `true`, but when set to false, Drill will trust all SSL certificates. Useful for debugging or on internal corporate networks using self-signed certificates or
private certificate authorities.

#### caseSensitiveFilters
Some APIs are case sensitive with the fields which are pushed down. If the endpoint that you are working with is in fact case sensitive, simply set this to `true`. Defaults to `false`.

## Usage

This plugin is different from other plugins in that it the table component of the `FROM` clause
Expand Down Expand Up @@ -577,9 +580,9 @@ ORDER BY issue_count DESC
you may encounter errors or empty responses if you are counting on the endpoint for
redirection.

2. At this time, the plugin does not support any authentication other than basic authentication.
~~2. At this time, the plugin does not support any authentication other than basic authentication.~~

3. This plugin does not implement join filter pushdowns (only constant plushdowns are
3. This plugin does not implement join filter pushdowns (only constant pushdowns are
supported). Join pushdown has the potential to improve performance if you use the HTTP service
joined to another table.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public class HttpApiConfig {
@JsonProperty
private final boolean errorOn400;

@JsonProperty
private final boolean caseSensitiveFilters;

// Enables the user to configure JSON options at the connection level rather than globally.
@JsonProperty
private final HttpJsonOptions jsonOptions;
Expand Down Expand Up @@ -157,6 +160,10 @@ public String inputType() {
return this.inputType;
}

public boolean caseSensitiveFilters() {
return this.caseSensitiveFilters;
}

public int xmlDataLevel() {
return this.xmlDataLevel;
}
Expand Down Expand Up @@ -199,6 +206,7 @@ public boolean equals(Object o) {
&& errorOn400 == that.errorOn400
&& verifySSLCert == that.verifySSLCert
&& directCredentials == that.directCredentials
&& caseSensitiveFilters == that.caseSensitiveFilters
&& Objects.equals(url, that.url)
&& Objects.equals(method, that.method)
&& Objects.equals(postBody, that.postBody)
Expand All @@ -218,7 +226,7 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(url, requireTail, method, postBody, headers, params, dataPath,
authType, inputType, xmlDataLevel, limitQueryParam, errorOn400, jsonOptions, verifySSLCert,
credentialsProvider, paginator, directCredentials, postParameterLocation);
credentialsProvider, paginator, directCredentials, postParameterLocation, caseSensitiveFilters);
}

@Override
Expand All @@ -232,6 +240,7 @@ public String toString() {
.field("headers", headers)
.field("params", params)
.field("dataPath", dataPath)
.field("caseSensitiveFilters", caseSensitiveFilters)
.field("authType", authType)
.field("inputType", inputType)
.field("xmlDataLevel", xmlDataLevel)
Expand Down Expand Up @@ -328,6 +337,7 @@ private HttpApiConfig(HttpApiConfig.HttpApiConfigBuilder builder) {

this.xmlDataLevel = Math.max(1, builder.xmlDataLevel);
this.errorOn400 = builder.errorOn400;
this.caseSensitiveFilters = builder.caseSensitiveFilters;
this.credentialsProvider = CredentialProviderUtils.getCredentialsProvider(builder.userName, builder.password, builder.credentialsProvider);
this.directCredentials = builder.credentialsProvider == null;

Expand Down Expand Up @@ -422,7 +432,7 @@ public static class HttpApiConfigBuilder {
private String authType;

private int xmlDataLevel;

private boolean caseSensitiveFilters;
private String limitQueryParam;

private boolean errorOn400;
Expand Down Expand Up @@ -489,6 +499,11 @@ public HttpApiConfigBuilder url(String url) {
return this;
}

public HttpApiConfigBuilder caseSensitiveFilters(boolean caseSensitiveFilters) {
this.caseSensitiveFilters = caseSensitiveFilters;
return this;
}

public HttpApiConfigBuilder method(String method) {
this.method = method;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.drill.exec.store.http.util.SimpleHttp;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -175,7 +176,13 @@ private boolean acceptType(MinorType type) {
*/
@Override
public Pair<GroupScan, List<RexNode>> transform(AndNode andNode) {
Map<String, String> filters = CaseInsensitiveMap.newHashMap();
Map<String, String> filters;
if (groupScan.getHttpConfig().caseSensitiveFilters()) {
filters = new HashMap<>();
} else {
filters = CaseInsensitiveMap.newHashMap();
}

double selectivity = 1;
for (ExprNode expr : andNode.children) {
ColRelOpConstNode relOp = (ColRelOpConstNode) expr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.drill.common.exceptions.EmptyErrorContext;
import org.apache.drill.common.logical.OAuthConfig;
import org.apache.drill.common.logical.StoragePluginConfig.AuthMode;
import org.apache.drill.common.map.CaseInsensitiveMap;
import org.apache.drill.common.exceptions.CustomErrorContext;
import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.exec.ExecConstants;
Expand Down Expand Up @@ -712,7 +711,6 @@ public static String mapURLParameters(HttpUrl url, Map<String, String> filters)
.message("API Query with URL Parameters must be populated.")
.build(logger);
}
CaseInsensitiveMap<String>caseInsensitiveFilterMap = (CaseInsensitiveMap<String>)filters;

List<String> params = SimpleHttp.getURLParameters(url);
String tempUrl = SimpleHttp.decodedURL(url);
Expand All @@ -726,7 +724,7 @@ public static String mapURLParameters(HttpUrl url, Map<String, String> filters)
// of providing helpful errors in strange cases, it is there.


String value = caseInsensitiveFilterMap.get(param);
String value = filters.get(param);

// Check and see if there is a default for this parameter. If not throw an error.
if (StringUtils.isEmpty(value)) {
Expand Down