以前 CouchDB 是通过 cloudant 连接器支持的:
https://github.com/cloudant-labs/spark-cloudant
但是这个项目声明它不再活跃并且它转移到了 Apache Bahir:
http://bahir.apache.org/docs/spark/2.1.1/spark-sql-cloudant/
因此,我使用以下命令在 Scala 笔记本中安装了 JAR:
然后,从 python notebook 中,重启内核后,我使用以下代码进行测试:
spark = SparkSession\
.builder\
.appName("Cloudant Spark SQL Example in Python using dataframes")\
.config("cloudant.host","0495289b-1beb-4e6d-888e-315f36925447-bluemix.cloudant.com")\
.config("cloudant.username", "0495289b-1beb-4e6d-888e-315f36925447-bluemix")\
.config("cloudant.password","xxx")\
.config("jsonstore.rdd.partitions", 8)\
.getOrCreate()
# ***1. Loading dataframe from Cloudant db
df = spark.read.load("openspace", "org.apache.bahir.cloudant")
df.cache()
df.printSchema()
df.show()
但我得到:
java.lang.ClassNotFoundException:org.apache.bahir.cloudant.DefaultSource