-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: Support array_sort
(list_sort
)
#8279
Changes from 30 commits
7afeb8b
6332bec
cc5e0c7
a114310
928c811
839093e
a836cde
5648dc7
a670409
22894a3
73a59d2
46409c2
8a86a4c
cf5c584
62ae9b9
9becd04
10f668e
32b406e
e879302
116134a
da02fa2
d98eb2e
4628734
52f0afe
15b41b1
b7ad7f0
504655d
85c25d9
79e7216
a7e51e1
29f2d62
ba51abd
2468f52
d369caa
180c303
68980ba
9411940
ba28346
0d098d3
dea30c3
052f184
df0942f
edccb66
fb74b99
767b004
2e0eef5
749e0c8
5d43a94
9242903
1e1cc77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1044,6 +1044,44 @@ select make_array(['a','b'], null); | |
---- | ||
[[a, b], ] | ||
|
||
## array_sort (aliases: `list_sort`) | ||
query ??? | ||
select array_sort(make_array(1, 3, null, 5, NULL, -5)), array_sort(make_array(1, 3, null, 2), 'ASC'), array_sort(make_array(1, 3, null, 2), 'desc', 'NULLS FIRST'); | ||
---- | ||
[, , -5, 1, 3, 5] [, 1, 2, 3] [, 3, 2, 1] | ||
|
||
query ? | ||
select array_sort(column1, 'DESC', 'NULLS LAST') from arrays_values; | ||
---- | ||
[10, 9, 8, 7, 6, 5, 4, 3, 2, ] | ||
[20, 18, 17, 16, 15, 14, 13, 12, 11, ] | ||
[30, 29, 28, 27, 26, 25, 23, 22, 21, ] | ||
[40, 39, 38, 37, 35, 34, 33, 32, 31, ] | ||
[] | ||
[50, 49, 48, 47, 46, 45, 44, 43, 42, 41] | ||
[60, 59, 58, 57, 56, 55, 54, 52, 51, ] | ||
[70, 69, 68, 67, 66, 65, 64, 63, 62, 61] | ||
|
||
query ? | ||
select array_sort(column1, 'ASC', 'NULLS FIRST') from arrays_values; | ||
---- | ||
[, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
[, 11, 12, 13, 14, 15, 16, 17, 18, 20] | ||
[, 21, 22, 23, 25, 26, 27, 28, 29, 30] | ||
[, 31, 32, 33, 34, 35, 37, 38, 39, 40] | ||
[] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. array_sort(null) should return null, not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
[41, 42, 43, 44, 45, 46, 47, 48, 49, 50] | ||
[, 51, 52, 54, 55, 56, 57, 58, 59, 60] | ||
[61, 62, 63, 64, 65, 66, 67, 68, 69, 70] | ||
|
||
|
||
## list_sort (aliases: `array_sort`) | ||
query ??? | ||
select list_sort(make_array(1, 3, null, 5, NULL, -5)), list_sort(make_array(1, 3, null, 2), 'ASC'), list_sort(make_array(1, 3, null, 2), 'desc', 'NULLS FIRST'); | ||
---- | ||
[, , -5, 1, 3, 5] [, 1, 2, 3] [, 3, 2, 1] | ||
|
||
|
||
## array_append (aliases: `list_append`, `array_push_back`, `list_push_back`) | ||
|
||
# TODO: array_append with NULLs | ||
|
@@ -1216,7 +1254,7 @@ select array_prepend(make_array(1, 11, 111), column1), array_prepend(column2, ma | |
|
||
# array_repeat scalar function #1 | ||
query ???????? | ||
select | ||
select | ||
array_repeat(1, 5), | ||
array_repeat(3.14, 3), | ||
array_repeat('l', 4), | ||
|
@@ -1249,7 +1287,7 @@ AS VALUES | |
(0, 3, 3.3, 'datafusion', make_array(8, 9)); | ||
|
||
query ?????? | ||
select | ||
select | ||
array_repeat(column2, column1), | ||
array_repeat(column3, column1), | ||
array_repeat(column4, column1), | ||
|
@@ -1264,7 +1302,7 @@ from array_repeat_table; | |
[] [] [] [] [3, 3, 3] [] | ||
|
||
statement ok | ||
drop table array_repeat_table; | ||
drop table array_repeat_table; | ||
|
||
## array_concat (aliases: `array_cat`, `list_concat`, `list_cat`) | ||
|
||
|
@@ -2180,7 +2218,7 @@ select array_remove(make_array(1, 2, 2, 1, 1), 2), array_remove(make_array(1.0, | |
[1, 2, 1, 1] [2.0, 2.0, 1.0, 1.0] [h, e, l, o] | ||
|
||
query ??? | ||
select | ||
select | ||
array_remove(make_array(1, null, 2, 3), 2), | ||
array_remove(make_array(1.1, null, 2.2, 3.3), 1.1), | ||
array_remove(make_array('a', null, 'bc'), 'a'); | ||
|
@@ -2679,7 +2717,7 @@ from array_intersect_table_3D; | |
query ?????? | ||
SELECT array_intersect(make_array(1,2,3), make_array(2,3,4)), | ||
array_intersect(make_array(1,3,5), make_array(2,4,6)), | ||
array_intersect(make_array('aa','bb','cc'), make_array('cc','aa','dd')), | ||
array_intersect(make_array('aa','bb','cc'), make_array('cc','aa','dd')), | ||
array_intersect(make_array(true, false), make_array(true)), | ||
array_intersect(make_array(1.1, 2.2, 3.3), make_array(2.2, 3.3, 4.4)), | ||
array_intersect(make_array([1, 1], [2, 2], [3, 3]), make_array([2, 2], [3, 3], [4, 4])) | ||
|
@@ -2690,7 +2728,7 @@ SELECT array_intersect(make_array(1,2,3), make_array(2,3,4)), | |
query ?????? | ||
SELECT list_intersect(make_array(1,2,3), make_array(2,3,4)), | ||
list_intersect(make_array(1,3,5), make_array(2,4,6)), | ||
list_intersect(make_array('aa','bb','cc'), make_array('cc','aa','dd')), | ||
list_intersect(make_array('aa','bb','cc'), make_array('cc','aa','dd')), | ||
list_intersect(make_array(true, false), make_array(true)), | ||
list_intersect(make_array(1.1, 2.2, 3.3), make_array(2.2, 3.3, 4.4)), | ||
list_intersect(make_array([1, 1], [2, 2], [3, 3]), make_array([2, 2], [3, 3], [4, 4])) | ||
|
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.
Try arrow::compute::sort to avoid unwrap