Open shfshihuafeng opened 10 months ago
we should determines whether the parameter name equals the plug-in name ?
--- a/contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpSchemaFactory.java
+++ b/contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpSchemaFactory.java
@@ -18,8 +18,11 @@
package org.apache.drill.exec.store.http;
import java.util.Collections;
+import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.Table;
@@ -85,7 +88,7 @@ public class HttpSchemaFactory extends AbstractSchemaFactory {
HttpAPIConnectionSchema subSchema = subSchemas.get(name);
if (subSchema != null) {
return subSchema;
- } else if (tables.containsKey(name)) {
+ } else if (tables.containsKey(name) || isRegistryPluginName(name.toLowerCase(Locale.ROOT))) {
return null;
} else {
throw UserException
@@ -95,6 +98,12 @@ public class HttpSchemaFactory extends AbstractSchemaFactory {
}
}
+ private boolean isRegistryPluginName(String name) {
+ Set<String> pluginNames = plugin.getRegistry().availablePlugins();
+ Set<String> pluginNamesToLower = pluginNames.stream().map(String::toLowerCase).collect(Collectors.toSet());
+ return pluginNamesToLower.contains(name);
+ }
@shfshihuafeng I don't think this is a bug. You are first running the query USE http
which sets the root at http
. Then you're running a SELECT ... FROM http.sunrise
. So at that point, the plugin is looking for a path: http.http.sunrise
which does not exist.
I'd bet that if you either skipped the USE
query or ran a SELECT ... FROM sunrise
it would work.
@cgivre You are right, but when use http, the default schema is http, when we use another data source schema, will report error. It think this is not right.
@cgivre
@cgivre when i use "use my.test" command to switch schema, It is correct to query data with full schema Name from other data sources
@shfshihuafeng
So are you saying the behavior with USE
is inconsistent? I want to make sure I understand the issue.
@cgivre There are two problems with this
Before submitting a bug report, please verify that you are using the most current version of Drill.
Describe the bug i create a http plugin named "http" and then use "use http" command to switch schema. i query http Data with "select * from http.sunrise",It report except
To Reproduce Steps to reproduce the behavior:
Expected behavior
Error detail, log output or screenshots
Error: CONNECTION ERROR: API 'http' does not exist in HTTP storage plugin 'http'
Drill version 1.22.0
Additional context