You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@zeppelin.apache.org by Antall Fernandes <an...@gmail.com> on 2015/10/12 18:31:24 UTC

Re: How to add Postgres / Redshidt jdbc driver dependency to Zipplein

This should help you out.

z.load("<path>/RedshiftJDBC41-1.1.2.0002.jar")
import org.apache.spark.sql.SQLContext
val host = sys.env("REDSHIFT_HOST")
val port = sys.env("REDSHIFT_PORT")
val username = sys.env("REDSHIFT_USERNAME")
val password = sys.env("REDSHIFT_PASSWORD")
val database = sys.env("REDSHIFT_DATABASE")
val url= List("jdbc:redshift://", host, ":", port, "/", database).mkString

val sqlSC = new SQLContext(sc)
val sql = "<query>"

val options = Map(
  "driver" -> "com.amazon.redshift.jdbc41.Driver",
  "user" -> username,
  "password" -> password,
  "url" -> url,
  "numPartitions" -> "5",
  "dbTable" -> List("(", sql, ") as dbTable").mkString
)

val result = sqlSC.read.format("jdbc").options(options).load()
result.show()

On Fri, Sep 18, 2015 at 5:11 AM, shahab <sh...@gmail.com> wrote:

> Hi,
>
> I am quite new to Zeppelin. And I would like to query Redshift database
> using data frames.
>
> I just wonder how I can add required JDBC driver to Zeppelin?Any example?
>
> best,
> /Shahab
>