我在尝试使用databricks-connect
并依赖于 Maven 安装的扩展在 Databricks 上运行一些 Python 代码时遇到问题(在这种情况下com.microsoft.azure:azure-eventhubs-spark_2.11:2.3.17
,可以在Databricks 与 Azure EventHub 集成的官方文档中找到
关于与 的连接databricks-connect
,一切都设置得很好(通过 获得“所有测试通过” databricks-connect test
)。Maven 包com.microsoft.azure:azure-eventhubs-spark_2.11:2.3.17
似乎在我的集群的库部分中“已安装”)。
错误的代码是这个简单的一行:
encrypted_string = sc._jvm.org.apache.spark.eventhubs.EventHubsUtils.encrypt(to_be_encrypted_string)
产生以下错误堆栈:
INFO - Receiving data from EventHub using Databricks' PySpark...
20/09/29 17:50:57 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
20/09/29 17:50:59 WARN MetricsSystem: Using default name SparkStatusTracker for source because neither spark.metrics.namespace nor spark.app.id is set.
Traceback (most recent call last):
File "C:\Users\my_user\Desktop\projectABC\src\my_folder\my_project\cli.py", line 86, in <module>
connector()
File "C:\Users\my_user\Desktop\projectABC\.venv\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:\Users\my_user\Desktop\projectABC\.venv\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Users\my_user\Desktop\projectABC\.venv\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\my_user\Desktop\projectABC\.venv\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\my_user\Desktop\projectABC\.venv\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\my_user\Desktop\projectABC\.venv\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Users\my_user\Desktop\projectABC\src\my_folder\my_project\cli.py", line 43, in test_data_process
prediction_connector.process_upstream_data()
File "c:\users\my_user\Desktop\projectABC\src\my_folder\my_project\command.py", line 224, in process_upstream_data
df = eventhub_consumer.receive_data_with_pyspark()
File "c:\users\my_user\Desktop\projectABC\src\my_folder\my_project\command.py", line 406, in receive_data_with_pyspark
eventhub_config = self._populate_pyspark_eventhub_config_file(spark_context=sc)
File "c:\users\my_user\Desktop\projectABC\src\my_folder\my_project\command.py", line 428, in _populate_pyspark_eventhub_config_file
eventhub_config = {'eventhubs.connectionString': spark_context._jvm.org.apache.spark.eventhubs.EventHubsUtils.encrypt(self.config.connection_string)}
TypeError: 'JavaPackage' object is not callable
我在这里遗漏了一些关于 Maven 包安装的明显内容吗?与 Python 一起使用它是否有额外的步骤?谢谢你的帮助 !