如何从特定事件中心分区 Spark-Streaming 结构读取

问题描述 投票:0回答:1

我有一个具有 32 个分区的事件中心。 我需要使用 Pyspark 从事件中心读取分区 1。

这是我现有的代码

# Config
connectionString = "Endpoint=sb://abcd"
eventHubName = "event_hub"

ehConf = {
  'eventhubs.connectionString' : sc._jvm.org.apache.spark.eventhubs.EventHubsUtils.encrypt(connectionString),
  'eventhubs.eventHubName': eventHubName
}
df_stream  = spark.readStream.format("eventhubs")\
  .options(**ehConf)\
  .option("compression", "gzip") \
  .load() 

请建议我们如何阅读。

pyspark spark-structured-streaming azure-eventhub
1个回答
0
投票

这应该有效

df_stream  = spark.readStream.format("eventhubs")\
  .options(**ehConf)\
  .option("partitionId", 1)\
  .load() 
© www.soinside.com 2019 - 2024. All rights reserved.