I wrote the following code:
def extractGenderFromName(ds: Dataset[Toto])
(implicit sparkSession: SparkSession): Dataset[Toto] = {
if (ds("gender") == null)
ds.withColumn("gender", split(col(identity), "/")(1))
}
Here I want to get the last part of the split of col identity, I put 1 but it can be 2 or 3. How to dynamically take the last part of col identity?