给定下面的json片段和模式,是否可以重命名 child 1
在Dataframe中?
有很多重命名嵌套字段的示例( withColumn
),但没有关于在数组中重命名复杂类型的内容。
json文件
{
"parentArray": [
{
"child 1": 0
},
{
"child 1": 1
}
]
}
架构
{
"fields": [
{
"metadata": {},
"name": "parentArray",
"nullable": true,
"type": {
"containsNull": true,
"elementType": {
"fields": [
{
"metadata": {},
"name": "child 1",
"nullable": true,
"type": "long"
}
],
"type": "struct"
},
"type": "array"
}
}
],
"type": "struct"
}
1条答案
按热度按时间ocebsuys1#
试试这个-
加载测试数据
更改数组中的列名