0

I am trying to connect to redshift from notebook, so far i have done following -

Configured metadata for the notebook

"customDeps": [
   "com.databricks:spark-redshift_2.10:3.0.0-preview1",
   "com.databricks:spark-avro_2.11:3.2.0",
   "com.databricks:spark-csv_2.11:1.5.0"
]

Checked browser console to ensure this library is loaded after restarting kernel

ui-logs-1422> [Tue Aug 22 2017 09:46:26 GMT+0530 (IST)] [notebook.util.CoursierDeps$] Fetched artifact to:/Users/xxxx/.m2/repository/com/databricks/spark-avro_2.10/3.0.0/spark-avro_2.10-3.0.0.jar
kernel.js:978 ui-logs-1452> [Tue Aug 22 2017 09:46:26 GMT+0530 (IST)] [notebook.util.CoursierDeps$] Fetched artifact to:/Users/xxxx/.coursier/cache/v1/http/repo1.maven.org/maven2/com/databricks/spark-redshift_2.10/3.0.0-preview1/spark-redshift_2.10-3.0.0-preview1.jar
kernel.js:978 ui-logs-1509> [Tue Aug 22 2017 09:46:26 GMT+0530 (IST)] [notebook.util.CoursierDeps$] Fetched artifact to:/Users/xxxx/.coursier/cache/v1/http/repo1.maven.org/maven2/com/databricks/spark-csv_2.11/1.5.0/spark-csv_2.11-1.5.0.jar
kernel.js:978 ui-logs-1526> [Tue Aug 22 2017 09:46:26 GMT+0530 (IST)] [notebook.util.CoursierDeps$] Fetched artifact to:/Users/xxxx/.coursier/cache/v1/http/repo1.maven.org/maven2/com/databricks/spark-avro_2.11/3.2.0/spark-avro_2.11-3.2.0.jar
When i try to load a table - i run into class not found exception,
java.lang.ClassNotFoundException: Failed to find data source: com.databricks.spark.redshift. Please find packages at http://spark.apache.org/third-party-projects.html
  at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:594)
  at org.apache.spark.sql.execution.datasources.DataSource.providingClass$lzycompute(DataSource.scala:86)
  at org.apache.spark.sql.execution.datasources.DataSource.providingClass(DataSource.scala:86)
  at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:325)
  at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:152)
  at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:125)
  ... 63 elided
Caused by: java.lang.ClassNotFoundException: com.databricks.spark.redshift.DefaultSource
  at scala.reflect.internal.util.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:62)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$25$$anonfun$apply$13.apply(DataSource.scala:579)
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$25$$anonfun$apply$13.apply(DataSource.scala:579)
  at scala.util.Try$.apply(Try.scala:192)
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$25.apply(DataSource.scala:579)
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$25.apply(DataSource.scala:579)
  at scala.util.Try.orElse(Try.scala:84)
  at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:579)

Anyone else running into this issue or have solved this?

I notice similar issue with another dependency as well, is there any thing missing in the configuration?

Trying out timeseries sample in the notebook - notebooks/timeseries/Spark-Timeseries.snb.ipynb Notice an existing entry in metadata for custom dependency -

"customDeps": [
    "com.cloudera.sparkts % sparkts % 0.3.0"
  ]

Quickly verified availability of this package @ https://spark-packages.org/package/sryza/spark-timeseries (updated meta data to include this line)

"com.cloudera.sparkts:sparkts:0.4.1"

After restarting kernel - validated library is loaded

ui-logs-337> [Wed Aug 23 2017 09:29:25 GMT+0530 (IST)] [notebook.util.CoursierDeps$] Will fetch these customDeps artifacts:Set(Dependency(com.cloudera.sparkts:sparkts,0.3.0,,Set(),Attributes(,),false,true), Dependency(com.cloudera.sparkts:sparkts,0.4.1,,Set(),Attributes(,),false,true))
kernel.js:978 ui-logs-347> [Wed Aug 23 2017 09:29:37 GMT+0530 (IST)] [notebook.util.CoursierDeps$] Fetched artifact to:/Users/xxxx/.coursier/cache/v1/http/repo1.maven.org/maven2/com/cloudera/sparkts/sparkts/0.4.1/sparkts-0.4.1.jar
Error message -

<console>:69: error: object cloudera is not a member of package com
       import com.cloudera.sparkts._
                  ^
<console>:70: error: object cloudera is not a member of package com
       import com.cloudera.sparkts.stats.TimeSeriesStatisticalTests
Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49
Guruprasad
  • 41
  • 6

2 Answers2

0

Downlaoded another version of spark-notebook(this wasnt from master branch).

spark-notebook-0.7.0-scala-2.11.8-spark-2.1.1-hadoop-2.7.2 
against 
spark-notebook-0.9.0-SNAPSHOT-scala-2.11.8-spark-2.1.1-hadoop-2.7.2

In addition i had to ensure scala, spark & hadoop versions are intact across dependencies i have configured. In this particular example i had to set jar file for amazon JDBC redshift driver from command line, as this was not available at maven repository.

export EXTRA_CLASSPATH=RedshiftJDBC4-1.2.7.1003.jar

Hope this helps others

Guruprasad
  • 41
  • 6
0

If you want, you can add the jar to the kernel's environment section "env" (EXTRA_CLASSPATH) like this:

cat /usr/local/share/jupyter/kernels/apache_toree_scala/kernel.json
{
  "argv": [
    "/usr/local/share/jupyter/kernels/apache_toree_scala/bin/run.sh",
    "--profile",
    "{connection_file}"
  ],
  "interrupt_mode": "signal",
  "env": {
    "__TOREE_SPARK_OPTS__": "",
    "PYTHONPATH": "/opt/cloudera/parcels/SPARK2/lib/spark2/python:/opt/cloudera/parcels/SPARK2/lib/spark2/python/lib/py4j-0.10.7-src.zip",
    "__TOREE_OPTS__": "",
    "PYTHON_EXEC": "python",
    "SPARK_HOME": "/opt/cloudera/parcels/SPARK2/lib/spark2",
    "DEFAULT_INTERPRETER": "Scala",
    "JAVA_HOME": "/usr/java/latest",
    "EXTRA_CLASSPATH": "/opt/cloudera/parcels/SPARK2/lib/spark2/jars/mysql-connector-java-5.1.15.jar"
  },
  "metadata": {},
  "display_name": "SPARK2/Scala",
  "language": "scala"
}
mdivk
  • 3,545
  • 8
  • 53
  • 91