【发布时间】:2021-12-27 18:32:53
【问题描述】:
我有一个字段 interest_product_id,如下所示 -
a.select('cust_id', 'interest_product_id').show(1,False)
+---------------+----------------------------------------------+
|cust_id |interest_product_id |
+---------------+----------------------------------------------+
|4308c3w994 |[[73ndy0-885bns-ysrd, isgbf-6322-734f4-92j72]]|
+---------------+----------------------------------------------+
架构如下 -
root
|-- cust_id: string (nullable = true)
|-- interest_product_id: array (nullable = true)
| |-- element: array (containsNull = true)
| | |-- element: string (containsNull = true)
由于字段interest_product_id 是数组类型,并且元素是数组(字符串),因此字段显示[[**]]。如何将其转换为数组(字符串)??
预期结果 -
+---------------+----------------------------------------------+
|cust_id |interest_product_id |
+---------------+----------------------------------------------+
|4308c3w994 |[73ndy0-885bns-ysrd, isgbf-6322-734f4-92j72] |
+---------------+----------------------------------------------+
请建议最好的方法。谢谢!!
【问题讨论】:
标签: python pyspark hive apache-spark-sql