I searched for this by applying a rating to my data frame in Java.
Using the answer in the comment above,
import org.apache.spark.sql.expressions.WindowSpec;
WindowSpec w = org.apache.spark.sql.expressions.Window.orderBy(colName);
Dataset<Row> leadDf = inputDSAAcolonly.withColumn("df1Rank", rank().over(w));
worked for me, thanks gaurav.