标题说明了一切:
在SPARK API中有没有等同于Spark SQL命令的东西,这样我就可以从包含多列数据结构的LATERAL VIEW中生成一列,然后将该结构中的列作为单独的列横向分布到父dataFrame中?
等同于df.select(expr("LATERAL VIEW udf(col1,col2...coln)"))的东西
发布于 2021-02-27 01:30:56
我通过选择udf到一个列中解决了这个问题:
val dfWithUdfResolved = dataFrame.select(calledUdf()).as("tuple_column"))
..。然后..。
dfWithUdfResolved
.withColumn("newCol1", $"tuple_column._1")
.withColumn("newCol2", $"tuple_column._2")
// ...
.withColumn("newColn", $"tuple_column._n")基本上使用元组表示法将值从列中提取到新的离散列中。
https://stackoverflow.com/questions/66371736
复制相似问题