I have the below spark dataset/dataframe. I have to create a new column diff_col by finding the difference between absolute values of col_2 and col_3
col_1 col_2 col_3
A 5 3
B null -2
C 2 null
D null null
E 3 1
F 4 -2
Expected output:
col_1 col_2 col_3 diff_col
A 5 3 2
B null -2 -2
C 2 null 2
D null null 0
E 3 1 2
F 4 -2 2
Not sure how to do this in java spark. In pyspark we can do by replacing null with lit(0) and then col(col_2) - col(col_3). Is there a java spark equivalent for this?