In spark SQl, you can write
SELECT title, rn,
lead(rn, 1) IGNORE NULLS over(order by rn) as next_rn
FROM my_table
;
How would you add the IGNORE NULLS part in the equivalent Scala code?
val my_df = my_table
.withColumn("next_rn", lead($"rn", 1).over(Window.orderBy("rn"))