You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2021/10/21 00:01:24 UTC

[GitHub] [drill] cgivre commented on issue #2343: [QUESTION] Java API to access parquet from AWS S3

cgivre commented on issue #2343:
URL: https://github.com/apache/drill/issues/2343#issuecomment-948122550


   I think something like this is what you're looking for.  You'll need to first set up your Drill instance to query your S3 bucket in the way described in the docs.  You'll also need to put Drill's JDBC driver somewhere where java can find it. 
   
   One thing to be careful of is just putting the driver in the same classpath that Drill uses as that will cause runtime issues. 
   
   ```java
   import java.sql.Connection;
   import java.sql.DriverManager;
   import java.sql.ResultSet;
   import java.sql.Statement;
   
   public class testDrillInterface {
     public static void main(String[] args) {
       try{
         //Choose the driver
         Class.forName("org.apache.drill.jdbc.Driver");
         
         //Create the Connection object
         Connection connection=DriverManager 
                      .getConnection("jdbc:drill:drillbit=localhost:31010");
         
         //Create the Statement object
         Statement st = connection.createStatement();
         
         //Execute the query 
         ResultSet rs = st.executeQuery("SELECT * from cp.`employees.json`");
         
         //Iterate through the results
         while(rs.next()){
           System.out.println(rs.getString(1));
         }
       } catch(Exception e){
         throw new RuntimeException(e);
       }
     }
   }
   ```
   
   (Code snippet from [_Learning Apache Drill_](https://www.amazon.com/Learning-Apache-Drill-Analyze-Distributed/dp/1492032794/ref=sr_1_1?dchild=1&keywords=learning+apache+drill&qid=1634774423&qsid=146-1523766-4835035&sr=8-1&sres=1492032794%2CB000URL296%2CB01NCNLLWD%2CB007YCMCIA%2CB00ET5VMTU%2C1617290238%2CB082VY8XXC%2CB0725YT69J%2CB006V6YAPI%2CB072JCG7XD%2CB014QUP0FE%2CB074PYYM51%2C1617292222%2CB083T58PKM%2CB00IJ0ALYS%2CB01N1YU6FD%2CB082VYDRXP%2C1925979318%2CB08FRJJS3B%2CB005NNF0YU) by Charles GIvre and Paul Rogers)  
   


-- 
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: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org