aboutsummaryrefslogtreecommitdiff
path: root/contrib/storage-jdbc/src
diff options
context:
space:
mode:
authorVolodymyr Vysotskyi <vvovyk@gmail.com>2018-11-13 15:21:39 +0200
committerVolodymyr Vysotskyi <vvovyk@gmail.com>2018-11-26 11:22:16 +0200
commitb67f77a18ac4b67044fa9b4b962d0536fdc54af5 (patch)
tree1c7529691cfac2ea44829f2a5d7c164f06067437 /contrib/storage-jdbc/src
parent1c087237a5a23e9c97cf5318e34f0c8c58ec7af6 (diff)
DRILL-6850: Force setting DRILL_LOGICAL Convention for DrillRelFactories and DrillFilterRel
- Fix workspace case insensitivity for JDBC storage plugin
Diffstat (limited to 'contrib/storage-jdbc/src')
-rwxr-xr-xcontrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java21
-rw-r--r--contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java9
2 files changed, 15 insertions, 15 deletions
diff --git a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
index b0338cb85..cd9a6c45c 100755
--- a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
+++ b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
@@ -22,6 +22,8 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -59,13 +61,12 @@ import org.apache.drill.exec.server.DrillbitContext;
import org.apache.drill.exec.store.AbstractSchema;
import org.apache.drill.exec.store.AbstractStoragePlugin;
import org.apache.drill.exec.store.SchemaConfig;
+import org.apache.drill.exec.store.SchemaFactory;
import org.apache.drill.exec.store.jdbc.DrillJdbcRuleBase.DrillJdbcFilterRule;
import org.apache.drill.exec.store.jdbc.DrillJdbcRuleBase.DrillJdbcProjectRule;
import org.apache.drill.shaded.guava.com.google.common.base.Joiner;
-import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableSet;
-import org.apache.drill.shaded.guava.com.google.common.collect.Maps;
public class JdbcStoragePlugin extends AbstractStoragePlugin {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(JdbcStoragePlugin.class);
@@ -157,10 +158,10 @@ public class JdbcStoragePlugin extends AbstractStoragePlugin {
}
/**
- * Returns whether a condition is supported by {@link JdbcJoin}.
+ * Returns whether a condition is supported by {@link org.apache.calcite.adapter.jdbc.JdbcRules.JdbcJoin}.
*
* <p>Corresponds to the capabilities of
- * {@link SqlImplementor#convertConditionToSqlNode}.
+ * {@link org.apache.calcite.rel.rel2sql.SqlImplementor#convertConditionToSqlNode}.
*
* @param node Condition
* @return Whether condition is supported
@@ -234,7 +235,7 @@ public class JdbcStoragePlugin extends AbstractStoragePlugin {
private class CapitalizingJdbcSchema extends AbstractSchema {
- final Map<String, CapitalizingJdbcSchema> schemaMap = Maps.newHashMap();
+ private final Map<String, CapitalizingJdbcSchema> schemaMap = new HashMap<>();
private final JdbcSchema inner;
public CapitalizingJdbcSchema(List<String> parentSchemaPath, String name, DataSource dataSource,
@@ -299,11 +300,11 @@ public class JdbcStoragePlugin extends AbstractStoragePlugin {
private class JdbcCatalogSchema extends AbstractSchema {
- private final Map<String, CapitalizingJdbcSchema> schemaMap = Maps.newHashMap();
+ private final Map<String, CapitalizingJdbcSchema> schemaMap = new HashMap<>();
private final CapitalizingJdbcSchema defaultSchema;
public JdbcCatalogSchema(String name) {
- super(ImmutableList.<String> of(), name);
+ super(Collections.emptyList(), name);
try (Connection con = source.getConnection();
ResultSet set = con.getMetaData().getCatalogs()) {
@@ -311,7 +312,7 @@ public class JdbcStoragePlugin extends AbstractStoragePlugin {
final String catalogName = set.getString(1);
CapitalizingJdbcSchema schema = new CapitalizingJdbcSchema(
getSchemaPath(), catalogName, source, dialect, convention, catalogName, null);
- schemaMap.put(catalogName, schema);
+ schemaMap.put(schema.getName(), schema);
}
} catch (SQLException e) {
logger.warn("Failure while attempting to load JDBC schema.", e);
@@ -325,7 +326,7 @@ public class JdbcStoragePlugin extends AbstractStoragePlugin {
if (!schemasAdded) {
// there were no schemas, just create a default one (the jdbc system doesn't support catalogs/schemas).
- schemaMap.put("default", new CapitalizingJdbcSchema(ImmutableList.<String> of(), name, source, dialect,
+ schemaMap.put(SchemaFactory.DEFAULT_WS_NAME, new CapitalizingJdbcSchema(Collections.emptyList(), name, source, dialect,
convention, null, null));
}
} else {
@@ -360,7 +361,7 @@ public class JdbcStoragePlugin extends AbstractStoragePlugin {
convention, catalogName, schemaName);
// if a catalog schema doesn't exist, we'll add this at the top level.
- schemaMap.put(schemaName, schema);
+ schemaMap.put(schema.getName(), schema);
} else {
CapitalizingJdbcSchema schema = new CapitalizingJdbcSchema(parentSchema.getSchemaPath(), schemaName,
source, dialect,
diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java
index 65a1ea564..a22b40aef 100644
--- a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java
+++ b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java
@@ -20,7 +20,6 @@ package org.apache.drill.exec.store.jdbc;
import org.apache.drill.categories.JdbcStorageTest;
import org.apache.drill.PlanTestBase;
import org.apache.drill.exec.expr.fn.impl.DateUtility;
-import org.apache.drill.exec.proto.UserBitShared;
import org.apache.drill.exec.util.StoragePluginTestUtils;
import org.junit.BeforeClass;
@@ -126,14 +125,14 @@ public class TestJdbcPluginWithDerbyIT extends PlanTestBase {
@Test
public void showTablesDefaultSchema() throws Exception {
- test("use derby");
- assertEquals(1, testRunAndPrint(UserBitShared.QueryType.SQL, "show tables like 'person'"));
+ testNoResult("use derby.drill_derby_test");
+ assertEquals(1, testSql("show tables like 'PERSON'"));
}
@Test
public void describe() throws Exception {
- test("use derby");
- assertEquals(19, testRunAndPrint(UserBitShared.QueryType.SQL, "describe drill_derby_test.person"));
+ testNoResult("use derby.drill_derby_test");
+ assertEquals(19, testSql("describe PERSON"));
}
@Test