我的目标是在spark / Hadoop中准备一个数据帧,我将在elasticsearch中对其进行索引。
我有2个orc表:client
和person
。关系是一对多
1个客户可以有多个人。
所以我将使用Spark / Spark SQL,所以让我们说一下数据帧:
客户端数据帧架构:
root
|-- client_id: string (nullable = true)
|-- c1: string (nullable = true)
|-- c2: string (nullable = true)
|-- c3: string (nullable = true)
人员数据框架构:
root
|-- person_id: string (nullable = true)
|-- p1: string (nullable = true)
|-- p2: string (nullable = true)
|-- p3: string (nullable = true)
|-- client_id: string (nullable = true)
我的目标是生成一个具有此架构的Dataframe:
root
|-- client_id: string (nullable = true)
|-- c1: string (nullable = true)
|-- c2: string (nullable = true)
|-- c3: string (nullable = true)
|-- persons: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- person_id: string (nullable = true)
| | |-- p1: string (nullable = true)
| | |-- p2: string (nullable = true)
| | |-- p3: string (nullable = true)
我怎么能做到这一点?
提前感谢您的帮助。