how to implement spark sql pagination query

后端 未结 2 1847
小蘑菇
小蘑菇 2021-01-17 17:38

Does anyone how to do pagination in spark sql query?

I need to use spark sql but don\'t know how to do pagination.

Tried:

select * from pers         


        
2条回答
  •  逝去的感伤
    2021-01-17 18:10

    karthik's answer will fail if there are duplicate rows in the dataframe. 'except' will remove all rows in df1 which are in df2 .

    val filteredRdd = df.rdd.zipWithIndex().collect { case (r, i) if 10 >= start && i <=20 => r }
    val newDf = sqlContext.createDataFrame(filteredRdd, df.schema)
    

提交回复
热议问题