【发布时间】:2021-07-13 08:54:55
【问题描述】:
我有多个数据帧,这些数据帧是从 azure-event-hub 中的一个 json 消息中提取的。我们希望使用 spark 流作业将这些 DF 推送到 Synapse DW 中的单独表。
这是我的架构 -
root
|-- Name: string (nullable = true)
|-- Salary: string (nullable = true)
|-- EmpID: string (nullable = true)
|-- Projects: struct (nullable = true)
| |-- ProjectID: string (nullable = true)
| |-- ProjectName: string (nullable = true)
| |-- Duration: string (nullable = true)
| |-- Location: array (nullable = true)
| | |-- element: struct (containsNull = true)
| | | |-- City: string (nullable = true)
| | | |-- State: string (nullable = true)
| |-- Contact: array (nullable = true)
| | |-- element: struct (containsNull = true)
| | | |-- Phone: string (nullable = true)
| | | |-- email: string (nullable = true)
我从上述架构中提取了 4 个不同的数据帧 -
- 项目
- 位置
- 联系方式
- 员工
它们都应该被插入到 Synapse 的 4 个不同的表中
ProjectDf.write.format("spark.sqldw").options(.dbo.Project).save(...)
LocationDf.write.format("spark.sqldw").options(.dbo.Loc).save(...)
ContactDf.write.format("spark.sqldw").options(.dbo.Contact).save(...)
EmployeeDf.write.format("spark.sqldw").options(.dbo.Emp).save(...)
请建议如何在此应用 ForeachBatch 接收器以插入表格。
【问题讨论】:
标签: scala apache-spark spark-streaming spark-structured-streaming azure-databricks