将外部罐装入spark-notebook失败

时间:2017-08-23 07:04:32

标签: spark-notebook

我正在尝试从笔记本连接到redshift,到目前为止我已经完成了以下操作 -

配置笔记本电脑的元数据

"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"
]

选中浏览器控制台以确保在重新启动内核

后加载此库
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)

其他人遇到此问题或已解决此问题?

我也注意到了另一个依赖项的类似问题,配置中是否缺少任何内容?

在笔记本中试用时间序列示例 - notebooks / timeseries / Spark-Timeseries.snb.ipynb 请注意自定义依赖项的元数据中的现有条目 -

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

快速验证此套餐的可用性@ https://spark-packages.org/package/sryza/spark-timeseries (更新了包含此行的元数据)

"com.cloudera.sparkts:sparkts:0.4.1"

重新启动内核后,已加载验证的库

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

2 个答案:

答案 0 :(得分:0)

下载另一个版本的spark-notebook(这不是来自master分支)。

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

此外,我必须确保scala,spark&amp; amp; hadoop版本在我配置的依赖项中完好无损。 在这个特定的例子中,我不得不从命令行为amazon JDBC redshift驱动程序设置jar文件,因为这在maven存储库中不可用。

export EXTRA_CLASSPATH=RedshiftJDBC4-1.2.7.1003.jar

希望这有助于其他人

答案 1 :(得分:0)

如果需要,可以将jar添加到内核的环境部分“ env”( EXTRA_CLASSPATH ),如下所示:

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"
}