[英]How to sort spark dataframe on the combination of columns in Java?
groupBy() 函數在聚合期間使用,而您的要求只需要 orderBy()
假設數據幀 df 具有 3 列 Col1、Col2、Col3,您可以在 Spark 中執行以下操作
val sortedDf = df.orderBy(col("Col1").desc,col("Col2").desc,col("Col3").asc)
此處提供相同的 POC SQLFIDDLE
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.