scala - 如何使用文件存储架构反序列化来自事件中心的 Avro 消息并存储在 Azure Databricks 的数据框中
问题描述
来自事件中心的数据采用 Avro 格式,二进制/不可读。需要在特定模式中转换为可读格式。
以下是尝试的代码:
%scala
// Configuration parameters for connecting to Event Hubs.
// Build connection string with the above information
val connectionString = ConnectionStringBuilder("our connection string).setEventHubName(EventHubName).build
val customEventhubParameters =
EventHubsConf(connectionString)
.setMaxEventsPerTrigger(1)
val incomingStream = spark.readStream.format("eventhubs").options(customEventhubParameters.toMap).load()
val messages = incomingStream.withColumn("Body", $"body".cast(StringType)).select("Body")
需要读取用户定义的 .avsc 模式并将其存储在 Dataframe 中以供以后处理
解决方案
推荐阅读
- node.js - 生成 e2big 节点
- html - 如何将一个 div 放在另一个下?
- cmake - 如何从工具链文件中覆盖 cmake 模块的设置?
- php - 混合 iOS / PHP 应用程序。将用户名作为 PHP 变量拉入,以用作 Pusher 对 Swift 代码的兴趣
- python - 从特定的文件名列表中删除大量文件(python)
- java - 格式化 LinkedHashMap
- java - java netbeans Jcombobox的整数太大的情况
- assembly - 在 ARM-Assembly 中将值存储在数组中
- javascript - 重置 React 样式组件的格式
- asp.net - ASP.net 发布新条目时一切正常,但之后调用时,数据消失了