rymarm commented on issue #2446:
URL: https://github.com/apache/drill/issues/2446#issuecomment-1026745794


   @GavinRay97 several months before I have found that Drill can be run in 
"embedded mode" with a pretty simple configuration. To achieve this, you need 
to add the next dependencies to your project `pom.xml`:
   ```xml
   <dependencies>
           <dependency>
               <groupId>org.apache.drill.exec</groupId>
               <artifactId>drill-java-exec</artifactId>
               <version>1.19.0</version>
               <exclusions>
                   <exclusion>
                       <groupId>org.slf4j</groupId>
                       <artifactId>log4j-over-slf4j</artifactId>
                   </exclusion>
                   <exclusion>
                       <groupId>org.slf4j</groupId>
                       <artifactId>slf4j-log4j12</artifactId>
                   </exclusion>
               </exclusions>
           </dependency>
           <dependency>
               <groupId>org.apache.drill.exec</groupId>
               <artifactId>drill-jdbc</artifactId>
               <version>1.19.0</version>
               <exclusions>
                   <exclusion>
                       <groupId>org.slf4j</groupId>
                       <artifactId>log4j-over-slf4j</artifactId>
                   </exclusion>
                   <exclusion>
                       <groupId>org.slf4j</groupId>
                       <artifactId>slf4j-log4j12</artifactId>
                   </exclusion>
               </exclusions>
           </dependency>
           <dependency>
               <groupId>com.google.guava</groupId>
               <artifactId>guava</artifactId>
               <version>21.0</version>
           </dependency>
       </dependencies>
   ```
   And after that, you will be able to run embedded Drill with the following 
example code:
   ```java
       // This part is responsible for running the embedded Drill and 
establishing a connection to it.
       // "jdbc:drill:zk=local" is connection string to run embedded Drill 
       Connection connection = 
DriverManager.getConnection("jdbc:drill:zk=local"); 
       // Example of executing simple query
       Statement st = connection.createStatement();
       // `/home/maksym/Desktop/sample.csv` is path to csv file that I've 
created for the example
       ResultSet rs = st.executeQuery("select * from 
dfs.`/home/maksym/Desktop/sample.csv`");
       while (rs.next()) {
         System.out.println(rs.getString(1));
       }
       connection.close();
   ```
   
   I didn't find exhausting information on how exactly should be configured 
application: what dependencies are required, what properties are available, and 
so on. But you can dive into code and look at how embedded mode was 
implemented. Here is the departure point:
   
https://github.com/apache/drill/blob/15b2f52260e4f0026f2dfafa23c5d32e0fb66502/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java#L104
   
   Besides this, you also find many Jira tickets that belong to issues with 
embedded Drill, here are several of them:
   [DRILL-2126](https://issues.apache.org/jira/browse/DRILL-2126),
   [DRILL-1654](https://issues.apache.org/jira/browse/DRILL-1654),
   [DRILL-1409](https://issues.apache.org/jira/browse/DRILL-1409)
   
   According to my investigation of code and manual tests, it seems, that 
embedded Drill works pretty well and the only issue is dependency conflicts, 
that is why in my example above, I added guava and excluded log jars. 
   
   I would like to gather as much information as possible about embedded Drill 
and add it to Drill documentation or make some code improvements to let users 
freely use this mode for their application. Of course, Drill was created as a 
distributed system, but Drill is so powerful tool that is also very useful even 
in single, embedded node mode. 


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to