Spark中的sort和orderBy函数有什么区别 [英] What is the difference between sort and orderBy functions in Spark
本文介绍了Spark中的sort和orderBy函数有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
sort和orderBy spark DataFrame有什么区别?
What is the difference between sort and orderBy spark DataFrame?
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)
以下命令产生相同的结果:
Below commands produce same result:
zips.sort(desc("pop")).show
zips.orderBy(desc("pop")).show
推荐答案
OrderBy只是sort函数的别名.
OrderBy is just an alias for the sort function.
从Spark文档中:
/**
* 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 : _*)
这篇关于Spark中的sort和orderBy函数有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文