-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-23921][SQL] Add array_sort function #21021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
72f31b3
a9b6e3b
d57c14a
9977f64
172b2c5
f2798f9
175d981
d1b0483
04a3ae5
9f63a76
e3fcaaa
2ad6bb8
2c4404c
21521d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2158,6 +2158,7 @@ def sort_array(col, asc=True): | |
|
|
||
| :param col: name of column or expression | ||
|
|
||
| >>> from pyspark.sql.functions import sort_array | ||
| >>> df = spark.createDataFrame([([2, 1, 3],),([1],),([],)], ['data']) | ||
|
||
| >>> df.select(sort_array(df.data).alias('r')).collect() | ||
| [Row(r=[1, 2, 3]), Row(r=[1]), Row(r=[])] | ||
|
|
@@ -2168,6 +2169,23 @@ def sort_array(col, asc=True): | |
| return Column(sc._jvm.functions.sort_array(_to_java_column(col), asc)) | ||
|
|
||
|
|
||
| @since(2.4) | ||
| def array_sort(col): | ||
| """ | ||
| Collection function: sorts the input array in ascending order. The elements of the input array | ||
| must be orderable. Null elements will be placed at the end of the returned array. | ||
|
|
||
| :param col: name of column or expression | ||
|
|
||
| >>> from pyspark.sql.functions import array_sort | ||
|
||
| >>> df = spark.createDataFrame([([2, 1, None, 3],),([1],),([],)], ['data']) | ||
| >>> df.select(array_sort(df.data).alias('r')).collect() | ||
| [Row(r=[1, 2, 3, None]), Row(r=[1]), Row(r=[])] | ||
| """ | ||
|
||
| sc = SparkContext._active_spark_context | ||
| return Column(sc._jvm.functions.array_sort(_to_java_column(col))) | ||
|
|
||
|
|
||
| @since(1.5) | ||
| @ignore_unicode_prefix | ||
| def reverse(col): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?