set row_number以0开头

时间:2018-04-24 09:47:21

标签: apache-spark apache-spark-sql window-functions row-number

嗨,我正在尝试火花窗口功能。我需要从“0”开始row_number。这是我的代码。

val target2 = target1.select("id","name","mark1","mark2","version").withColumn("rank", row_number().over(Window.partitionBy("name","mark1","mark2").orderBy("id")))

行号从“1”开始。我试过这样的。

val target2 = target1.select("id","name","mark1","mark2","version").withColumn("rank", row_number().over(Window.partitionBy("name","mark1","mark2").orderBy("id") -1))

val target2 = target1.select("id","name","mark1","mark2","version").withColumn("rank", row_number().over(Window.partitionBy("name","mark1","mark2").orderBy("id"))) -1

不适合我。我需要从零开始我的row_number。任何帮助将不胜感激。

0 个答案:

没有答案