我有一个多列的parquet文件,其中有2列是JSON/Struct,但它们的类型是string。可以有任何数量的array_elements。
{
"addressline": [
{
"array_element": "F748DK’8U1P9’2ZLKXE"
},
{
"array_element": "’O’P0BQ04M-"
},
{
"array_element": "’fvrvrWEM-"
}
],
"telephone": [
{
"array_element": {
"locationtype": "8.PLT",
"countrycode": null,
"phonenumber": "000000000",
"phonetechtype": "1.PTT",
"countryaccesscode": null,
"phoneremark": null
}
}
]
}
字符串
如何在PySpark中创建一个模式来处理这些列?
1条答案
按热度按时间ru9i0ody1#
把你提供的例子当作字符串,我创建了这个字符串:
字符串
这是要应用于此列的架构:
型
为
from_json
函数提供模式的结果:型