You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2013/09/02 00:22:16 UTC

[15/18] git commit: Updates to fix SQL Handler issues. Add simple full query jdbc test execution (no results checking)

Updates to fix SQL Handler issues.  Add simple full query jdbc test execution (no results checking)


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/89eb9457
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/89eb9457
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/89eb9457

Branch: refs/heads/master
Commit: 89eb9457420ef444aafa867d77453bb293ae6ec8
Parents: d3b2f9f
Author: Jacques Nadeau <ja...@apache.org>
Authored: Sun Sep 1 08:38:41 2013 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Sun Sep 1 15:16:22 2013 -0700

----------------------------------------------------------------------
 .../org/apache/drill/jdbc/DrillHandler.java     | 30 +++++++++++---------
 .../apache/drill/optiq/DrillImplementor.java    |  2 +-
 .../apache/drill/jdbc/test/FullEngineTest.java  | 16 ++++++-----
 .../org/apache/drill/jdbc/test/JdbcAssert.java  | 13 ++++++++-
 4 files changed, 38 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/89eb9457/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java
index 6cc25e0..380993b 100644
--- a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java
+++ b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java
@@ -68,20 +68,6 @@ public class DrillHandler extends HandlerImpl {
         String enginesData = Resources.toString(Resources.getResource("storage-engines.json"), Charsets.UTF_8);
 
         StorageEngines engines = config.getMapper().readValue(enginesData, StorageEngines.class);
-        MutableSchema rootSchema = connection.getRootSchema();
-
-        for (Map.Entry<String, StorageEngineConfig> entry : engines) {
-          SchemaProvider provider = registry.getSchemaProvider(entry.getValue());
-          FileSystemSchema schema = new FileSystemSchema(client, entry.getValue(), provider,
-              rootSchema.getTypeFactory(), rootSchema, entry.getKey(), rootSchema.getExpression(),
-              rootSchema.getQueryProvider());
-          rootSchema.addSchema(entry.getKey(), schema);
-        }
-
-        rootSchema.addSchema(
-            "--FAKE--",
-            new FakeSchema(rootSchema, rootSchema.getQueryProvider(), rootSchema.getTypeFactory(), "fake", rootSchema
-                .getExpression()));
 
         if (zk != null) {
           coordinator = new ZKClusterCoordinator(config, zk);
@@ -100,6 +86,22 @@ public class DrillHandler extends HandlerImpl {
           cl.connect();
           client = cl;
         }
+        
+        MutableSchema rootSchema = connection.getRootSchema();
+
+        for (Map.Entry<String, StorageEngineConfig> entry : engines) {
+          SchemaProvider provider = registry.getSchemaProvider(entry.getValue());
+          FileSystemSchema schema = new FileSystemSchema(client, entry.getValue(), provider,
+              rootSchema.getTypeFactory(), rootSchema, entry.getKey(), rootSchema.getExpression(),
+              rootSchema.getQueryProvider());
+          rootSchema.addSchema(entry.getKey(), schema);
+        }
+
+        rootSchema.addSchema(
+            "--FAKE--",
+            new FakeSchema(rootSchema, rootSchema.getQueryProvider(), rootSchema.getTypeFactory(), "fake", rootSchema
+                .getExpression()));
+        
       } catch (Exception ex) {
         throw new SQLException("Failure trying to connect to Drill.", ex);
       }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/89eb9457/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillImplementor.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillImplementor.java b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillImplementor.java
index 27b9630..0a9e28c 100644
--- a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillImplementor.java
+++ b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillImplementor.java
@@ -91,7 +91,7 @@ public class DrillImplementor {
   }
   
   public void registerSource(DrillTable table){
-    if(tables.add(table)){
+    if(!table.isRefEngine() && tables.add(table)){
       sourcesNode.put(table.getStorageEngineName(), mapper.convertValue(table.getStorageEngineConfig(), JsonNode.class));  
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/89eb9457/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java
index c3bd51d..e88dc0d 100644
--- a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java
+++ b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java
@@ -13,7 +13,7 @@ import org.junit.rules.Timeout;
 import com.google.common.base.Charsets;
 import com.google.common.io.Resources;
 
-@Ignore
+
 public class FullEngineTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(FullEngineTest.class);
 
@@ -25,16 +25,18 @@ public class FullEngineTest {
   // Set a timeout unless we're debugging.
   @Rule public TestRule globalTimeout = IS_DEBUG ? new TestName() : new Timeout(10000);
   
-  @BeforeClass
-  public static void setupFixtures() throws IOException {
-    MODEL_FULL_ENGINE = Resources.toString(Resources.getResource("full-model.json"), Charsets.UTF_8);
-  }
+//  @BeforeClass
+//  public static void setupFixtures() throws IOException {
+//    MODEL_FULL_ENGINE = Resources.toString(Resources.getResource("full-model.json"), Charsets.UTF_8);
+//  }
+  
+  
   
   @Test
   public void fullSelectStarEngine() throws Exception {
-    JdbcAssert.withModel(MODEL_FULL_ENGINE, "DONUTS")
+    JdbcAssert.withFull("parquet-local")
     // .sql("select cast(_MAP['red'] as bigint) + 1 as red_inc from donuts ")
-        .sql("select _MAP['d'] as d, _MAP['b'] as b from \"parquet-local\".\"/tmp/parquet_test_file_many_types\" ").displayResults(50);
+        .sql("select _MAP['d'] as d, _MAP['b'] as b from \"/tmp/parquet_test_file_many_types\" ").displayResults(50);
   }
 
 //  @Test

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/89eb9457/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
index d3927f4..54af383 100644
--- a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
+++ b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
@@ -47,6 +47,12 @@ public class JdbcAssert {
     return new ModelAndSchema(info);
   }
 
+  public static ModelAndSchema withFull(String schema) {
+    final Properties info = new Properties();
+    info.setProperty("schema", schema);
+    return new ModelAndSchema(info, false);
+  }
+
   
   static String toString(ResultSet resultSet, int expectedRecordCount) throws SQLException {
     StringBuilder buf = new StringBuilder();
@@ -109,11 +115,16 @@ public class JdbcAssert {
     private final ConnectionFactory connectionFactory;
 
     public ModelAndSchema(Properties info) {
+      this(info, true);
+    }
+    
+    public ModelAndSchema(Properties info, final boolean ref) {
       this.info = info;
       this.connectionFactory = new ConnectionFactory() {
         public Connection createConnection() throws Exception {
           Class.forName("org.apache.drill.jdbc.Driver");
-          return DriverManager.getConnection("jdbc:drill:ref=true", ModelAndSchema.this.info);
+          String connect = ref ? "jdbc:drill:ref=true" : "jdbc:drill:";
+          return DriverManager.getConnection(connect, ModelAndSchema.this.info);  
         }
       };
     }