What is the difference between sort and orderBy functions in Spark

前端 未结 3 1732
礼貌的吻别
礼貌的吻别 2020-12-15 05:06

What is the difference between sort and orderBy spark DataFrame?

scala> zips.printSchema
root
 |-- _id: string (nullable = true)
 |-- city: string (nullab         


        
3条回答
  •  被撕碎了的回忆
    2020-12-15 05:33

    OrderBy is just an alias for the sort function.

    From the Spark documentation:

      /**
       * 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 : _*)
    

提交回复
热议问题