Skip to content

Instantly share code, notes, and snippets.

@NeerajBhadani
Created May 25, 2020 15:13
Show Gist options
  • Save NeerajBhadani/7a10e5082225f7d0f47109c564eb368c to your computer and use it in GitHub Desktop.
Save NeerajBhadani/7a10e5082225f7d0f47109c564eb368c to your computer and use it in GitHub Desktop.
lag
val winSpec = Window.partitionBy("depName").orderBy("salary")
val lag_df =
empsalary.withColumn("lag", lag("salary", 2).over(winSpec))
lag_df.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment