How to connect to Drill from R using JDBC?

Document created by prasoon Employee on Feb 8, 2016
Version 1Show Document
  • View in full screen mode

Author: Prasoon Keloth

 

Original Publication Date: February 27, 2015

Goal:

How to connect to Drill from R using JDBC.

Solution:

1. Load  rJava and RJDBC from R:

library("rJava") 
library("RJDBC")

 

2. Connect to drill using drill-jdbc driver.

For example:

drv <- JDBC("org.apache.drill.jdbc.Driver","/opt/mapr/drill/drill-0.7.0/jars/jdbc-driver/drill-jdbc-all-0.7.0-SNAPSHOT.jar") 
conn <- dbConnect(drv, "jdbc:drill:zk=node1:5181,node2:5181,node3:5181/drill/MyCluster-drillbits;schema=hive")

Note:

a. The Drill JDBC driver should match the Drill version.

b. Please refer to this link for Drill JDBC URL string format:

jdbc:drill:zk=<zookeeper_quorum>/<drill_directory_in_zookeeper>/<cluster_ID>;schema=<schema_to_use_as_default>

 

3. Run query.

For example:

dbGetQuery(conn, "show tables from hive")

Attachments

    Outcomes