Databricks与Azure事件中心连接

问题描述

在尝试使用databricks-connect并根据Maven安装的扩展名(在这种情况下,com.microsoft.azure:azure-eventhubs-spark_2.11:2.3.17Databricks official documentation for integration with Azure EventHub上)在Databricks上运行一些Python代码时,我遇到了问题

关于与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 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上使用它还有额外的步骤吗?感谢您的帮助!

解决方法

功能有一些limitations

不支持以下Databricks功能和第三方平台:

  • 以下Databricks实用程序:凭证,库,笔记本工作流和小部件。
  • 结构化流(包括Azure事件中心)
  • 在远程集群上运行不是Spark作业一部分的任意代码。
  • 用于Delta表操作的本地Scala,Python和R API(例如,DeltaTable.forPath)。但是,都支持带有Delta Lake操作的SQL API(spark.sql(...))和Delta表上的常规Spark API(例如spark.read.load)。

此外,使用Databricks Connect,您还必须将所有库都放在本地类路径中。典型的情况是将所有非Spark依赖项打包到jar-with-dependencies中。