dataframe - Pyspark 将 StrucType[ArrayType, StructureType] 转换为 ArrayType[ArrayType,ArrayType]
问题描述
我有一个列 'COL_NAME' 的 DF,其中包含一个 StructType 格式:
StructType[StructType, StructType, ArrayType, ArrayType, StructType, ArrayType, ArrayType]
上面的 StructType 从 UDF 返回。我需要将它转换为所有 ArrayType
ArrayType[ArrayType, ArrayType, ArrayType, ArrayType, ArrayType, ArrayType, ArrayType]
怎么做。太感谢了
更新
例子:
array need to return :
[[before], [after], [from_tbl], [where_tbl], [to_tbl], [lst_tbl], [dbinfo]]
where before/after is a list
before, after = [[query_type,out,[from],[where]],[query_type,out,[from],[where]]]
where querytype is string, out is string, but from, where is list, not same level
to_tbl = [write_mode, [table_name], table_action]
from_tbl, where_tbl, from, where, table_name, lst_tbl, db_info = [a,b,c]
当我定义 UDF 时,我必须定义返回模式,嵌套数组不是同一级别,所以我无法为所有人定义有效模式
解决方案
推荐阅读
- python - Pytorch 挤压和解压
- android - 将 React Native 前端与 Node 后端连接起来
- .net-core - 如何将 System.Text.JsonElement 打印(格式化)到字符串
- c# - 压缩内存流时出现内存不足异常
- php - 如何在PHP中检查字符串是否包含带有大写和小写的特定单词
- vue.js - 如何将时间戳转换为天数?
- mongodb - 猫鼬路径“。” 是必需的 - PostmanMocking 有问题吗?
- google-sheets - 如何在谷歌表格上添加两列年份?
- mysql - mysql根据两列计算债务和存款
- javascript - 在其他更新开始之前状态更新未完成