[英]How to sort spark dataframe on the combination of columns in Java?
The groupBy() function is used during aggregation while your requirement just requires orderBy() groupBy() 函数在聚合期间使用,而您的要求只需要 orderBy()
Assuming dataframe df with 3 columns Col1, Col2, Col3, you can do the below in Spark假设数据帧 df 具有 3 列 Col1、Col2、Col3,您可以在 Spark 中执行以下操作
val sortedDf = df.orderBy(col("Col1").desc,col("Col2").desc,col("Col3").asc)
POC for the same is available here SQLFIDDLE此处提供相同的 POC SQLFIDDLE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.