rank() function usage in Spark SQL
Window
spec need to be specified for rank()
val w = org.apache.spark.sql.expressions.Window.orderBy("date") //some spec
val leadDf = inputDSAAcolonly.withColumn("df1Rank", rank().over(w))
Edit: Java version of answer, as OP using Java
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));