Re: Pass row to UDF and select column based on pattern match

2019-07-10 Thread Gourav Sengupta
Just out of curiosity why are you trying to use a UDF when the corresponding function is available? Or why not use SQL instead? Regards, Gourav On Tue, Jul 9, 2019 at 7:25 PM Femi Anthony wrote: > How can I achieve the following by passing a row to a udf ? > > > *val df1 = df.withColumn("co

Pass row to UDF and select column based on pattern match

2019-07-09 Thread Femi Anthony
How can I achieve the following by passing a row to a udf ? val df1 = df.withColumn("col_Z", when($"col_x" === "a", $"col_A") .when($"col_x" === "b", $"col_B") .when($"col_x" === "c", $"col_C") .when($"col_x" === "d", $"c