2016-11-15 11 views
3

sortとorderBy spark DataFrameの違いは何ですか?コマンド以下SparkでsortとorderBy関数の違いは何ですか

scala> zips.printSchema 
root 
|-- _id: string (nullable = true) 
|-- city: string (nullable = true) 
|-- loc: array (nullable = true) 
| |-- element: double (containsNull = true) 
|-- pop: long (nullable = true) 
|-- state: string (nullable = true) 

同じ結果を生成:

zips.sort(desc("pop")).show 
zips.orderBy(desc("pop")).show 

答えて

7

のOrderByは、ソート機能のためだけのエイリアスです。

スパークのドキュメントから:

/** 
    * Returns a new Dataset sorted by the given expressions. 
    * This is an alias of the `sort` function. 
    * 
    * @group typedrel 
    * @since 2.0.0 
    */ 
    @scala.annotation.varargs 
    def orderBy(sortCol: String, sortCols: String*): Dataset[T] = sort(sortCol, sortCols : _*) 
関連する問題