在emr上设置jupyter以使用cql读取cassandra?

bnlyeluc  于 2021-07-14  发布在  Spark
关注(0)|答案(0)|浏览(271)

当我试着用

import os
os.environ['PYSPARK_SUBMIT_ARGS'] = '--packages datastax:spark-cassandra-connector:2.4.0-s_2.11 --conf spark.cassandra.connection.host=x.x.x.x pyspark-shell'

spark = SparkSession.builder \
  .appName('SparkCassandraApp') \
  .config('spark.cassandra.connection.host', 'x.x.x.x') \
  .config('spark.cassandra.connection.port', 'xxxx') \
  .config('spark.cassandra.output.consistency.level','ONE') \
  .master('local[2]') \
  .getOrCreate()

我仍然无法用代码连接到cassandra集群

dataFrame = spark.read.format("org.apache.spark.sql.cassandra").option("keyspace", "keyspace").option("table", "table").load()
dataFrame = dataFrame.limit(100)
dataFrame.show()

出现错误:

An error was encountered:
An error occurred while calling o103.load.
: java.lang.ClassNotFoundException: Failed to find data source: org.apache.spark.sql.cassandra. 
Please find packages at http://spark.apache.org/third-party-projects.html

这里提出了一个类似的问题:修改jupyter内核以在spark中添加cassandra连接
但我没有看到一个有效的答案。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题