如何在databricks集群中安装spark-redis相关的jar?

发布于 2025-01-13 00:52:11 字数 1128 浏览 1 评论 0原文

我正在尝试从 databricks 连接到 Azure redis 缓存。

我已经从 databricks 中的 maven 包安装了这个包 com.redislabs:spark-redis:2.3.0 。我使用下面的代码创建了一个 Spark 会话

SparkSession\
.builder\
.appName("myApp")\ 
.config("spark.redis.host", "my host")\ 
.config("spark.redis.port", "6379")\
.config("spark.redis.auth", "passwd")\ 
.getOrCreate()

但是当我运行 df.write.format("org.apache.spark.sql.redis").option("table", "people").option("key .column", "name").save()

我收到以下错误。

*Py4JJavaError: An error occurred while calling o390.save.
: java.lang.ClassNotFoundException: 
Failed to find data source: org.apache.spark.sql.redis. Please find packages at
http://spark.apache.org/third-party-projects.html*

您能否让我知道安装所有必要的库/jar 以访问 databricks 中的 redis 的详细步骤。

我在 spark-redis python doc 但我不知道如何在 databricks 中运行它。

$ ./bin/pyspark --jars <path-to>/spark-redis-<version>-jar-with-dependencies.jar

另外请告诉我最新的 Spark-Redis 版本是什么。

I am trying to connect to Azure cache for redis from databricks .

I have installed this package com.redislabs:spark-redis:2.3.0 from maven package in databricks. I have created a spark session with below code

SparkSession\
.builder\
.appName("myApp")\ 
.config("spark.redis.host", "my host")\ 
.config("spark.redis.port", "6379")\
.config("spark.redis.auth", "passwd")\ 
.getOrCreate()

But when I ran df.write.format("org.apache.spark.sql.redis").option("table", "people").option("key.column", "name").save()

I am getting below error.

*Py4JJavaError: An error occurred while calling o390.save.
: java.lang.ClassNotFoundException: 
Failed to find data source: org.apache.spark.sql.redis. Please find packages at
http://spark.apache.org/third-party-projects.html*

Could you please let me know the detailed steps to install all necessary libraries/jars to access redis in databricks.

I have seen below code in spark-redis python doc but I don't know how to run it in databricks.

$ ./bin/pyspark --jars <path-to>/spark-redis-<version>-jar-with-dependencies.jar

And also please let me know what is the latest spark-redis version.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们的影子 2025-01-20 00:52:11

Redis 有一个 Spark 包,您可以将其下载并附加到您的集群

Redis 有一个 Spark 包,您可以下载它并将其 : 笔记本展示了如何在 Azure Databricks 中将 Redis 与 Apache Spark 结合使用。

有关更多详细信息,请参阅Azure Databricks - Redis。

Redis has a Spark Package that you can download and attach to your cluster

The following notebook shows how to use Redis with Apache Spark in Azure Databricks.

For more details, refer to Azure Databricks - Redis.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文