hanyuzheng7 opened a new pull request, #23158:
URL: https://github.com/apache/flink/pull/23158
## What is the purpose of the change
Implement the array_sort function to extract a subset of elements from an
array.
Returns the array in sorted order. Sorts the input array in ascending or
descending order according to the natural ordering of the array elements. NULL
elements are placed at the beginning of the returned array in ascending order
or at the end of the returned array in descending order. If the array itself is
null, the function will return null. The optional ascendingOrder argument
defaults to true if not specified.
## Brief change log
ARRAY_SORT for Table API and SQL
Syntax:
`ARRAY_SORT(array, [ascendingOrder])`
Arguments:
array: The array we want to sort.
ascendingOrder: this is an option, default and true stand for ascending
order, false stand for descending order.
Returns:
if the array is null or ascendingOrder is null return null. if array is
empty return empty.
Examples:
```
SELECT ARRAY_SORT([5, 3, 2, 1, 0, null])
Output: [null, 0, 1, 2, 3, 5]
```
```
SELECT ARRAY_SORT([5, 3, 2, 1, 0, null], true)
Output: [null, 0, 1, 2, 3, 5]
```
```
SELECT ARRAY_SORT([null, 1, 2, 3, 5], false)
Output: [5, 3, 2, 1, null]
```
```
SELECT ARRAY_SORT(null)
null
```
```
SELECT ARRAY_SLICE(['a', 'b', 'c', 'd', 'e'], null)
null
```
see also:
spark: https://spark.apache.org/docs/latest/api/sql/index.html#array_sort
databrick:https://docs.databricks.com/sql/language-manual/functions/array_sort.html
## Verifying this change
- This change added tests in CollectionFunctionsITCase.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / no)
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: (yes / no)
- The serializers: (yes / no / don't know)
- The runtime per-record code paths (performance sensitive): (yes / no /
don't know)
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
- The S3 file system connector: (yes / no / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs
/ not documented)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]