I tried the options mentioned in the following post but it didn't work in java - finding the difference of two columns in spark dataframes and appending to a new column
subtract two columns with null in spark dataframe
Please let me know how can I find difference between two column of a dataset using Spark in Java.