【发布时间】:2017-03-15 06:18:37
【问题描述】:
我有要应用 UDF 的架构和列名称。列的名称是用户输入,每个输入的数字可能不同。 有没有办法将 UDF 应用于数据框中的 N 列?
正在努力实现这一目标。 对于带有 col1,col2,col3,col4,col5 的模式
DataFrame newDF = df.withColumn("col2", callUDF("test", (df.col("col2"))));
or
DataFrame newDF = df.withColumn("col2", callUDF("test", (df.col("col2"))))
.withColumn("col3", callUDF("test", (df.col("col3"))));
or
DataFrame newDF = df.withColumn("col2", callUDF("test", (df.col("col1"))))
.withColumn("col3", callUDF("test", (df.col("col3"))))
.withColumn("col5", callUDF("test", (df.col("col5"))))
or for N columns.
有什么想法吗?
【问题讨论】:
标签: apache-spark apache-spark-sql spark-dataframe