【发布时间】:2022-01-12 20:44:47
【问题描述】:
我写了以下代码:
def extractGenderFromName(ds: Dataset[Toto])
(implicit sparkSession: SparkSession): Dataset[Toto] = {
if (ds("gender") == null)
ds.withColumn("gender", split(col(identity), "/")(1))
}
这里我想得到 col identity 的最后一部分,我放了1 但它可以是2 或3。如何动态取colidentity的最后一部分?
【问题讨论】:
-
检查this
标签: dataframe scala apache-spark apache-spark-sql apache-spark-dataset