This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new ba2cf0589d7 [fix](array) fix some array functions (#2845)
ba2cf0589d7 is described below
commit ba2cf0589d758db7612ee3dd76624707fdc3c9c9
Author: Sun Chenyang <[email protected]>
AuthorDate: Fri Sep 5 15:58:22 2025 +0800
[fix](array) fix some array functions (#2845)
## Versions
- [x] dev
- [ ] 3.0
- [ ] 2.1
- [ ] 2.0
## Languages
- [x] Chinese
- [x] English
## Docs Checklist
- [ ] Checked by AI
- [ ] Test Cases Built
---
.../array-functions/array-range.md | 100 ++++++++++--------
.../array-functions/array-remove.md | 47 +++++----
.../array-functions/array-repeat.md | 81 +++++++++++----
.../array-functions/array-reverse-sort.md | 44 ++++----
.../array-functions/array-reverse-split.md | 106 ++++++++-----------
.../array-functions/array-shuffle.md | 50 +++++----
.../scalar-functions/array-functions/array-size.md | 45 ++++----
.../array-functions/array-slice.md | 61 ++++++-----
.../scalar-functions/array-functions/array-sort.md | 44 ++++----
.../array-functions/array-sortby.md | 114 +++++++--------------
.../array-functions/array-split.md | 106 ++++++++-----------
.../scalar-functions/array-functions/countequal.md | 48 +++++----
.../array-functions/array-range.md | 89 +++++++++-------
.../array-functions/array-remove.md | 44 ++++----
.../array-functions/array-repeat.md | 80 +++++++++++----
.../array-functions/array-reverse-sort.md | 39 ++++---
.../array-functions/array-reverse-split.md | 97 +++++++-----------
.../array-functions/array-shuffle.md | 45 ++++----
.../scalar-functions/array-functions/array-size.md | 40 +++-----
.../array-functions/array-slice.md | 56 ++++++----
.../scalar-functions/array-functions/array-sort.md | 39 ++++---
.../array-functions/array-sortby.md | 91 +++++-----------
.../array-functions/array-split.md | 97 +++++++-----------
.../scalar-functions/array-functions/countequal.md | 45 ++++----
24 files changed, 768 insertions(+), 840 deletions(-)
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md
index 1ff95a184cc..03bb6a2a9ea 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md
@@ -5,52 +5,68 @@
}
---
-## Description
+## Function
-1. Generate int array
-2. Generate date and time array
-
-## Aliases
-
-- SEQUENCE
+Generate an arithmetic sequence array of numbers or datetimes.
+- For numeric types, the default step is 1
+- For datetime types, the default step is 1 day
## Syntax
-```sql
-ARRAY_RANGE(<end>)
-ARRAY_RANGE(<start>, <end>)
-ARRAY_RANGE(<start>, <end>, <step>)
-ARRAY_RANGE(<start_datetime>, <end_datetime>)
-ARRAY_RANGE(<start_datetime>, <end_datetime>, INTERVAL <interval_step> <unit>)
-```
+- `ARRAY_RANGE(end)`
+- `ARRAY_RANGE(start, end)`
+- `ARRAY_RANGE(start, end, step)`
+- `ARRAY_RANGE(start_dt, end_dt)`
+- `ARRAY_RANGE(start_dt, end_dt, interval step unit)`
## Parameters
-| Parameter | Description |
-|--|--|
-| `<start>` | The starting value is a positive integer, the default value is 0
|
-| `<end>` | End value, a positive integer |
-| `<step>` | Step size, a positive integer, default is 1 |
-| `<start_datetime>` | Start date, datetimev2 type |
-| `<end_datetime>` | End date, datetimev2 type |
-| `<interval_step>` | Interval value, default is 1 |
-| `<unit>` | Interval unit, supports
year/quarter/month/week/day/hour/minute/second, default is day |
-
-## Return Value
-
-1. Returns an array from start to end - 1, with a step length of step. If the
third parameter step is negative or zero, the function result will be NULL
-2. Returns an array of datetimev2 between start_datetime and the closest
end_datetime (calculated by Interval_step UNIT). If the third argument
interval_step is negative or zero, the function result will be NULL
-
-## Example
-
-```sql
-SELECT ARRAY_RANGE(0,20,2),ARRAY_RANGE(cast('2019-05-15 12:00:00' as
datetimev2(0)), cast('2022-05-17 12:00:00' as datetimev2(0)), interval 2 year);
-```
-
-```text
-+-------------------------------------+----------------------------------------------------------------------------------------------------------------------+
-| array_range(0, 20, 2) | array_range_year_unit(cast('2019-05-15
12:00:00' as DATETIMEV2(0)), cast('2022-05-17 12:00:00' as DATETIMEV2(0)), 2) |
-+-------------------------------------+----------------------------------------------------------------------------------------------------------------------+
-| [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] | ["2019-05-15 12:00:00", "2021-05-15
12:00:00"]
|
-+-------------------------------------+----------------------------------------------------------------------------------------------------------------------+
-```
+- `start`, `end`: non-negative integers. `end` is the upper bound and is
excluded from the result.
+- `step`: must be a positive integer; the step length; default is 1.
+- `start_dt`, `end_dt`: DATETIME. In the two-argument form, the default step
is 1 DAY.
+- `interval step unit`: datetime step. `unit` can be
`YEAR|QUARTER|MONTH|WEEK|DAY|HOUR|MINUTE|SECOND`; `step` must be a positive
integer.
+
+## Return value
+
+- Returns `ARRAY<T>`; returns `NULL` for illegal arguments; returns an empty
array `[]` for an empty range.
+- The element type `T` matches the input: integers produce `INT`, datetimes
produce `DATETIME`.
+
+## Usage notes
+
+- Numeric sequence: start from `start`, increment by `step`, up to but
excluding `end` (left-closed, right-open).
+- Datetime sequence: start from `start_dt`, increment by `step` in the given
`unit`, up to but excluding `end_dt`; the two-argument form is equivalent to
`interval 1 day`.
+- Illegal arguments return `NULL`:
+ - Numeric: `start < 0`, `end < 0`, `step <= 0`.
+ - Datetime: `start_dt` or `end_dt` invalid, or `step <= 0`.
+- `ARRAY_RANGE` and `SEQUENCE` are equivalent.
+
+## Examples
+
+- Numeric: `start` defaults to 0, `step` defaults to 1
+ - `ARRAY_RANGE(5)` -> `[0, 1, 2, 3, 4]`
+ - `ARRAY_RANGE(0, 5)` -> `[0, 1, 2, 3, 4]`
+
+- Numeric: `end` is the upper bound and is not included in the result.
+ - `ARRAY_RANGE(2, 6, 2)` -> `[2, 4]`
+ - `ARRAY_RANGE(3, 3)` -> `[]`
+
+- Numeric: `end` must be greater than or equal to `start`, otherwise returns
`[]`
+ - `ARRAY_RANGE(3, 2)` -> `[]`
+
+- Numeric: `start`, `end` must be non-negative integers, and `step` must be
greater than 0.
+ - `ARRAY_RANGE(-1, 3)` -> `NULL`
+ - `ARRAY_RANGE(1, 3, 0)` -> `NULL`
+
+- Datetime: `step` defaults to 1 day.
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-17 12:00:00')` ->
`['2022-05-15 12:00:00', '2022-05-16 12:00:00']`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-17 12:00:00', interval 1
day)` -> `['2022-05-15 12:00:00', '2022-05-16 12:00:00']`
+
+- Datetime: `unit` can be `YEAR|QUARTER|MONTH|WEEK|DAY|HOUR|MINUTE|SECOND`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2024-05-17 12:00:00', interval 1
year)` -> `["2022-05-15 12:00:00", "2023-05-15 12:00:00"]`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2023-05-17 12:00:00', interval 1
quarter);` -> `["2022-05-15 12:00:00", "2022-08-15 12:00:00", "2022-11-15
12:00:00", "2023-02-15 12:00:00"] `
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-07-17 12:00:00', interval 1
month);` -> `["2022-05-15 12:00:00", "2022-06-15 12:00:00"]`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-17 12:00:00', interval 1
day)` -> `['2022-05-15 12:00:00', '2022-05-16 12:00:00']`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-15 14:00:00', interval 1
hour)` -> `["2022-05-15 12:00:00", "2022-05-15 13:00:00"]`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-15 12:02:00', interval 1
minute)` -> `["2022-05-15 12:00:00", "2022-05-15 12:01:00"]`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-15 12:00:02', interval 1
second)` -> `["2022-05-15 12:00:00", "2022-05-15 12:00:01"]`
+
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-remove.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-remove.md
index fe365774a01..e49a98012c2 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-remove.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-remove.md
@@ -5,37 +5,40 @@
}
---
-## Description
+## Function
-Removes all specified elements from an array
+Remove all elements equal to the given value from an array while preserving
the relative order of the remaining elements.
## Syntax
-```sql
-ARRAY_REMOVE(<arr>, <val>)
-```
+- `ARRAY_REMOVE(arr, target)`
## Parameters
-| Parameter | Description |
-|--|--|
-| `<arr>` | Corresponding array |
-| `<val>` | Specifying Elements |
+- `arr`: `ARRAY<T>`, supports numbers, boolean, string, datetime, IP, etc.
+- `target`: a value of the same type as the array elements, used to match
elements to remove.
-## Return Value
+## Return value
-Returns the array after removing all specified elements. If the input
parameter is NULL, it returns NULL
+- Returns `ARRAY<T>` of the same type as the input.
+- If `arr` or `target` is `NULL`, returns `NULL`.
+
+## Usage notes
+
+- Matching rule: only elements whose value equals `target` are removed. `NULL`
elements are not equal to any non-`NULL` value, so they are not removed.
+
+## Examples
+
+- Basic: After removal, the remaining elements keep their original relative
order.
+ - `ARRAY_REMOVE([1,2,3], 1)` -> `[2,3]`
+ - `ARRAY_REMOVE([1,2,3,null], 1)` -> `[2,3,null]`
+
+- If either `arr` or `target` is `NULL`, returns `NULL`
+ - `ARRAY_REMOVE(['a','b','c',NULL], NULL)` -> `NULL`
+ - `ARRAY_REMOVE(NULL, 2)` -> `NULL`
+
+- No match
+ - `ARRAY_REMOVE([1,2,3], 258)` -> `[1,2,3]`
-## Example
-```sql
-SELECT ARRAY_REMOVE(['test', NULL, 'value'], 'value');
-```
-```text
-+------------------------------------------------+
-| array_remove(['test', NULL, 'value'], 'value') |
-+------------------------------------------------+
-| ["test", null] |
-+------------------------------------------------+
-```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-repeat.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-repeat.md
index 2bfce5420fc..a3a64e547fa 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-repeat.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-repeat.md
@@ -5,37 +5,78 @@
}
---
-## Description
+## Function
-Generates an array containing n repeated elements
+`ARRAY_REPEAT` is used to generate an array of a specified length, where all
elements have the given value.
## Syntax
-```sql
-ARRAY_REPEAT(<element>, <n>)
+```SQL
+ARRAY_REPEAT(element, count)
```
## Parameters
-| Parameter | Description |
-|--|--|
-| `<n>` | Number of digits |
-| `<element>` | Specifying Elements |
+- `element`: Any storage type supported in an `ARRAY`.
+
+- `count`: Integer type, specifies the length of the returned array.
+
## Return Value
-Returns an array containing n repeated elements. array_with_constant has the
same function as array_repeat and is used to be compatible with the hive syntax
format.
+- Returns an array of type `ARRAY<T>`, where `T` is the type of `element`.
+ - The array contains `count` copies of the same `element`.
-## Example
+## Usage Notes
-```sql
-SELECT ARRAY_REPEAT("hello", 2),ARRAY_REPEAT(12345, 3);
-```
+- If `count = 0` or `NULL`, returns an empty array.
+- If `element` is `NULL`, all elements in the array are `NULL`.
+- This function has the same functionality as `ARRAY_WITH_CONSTANT`, but the
parameter order is reversed.
-```text
-+--------------------------+------------------------+
-| array_repeat('hello', 2) | array_repeat(12345, 3) |
-+--------------------------+------------------------+
-| ["hello", "hello"] | [12345, 12345, 12345] |
-+--------------------------+------------------------+
-```
+## Examples
+
+1. Simple example
+
+ ```SQL
+ SELECT ARRAY_REPEAT('hello', 3);
+ +---------------------------------+
+ | ARRAY_REPEAT('hello', 3) |
+ +---------------------------------+
+ | ["hello", "hello", "hello"] |
+ +---------------------------------+
+ ```
+
+2. Special cases
+
+ ```SQL
+ SELECT ARRAY_REPEAT('hello', 0);
+ +---------------------------------+
+ | ARRAY_REPEAT('hello', 0) |
+ +---------------------------------+
+ | [] |
+ +---------------------------------+
+
+ SELECT ARRAY_REPEAT('hello', NULL);
+ +------------------------------------+
+ | ARRAY_REPEAT('hello', NULL) |
+ +------------------------------------+
+ | [] |
+ +------------------------------------+
+
+ SELECT ARRAY_REPEAT(NULL, 2);
+ +------------------------------+
+ | ARRAY_REPEAT(NULL, 2) |
+ +------------------------------+
+ | [null, null] |
+ +------------------------------+
+
+ SELECT ARRAY_REPEAT(NULL, NULL);
+ +---------------------------------+
+ | ARRAY_REPEAT(NULL, NULL) |
+ +---------------------------------+
+ | [] |
+ +---------------------------------+
+
+ -- Returns error: INVALID_ARGUMENT
+ SELECT ARRAY_REPEAT('hello', -1);
+ ```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-sort.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-sort.md
index 0c5f9ccdd4a..4c1217471ae 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-sort.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-sort.md
@@ -1,40 +1,40 @@
---
{
"title": "ARRAY_REVERSE_SORT",
- "language": "en"
+ "language": "en-US"
}
---
-## Description
+## Function
-Sort the elements in an array in descending order
+Sort array elements in descending order.
## Syntax
-```sql
-ARRAY_REVERSE_SORT(<arr>)
-```
+- `ARRAY_REVERSE_SORT(arr)`
## Parameters
-| Parameter | Description |
-|--|--|
-| `<arr>` | Corresponding array |
+- `arr`: `ARRAY<T>`, where `T` can be numeric, boolean, string, datetime, IP,
etc.
-## Return Value
+## Return value
-Returns an array sorted in descending order. If the input array is NULL, it
returns NULL. If the array element contains NULL, the output sorted array will
put NULL at the end.
+- Returns `ARRAY<T>` of the same type as the input.
+- `NULL` elements are placed at the end of the returned array.
+
+## Usage notes
+
+- If the input is `NULL`, returns `NULL`; if the input is an empty array `[]`,
returns an empty array.
+- `ARRAY_REVERSE_SORT` sorts in descending order, while `ARRAY_SORT` sorts in
ascending order.
+
+## Examples
+
+- Basic: `NULL` elements are placed at the end of the returned array
+ - `ARRAY_REVERSE_SORT([1,2,3,null])` -> `[3,2,1,null]`
+
+- If the input is `NULL`, returns `NULL`; if the input is an empty array `[]`,
returns an empty array.
+ - `ARRAY_REVERSE_SORT(NULL)` -> `NULL`
+ - `ARRAY_REVERSE_SORT([])` -> `[]`
-## Example
-```sql
-SELECT ARRAY_REVERSE_SORT([1, 2, 3, 6]),ARRAY_REVERSE_SORT([1, 4, 3, 5,
NULL]),ARRAY_REVERSE_SORT([NULL]);
-```
-```text
-+----------------------------------+----------------------------------------+----------------------------+
-| array_reverse_sort([1, 2, 3, 6]) | array_reverse_sort([1, 4, 3, 5, NULL]) |
array_reverse_sort([NULL]) |
-+----------------------------------+----------------------------------------+----------------------------+
-| [6, 3, 2, 1] | [5, 4, 3, 1, null] |
[null] |
-+----------------------------------+----------------------------------------+----------------------------+
-```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-split.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-split.md
index 07cf6220f85..8dca3cbd65f 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-split.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-split.md
@@ -1,79 +1,53 @@
---
{
"title": "ARRAY_REVERSE_SPLIT",
- "language": "en"
+ "language": "en-US"
}
---
-## Description
+## Function
-1. pass in two `ARRAY` of equal length, the second of which is an
`Array<Boolean>`, and split the `arg` according to the split point to the right
of the position in the `cond` that is `true`.
-2. Higher-order functions, passed a lambda expression and at least one `ARRAY
arg0`, split `arg0` by the right-hand side of the `true` position in the `cond`
of the `Array<Boolean>` result of the operation on the lambda expression.
+Split the input array into multiple subarrays according to given boolean flags.
+
+- Splitting rule (left to right): for `arr=[a1,a2,...,an]` and
`flags=[f1,f2,...,fn]`, at every position where `fi==true`, split between `ai`
and `a(i+1)`.
+ - For example, with `arr=[3, 4, 5]` and `flags=[false, true, false]`, the
second flag is true, so split between the second and third elements, resulting
in two subarrays `[3, 4]` and `[5]`.
## Syntax
-```sql
-ARRAY_REVERSE_SPLIT(<arr>, <cond>)
-ARRAY_REVERSE_SPLIT(<lambda>, <arr> [, ...])
-```
+- `ARRAY_REVERSE_SPLIT(arr, flags)`
+- `ARRAY_REVERSE_SPLIT(lamda, arr0, ...)`
+- `ARRAY_REVERSE_SPLIT(lambda, arr0, ...)` is equivalent to
`ARRAY_REVERSE_SPLIT(arr0, ARRAY_MAP(lambda, arr0, ...))`
## Parameters
-| Parameter | Description |
-| --- | --- |
-| `<lambda>` | A lambda expression where the input parameters must match the
number of columns in the given array. The expression can execute valid scalar
functions but does not support aggregate functions. |
-| `<arr>` | ARRAY array |
-
-## Return Value
-
-Returns an ARRAY type result, where the array is split according to the
specified condition.
-
-## Example
-
-```sql
-select array_reverse_split([1,2,3,4,5], [1,0,1,0,0]);
-```
-
-```text
-+-------------------------------------------------------------------------------+
-| array_reverse_split([1, 2, 3, 4, 5], cast([1, 0, 1, 0, 0] as
ARRAY<BOOLEAN>)) |
-+-------------------------------------------------------------------------------+
-| [[1], [2, 3], [4, 5]]
|
-+-------------------------------------------------------------------------------+
-```
-
-```sql
-select array_reverse_split((x,y)->y, [1,2,3,4,5], [1,0,0,0,0]);
-```
-
-```text
-+------------------------------------------------------------------------------------------------------------------------+
-| array_reverse_split([1, 2, 3, 4, 5], cast(array_map((x, y) -> y, [1, 2, 3,
4, 5], [1, 0, 0, 0, 0]) as ARRAY<BOOLEAN>)) |
-+------------------------------------------------------------------------------------------------------------------------+
-| [[1], [2, 3, 4, 5]]
|
-+------------------------------------------------------------------------------------------------------------------------+
-```
-
-```sql
-select array_reverse_split((x,y)->(y+1), ['a', 'b', 'c', 'd'], [-1, -1, 0,
-1]);
-```
-
-```text
-+----------------------------------------------------------------------------------------------------------------------------------------+
-| array_reverse_split(['a', 'b', 'c', 'd'], cast(array_map((x, y) -> (y + 1),
['a', 'b', 'c', 'd'], [-1, -1, 0, -1]) as ARRAY<BOOLEAN>)) |
-+----------------------------------------------------------------------------------------------------------------------------------------+
-| [["a", "b", "c"], ["d"]]
|
-+----------------------------------------------------------------------------------------------------------------------------------------+
-```
-
-```sql
-select array_reverse_split(x->(year(x)>2013),["2020-12-12", "2013-12-12",
"2015-12-12", null]);
-```
-
-```text
-+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| array_reverse_split(['2020-12-12', '2013-12-12', '2015-12-12', NULL],
array_map(x -> (year(cast(x as DATEV2)) > 2013), ['2020-12-12', '2013-12-12',
'2015-12-12', NULL])) |
-+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| [["2020-12-12"], ["2013-12-12", "2015-12-12"], [null]]
|
-+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-```
+- `arr`: `ARRAY<T>`.
+- `flags`: `ARRAY<BOOLEAN>`, whose length must match that of `arr` row by row.
`true` means split between the current position and the next element.
+- `arr0, ...`: one or more `ARRAY<T>`.
+- `lambda`: a `lambda` expression applied to `arr0, ...` to produce `flags`,
which are then used for splitting.
+
+## Return value
+
+- Returns `ARRAY<ARRAY<T>>`. Elements of inner arrays are the same as those of
`arr`.
+- If the element counts of `arr` and `flags` do not match, an error is thrown.
+
+## Usage notes
+
+- If a position in `flags` is `NULL`, it is treated as no split (equivalent to
`false`).
+- The splitting rule of `ARRAY_REVERSE_SPLIT` is: at each position where
`fi==true`, split between `ai` and `a(i+1)`.
+- The splitting rule of `ARRAY_SPLIT` is: at each position where `fi==true`,
split between `ai` and `a(i-1)`.
+
+## Examples
+
+- Basic splitting: at each `true` position, split from the right side neighbor.
+ - `ARRAY_REVERSE_SPLIT([1,2,3,4,5], [false,true,false,true,false])` ->
`[[1,2], [3,4], [5]]`
+ - `ARRAY_REVERSE_SPLIT(['a','b','c'], [false,false,false])` ->
`[['a','b','c']]`
+
+- With `NULL` in `flags`: `NULL` is treated the same as `false` (no split).
+ - `ARRAY_REVERSE_SPLIT([1,NULL,3], [false,null,false])` -> `[[1,[NULL,3]]`
+
+- `lambda= x -> x-1` applied to `arr=[1, 2, 3]` produces `flags=[0,1,2]`,
equivalent to `flags=[false,true,true]`
+ - `ARRAY_REVERSE_SPLIT(x->x-1, [1, 2, 3])` is equivalent to
`ARRAY_REVERSE_SPLIT([1, 2, 3], [false,true,true])` -> `[[1, 2], [3]]`
+
+- `lambda= (x,y) -> x-y` applied to `arr=[1, 2, 3]` and `arr1=[0,1,2]`
produces `flags=[true,true,true]`
+ - `ARRAY_REVERSE_SPLIT((x,y) -> x-y, [1, 2, 3], [0, 1, 2])` is equivalent to
`ARRAY_REVERSE_SPLIT([1, 2, 3], [true,true,true])` -> `[[1], [2], [3]]`
+
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-shuffle.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-shuffle.md
index 2e2e0d37161..9d319d086d5 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-shuffle.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-shuffle.md
@@ -1,45 +1,41 @@
---
{
"title": "ARRAY_SHUFFLE",
- "language": "en"
+ "language": "en-US"
}
---
-## Description
+## Function
-Randomly arrange the elements in an array
-
-## Aliases
-
-- SHUFFLE
+Randomly shuffle the order of elements in an array.
## Syntax
-```sql
-ARRAY_SHUFFLE(<array>, <seed>)
-```
+- `ARRAY_SHUFFLE(arr)`
+- `ARRAY_SHUFFLE(arr, seed)`
## Parameters
-| Parameter | Description |
-|--|--|
-| `<array>` | The array to be randomly permuted |
-| `<seed>` | An optional parameter that sets the initial value of the
pseudo-random number generator used to generate pseudo-random numbers |
+- `arr`: `ARRAY<T>`.
+- `seed`: optional, random seed.
+
+## Return value
+
+- Returns an array of the same type as the input, with elements randomly
reordered. Element count and types remain unchanged.
+
+## Usage notes
-## Return Value
+- If the input `arr` is `NULL`, returns `NULL`.
+- Providing a `seed` yields reproducible results; omitting it may yield
different results per execution.
+- `ARRAY_SHUFFLE` has an alias `SHUFFLE`; they are equivalent.
+-
-Randomize the elements in an array. The parameter array1 is the array to be
randomly arranged, and the optional parameter seed is the initial value used by
the pseudo-random number generator to generate pseudo-random numbers. shuffle
has the same function as array_shuffle.
+## Examples
-## Example
+- Basic usage:
+ - `ARRAY_SHUFFLE([1, 2, 3, 4])` -> e.g. `[3, 1, 4, 2]` (random order)
+ - `ARRAY_SHUFFLE(['a', null, 'b'])` -> e.g. `['b', 'a', null]`
-```sql
-SELECT ARRAY_SHUFFLE([1, 2, 3, 6]),ARRAY_SHUFFLE([1, 4, 3, 5, NULL],1);
-```
+- With a fixed seed (reproducible results):
+ - `ARRAY_SHUFFLE([1, 2, 3, 4], 0)` -> same order each time (e.g. `[1, 3, 2,
4]`)
-```text
-+-----------------------------+--------------------------------------+
-| array_shuffle([1, 2, 3, 6]) | array_shuffle([1, 4, 3, 5, NULL], 1) |
-+-----------------------------+--------------------------------------+
-| [2, 6, 3, 1] | [4, 1, 3, 5, null] |
-+-----------------------------+--------------------------------------+
-```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-size.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-size.md
index 02d67e45b14..331dc4d2f35 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-size.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-size.md
@@ -1,45 +1,36 @@
---
{
"title": "ARRAY_SIZE",
- "language": "en"
+ "language": "en-US"
}
---
-## Description
+## Function
-Count the number of elements in an array
-
-## Aliases
-
-- SIZE
-- CARDINALITY
+Return the number of elements in an array.
## Syntax
-```sql
-ARRAY_SIZE(<arr>)
-```
+- `ARRAY_SIZE(arr)`
## Parameters
-| Parameter | Description |
-|--|--|
-| `<arr>` | The array to be calculated |
+- `arr`: `ARRAY<T>`.
+
+## Return value
+
+- Returns how many elements `arr` contains.
+
+## Usage notes
-## Return Value
+- If the input `arr` is `NULL`, returns `NULL`.
-Returns the number of elements in the array. If the input array is NULL, it
returns NULL.
+## Examples
-## Example
+- Arrays:
+ - `ARRAY_SIZE([1, 2, 3])` -> `3`
+ - `ARRAY_SIZE(['a', NULL, 'b'])` -> `3`
-```sql
-SELECT ARRAY_SIZE(['a', 'b', 'c']),ARRAY_SIZE([NULL]),ARRAY_SIZE([]);
-```
+- If the input `arr` is `NULL`, returns `NULL`
+ - `ARRAY_SIZE(NULL)` -> `NULL`
-```text
-+------------------------------+---------------------+-----------------+
-| cardinality(['a', 'b', 'c']) | cardinality([NULL]) | cardinality([]) |
-+------------------------------+---------------------+-----------------+
-| 3 | 1 | 0 |
-+------------------------------+---------------------+-----------------+
-```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-slice.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-slice.md
index 7fe3a6341dc..a122ad1d226 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-slice.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-slice.md
@@ -1,42 +1,55 @@
---
{
"title": "ARRAY_SLICE",
- "language": "en"
+ "language": "en-US"
}
---
-## Description
+## Function
-Specify the starting position and length to extract a portion of elements from
an array to form a new sub-array
+Return a subarray, supporting starting offset and length.
## Syntax
-```sql
-ARRAY_SLICE(<arr>, <off>, <len>)
-```
+- `ARRAY_SLICE(arr, offset)`
+- `ARRAY_SLICE(arr, offset, length)`
## Parameters
-| Parameter | Description |
-|--|--|
-| `<arr>` | Corresponding array |
-| `<off>` | Starting position. If off is a positive number, it indicates the
offset from the left. If off is a negative number, it indicates the offset from
the right. When the specified off is not within the actual range of the array,
an empty array is returned. |
-| `<len>` | If len is a negative number, it means the length is 0.|
+- `arr`: `ARRAY<T>`.
+- `offset`: starting position. Positive values count from the head (`1` is the
first element); negative values count from the tail (`-1` is the last element).
+- `length`: length to take. A positive value takes `length` elements; a
negative value is treated as length 0.
-## Return Value
+## Return value
-Returns a subarray containing all elements of the specified length starting
from the specified position. If the input parameter is NULL, it returns NULL.
+- Returns `ARRAY<T>` of the same type as the input.
+
+## Usage notes
+
+- Out-of-bounds safe: the start and end are clipped to the array boundaries.
If there is no overlap, an empty array is returned.
+
+## Examples
+
+- Positive starting offset: from the offset to the right end
+ - `ARRAY_SLICE([1,2,3,4,5,6], 2)` -> `[2,3,4,5,6]`
+
+- Negative starting offset: from the offset to the right end
+ - `ARRAY_SLICE([1,2,3,4,5,6], -3)` -> `[4,5,6]`
+
+- Positive length: take to the right starting from offset
+ - `ARRAY_SLICE([1,2,3,4,5,6], 2, 3)` -> `[2,3,4]`
+ - `ARRAY_SLICE([1,2,3,4,5,6], -4, 2)` -> `[3,4]`
+
+- Negative length: treated as length 0
+ - `ARRAY_SLICE([1,2,3,4,5,6], 2, -2)` -> `[]`
+
+- Out-of-range arguments: return empty array
+ - `ARRAY_SLICE([1,2,3,4,5,6], 10, 3)` -> `[]`
+
+- Any `NULL` argument: return `NULL`
+ - `ARRAY_SLICE([1,2,3], NULL, 2)` -> `NULL`
+ - `ARRAY_SLICE([1,2,3], 2, NULL)` -> `NULL`
+ - `ARRAY_SLICE(NULL, 2, 3)` -> `NULL`
-## Example
-```sql
-SELECT ARRAY_SLICE([1, 2, 3, 6],2,3),ARRAY_SLICE([1, 4, 3, 5,
NULL],-2,1),ARRAY_SLICE([1, 3, 5],0);
-```
-```text
-+---------------------------------+----------------------------------------+---------------------------+
-| array_slice([1, 2, 3, 6], 2, 3) | array_slice([1, 4, 3, 5, NULL], -2, 1) |
array_slice([1, 3, 5], 0) |
-+---------------------------------+----------------------------------------+---------------------------+
-| [2, 3, 6] | [5] |
[] |
-+---------------------------------+----------------------------------------+---------------------------+
-```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-sort.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-sort.md
index 353f140181e..2214ed035ff 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-sort.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-sort.md
@@ -1,40 +1,40 @@
---
{
"title": "ARRAY_SORT",
- "language": "en"
+ "language": "en-US"
}
---
-## Description
+## Function
-Sort the elements in an array in ascending order
+Sort array elements in ascending order.
## Syntax
-```sql
-ARRAY_SORT(<arr>)
-```
+- `ARRAY_SORT(arr)`
## Parameters
-| Parameter | Description |
-|--|--|
-| `<arr>` | Corresponding array |
+- `arr`: `ARRAY<T>`, where `T` can be numeric, boolean, string, datetime, IP,
etc.
-## Return Value
+## Return value
-Returns an array sorted in ascending order. If the input array is NULL, it
returns NULL. If the array elements contain NULL, the output sorted array will
put NULL first.
+- Returns `ARRAY<T>` of the same type as the input.
+- `NULL` elements are placed at the beginning of the returned array.
+
+## Usage notes
+
+- If the input is `NULL`, returns `NULL`; if the input is an empty array `[]`,
returns an empty array.
+- `ARRAY_SORT` sorts in ascending order, while `ARRAY_REVERSE_SORT` sorts in
descending order.
+
+## Examples
+
+- Basic: `NULL` elements are placed at the beginning of the returned array
+ - `ARRAY_SORT([2,1,3,null])` -> `[null, 1, 2, 3]`
+
+- If the input is `NULL`, returns `NULL`; if the input is an empty array `[]`,
returns an empty array.
+ - `ARRAY_SORT(NULL)` -> `NULL`
+ - `ARRAY_SORT([])` -> `[]`
-## Example
-```sql
-SELECT ARRAY_SORT([1, 2, 3, 6]),ARRAY_SORT([1, 4, 3, 5,
NULL]),ARRAY_SORT([NULL]);
-```
-```text
-+--------------------------+--------------------------------+--------------------+
-| array_sort([1, 2, 3, 6]) | array_sort([1, 4, 3, 5, NULL]) |
array_sort([NULL]) |
-+--------------------------+--------------------------------+--------------------+
-| [1, 2, 3, 6] | [null, 1, 3, 4, 5] | [null]
|
-+--------------------------+--------------------------------+--------------------+
-```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-sortby.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-sortby.md
index 727341db109..980a6e9943f 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-sortby.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-sortby.md
@@ -1,92 +1,50 @@
---
{
"title": "ARRAY_SORTBY",
- "language": "en"
+ "language": "en-US"
}
---
-## Description
+## Function
-First, arrange the key column in ascending order, and then return the
corresponding column of the src column sorted in this order as the result;
-Returns NULL if the input array src is NULL.
-If the input array key is NULL, the order in which src is returned remains
unchanged.
-If the input array key element contains NULL, the output sorted array will
place NULL first.
+Sort the `values` array according to the order of a `keys` array.
+- For example, if `keys` is `[3, 0, 2]` and `values` is `[5, 7, 8]`, after
sorting the `keys` become `[0, 2, 3]` and the corresponding `values` become
`[7, 8, 5]`.
## Syntax
-```sql
-ARRAY_SORTBY(<src>, <key>)
-ARRAY_SORTBY(<lambda>, <arr> [, ...])
-```
+- `ARRAY_SORTBY(values, keys)`
+- `ARRAY_SORTBY(lambda, values)`
+- `ARRAY_SORTBY(lambda, values)` is equivalent to `ARRAY_SORTBY(values,
ARRAY_MAP(lambda, values))`
## Parameters
-| Parameter | Description |
-| --- | --- |
-| `<lambda>` | A lambda expression where the input parameters must match the
number of columns in the given array. The expression can execute valid scalar
functions but does not support aggregate functions. |
-| `<arr>` | ARRAY array |
-
-## Return Value
-
-Returns a sorted ARRAY type result.
-
-## Example
-
-```sql
-select array_sortby(['a','b','c'],[3,2,1]);
-```
-
-```text
-+----------------------------------------------------+
-| array_sortby(ARRAY('a', 'b', 'c'), ARRAY(3, 2, 1)) |
-+----------------------------------------------------+
-| ['c', 'b', 'a'] |
-+----------------------------------------------------+
-```
-
-```sql
-select array_sortby([1,2,3,4,5],[10,5,1,20,80]);
-```
-
-```text
-+-------------------------------------------------------------+
-| array_sortby(ARRAY(1, 2, 3, 4, 5), ARRAY(10, 5, 1, 20, 80)) |
-+-------------------------------------------------------------+
-| [3, 2, 1, 4, 5] |
-+-------------------------------------------------------------+
-```
-
-```sql
-select *,array_sortby(c_array1,c_array2) from test_array_sortby order by id;
-```
-
-```text
-+------+-----------------+-------------------------+--------------------------------------+
-| id | c_array1 | c_array2 | array_sortby(`c_array1`,
`c_array2`) |
-+------+-----------------+-------------------------+--------------------------------------+
-| 0 | NULL | [2] | NULL
|
-| 1 | [1, 2, 3, 4, 5] | [10, 20, -40, 80, -100] | [5, 3, 1, 2, 4]
|
-| 2 | [6, 7, 8] | [10, 12, 13] | [6, 7, 8]
|
-| 3 | [1] | [-100] | [1]
|
-| 4 | NULL | NULL | NULL
|
-| 5 | [3] | NULL | [3]
|
-| 6 | [1, 2] | [2, 1] | [2, 1]
|
-| 7 | [NULL] | [NULL] | [NULL]
|
-| 8 | [1, 2, 3] | [3, 2, 1] | [3, 2, 1]
|
-+------+-----------------+-------------------------+--------------------------------------+
-```
-
-```sql
-select *, array_map((x,y)->(y+x),c_array1,c_array2) as
arr_sum,array_sortby((x,y)->(y+x),c_array1,c_array2) as arr_sort from
array_test2;
-```
-
-```text
-+------+-----------------+--------------+----------------+-----------------+
-| id | c_array1 | c_array2 | arr_sum | arr_sort |
-+------+-----------------+--------------+----------------+-----------------+
-| 1 | [1, 2, 3] | [10, 11, 12] | [11, 13, 15] | [1, 2, 3] |
-| 2 | [4, 3, 5] | [10, 20, 30] | [14, 23, 35] | [4, 3, 5] |
-| 3 | [-40, 30, -100] | [30, 10, 20] | [-10, 40, -80] | [-100, -40, 30] |
-+------+-----------------+--------------+----------------+-----------------+
-```
+- `values`: `ARRAY<T>`, the value array to be sorted. `T` supports numeric,
boolean, string, datetime, IP, etc.
+- `keys`: `ARRAY<T>`, a key array of the same length as `values`. `T` supports
numeric, boolean, string, datetime, IP, etc.
+- `lambda`: a `lambda` expression applied to `values` to produce the `keys`
array used for sorting.
+
+## Return value
+
+- Returns `ARRAY<T>` of the same type as `values`.
+- An error is thrown when, for any row, the element counts of `values` and
`keys` are different.
+
+## Usage notes
+
+- Stability: `values` are reordered by ascending `keys`. The relative order
among equal keys is undefined.
+- In higher-order calls, `keys` are computed first by `ARRAY_MAP`, then
`values` are sorted by `keys`.
+
+## Examples
+
+- Basic: sort `values` by the ascending order of `keys`.
+ - `ARRAY_SORTBY([10,20,30], [3,1,2])` -> `[20,30,10]`
+ - `ARRAY_SORTBY(['a','b','c'], [2,2,1])` -> `['c','a','b]`
+
+- Higher-order: compute `keys` via `lambda`, then sort.
+ - `ARRAY_SORTBY(x -> x + 1, [3,1,2])` -> `[1,2,3]` (with `keys` `[4,2,3]`)
+ - `ARRAY_SORTBY(x -> x*2 <= 2, [1,2,3])` -> `[1,2,3]` (with `keys`
`[true,false,false]`)
+
+- When `keys` or `values` is `NULL`, return `values` unchanged.
+ - `array_sortby([10,20,30], NULL)` -> `[10, 20, 30]`
+ - `array_sortby(NULL, [2,3])` -> `NULL`
+
+
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-split.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-split.md
index eeca25df589..0f23efa6c40 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-split.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-split.md
@@ -1,79 +1,53 @@
---
{
"title": "ARRAY_SPLIT",
- "language": "en"
+ "language": "en-US"
}
---
-## Description
+## Function
-1. pass in two `ARRAY` of equal length, the second of which is an
`Array<Boolean>`, and split the `arr` according to the split point to the left
of the position in the `cond` where `true` is found.
-2. Higher-order functions, passed a lambda expression and at least one `ARRAY
arr`, split `arr` by the left-hand side of the `true` position in the
`Array<Boolean>` result of the lambda expression operation.
+Split the input array into multiple subarrays according to given boolean flags.
+
+- Splitting rule (left to right): for `arr=[a1,a2,...,an]` and
`flags=[f1,f2,...,fn]`, at every position where `fi==true`, split between `ai`
and `a(i-1)`.
+ - For example, with `arr=[3, 4, 5]` and `flags=[false, true, false]`, the
second flag is true, so split between the first and second elements, resulting
in two subarrays `[3]` and `[4,5]`.
## Syntax
-```sql
-ARRAY_SPLIT(<arr>, <cond>)
-ARRAY_SPLIT(<lambda>, arr [, ...])
-```
+- `ARRAY_SPLIT(arr, flags)`
+- `ARRAY_SPLIT(lambda, arr0, ...)`
+- `ARRAY_SPLIT(lambda, arr0, ...)` is equivalent to `ARRAY_SPLIT(arr0,
ARRAY_MAP(lambda, arr0, ...))`
## Parameters
-| Parameter | Description |
-| --- | --- |
-| `<lambda>` | A lambda expression where the input parameters must match the
number of columns in the given array. The expression can execute valid scalar
functions but does not support aggregate functions. |
-| `<arr>` | ARRAY array |
-
-## Return Value
-
-Returns an ARRAY type result, where the array is split according to the
specified condition.
-
-## Example
-
-```sql
-select array_split([1,2,3,4,5], [1,0,1,0,0]);
-```
-
-```text
-+-----------------------------------------------------------------------+
-| array_split([1, 2, 3, 4, 5], cast([1, 0, 1, 0, 0] as ARRAY<BOOLEAN>)) |
-+-----------------------------------------------------------------------+
-| [[1, 2], [3, 4, 5]] |
-+-----------------------------------------------------------------------+
-```
-
-```sql
-select array_split((x,y)->y, [1,2,3,4,5], [1,0,0,0,0]);
-```
-
-```text
-+----------------------------------------------------------------------------------------------------------------+
-| array_split([1, 2, 3, 4, 5], cast(array_map((x, y) -> y, [1, 2, 3, 4, 5],
[1, 0, 0, 0, 0]) as ARRAY<BOOLEAN>)) |
-+----------------------------------------------------------------------------------------------------------------+
-| [[1, 2, 3, 4, 5]]
|
-+----------------------------------------------------------------------------------------------------------------+
-```
-
-```sql
-select array_split((x,y)->(y+1), ['a', 'b', 'c', 'd'], [-1, -1, 0, -1]);
-```
-
-```text
-+--------------------------------------------------------------------------------------------------------------------------------+
-| array_split(['a', 'b', 'c', 'd'], cast(array_map((x, y) -> (y + 1), ['a',
'b', 'c', 'd'], [-1, -1, 0, -1]) as ARRAY<BOOLEAN>)) |
-+--------------------------------------------------------------------------------------------------------------------------------+
-| [["a", "b"], ["c", "d"]]
|
-+--------------------------------------------------------------------------------------------------------------------------------+
-```
-
-```sql
-select array_split(x->(year(x)>2013),["2020-12-12", "2013-12-12",
"2015-12-12", null]);
-```
-
-```text
-+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| array_split(['2020-12-12', '2013-12-12', '2015-12-12', NULL], array_map(x ->
(year(cast(x as DATEV2)) > 2013), ['2020-12-12', '2013-12-12', '2015-12-12',
NULL])) |
-+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| [["2020-12-12", "2013-12-12"], ["2015-12-12"], [null]]
|
-+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-```
+- `arr`: `ARRAY<T>`.
+- `flags`: `ARRAY<BOOLEAN>`, whose length must match that of `arr` row by row.
`true` means split between the current position and the next element.
+- `arr0, ...`: one or more `ARRAY<T>`.
+- `lambda`: a `lambda` expression applied to `arr0, ...` to produce `flags`,
which are then used for splitting.
+
+## Return value
+
+- Returns `ARRAY<ARRAY<T>>`. Elements of inner arrays are the same as those of
`arr`.
+- If the element counts of `arr` and `flags` do not match, an error is thrown.
+
+## Usage notes
+
+- If a position in `flags` is `NULL`, it is treated as no split (equivalent to
`false`).
+- The splitting rule of `ARRAY_SPLIT` is: at each position where `fi==true`,
split between `ai` and `a(i-1)`.
+- The splitting rule of `ARRAY_REVERSE_SPLIT` is: at each position where
`fi==true`, split between `ai` and `a(i+1)`.
+
+## Examples
+
+- Basic splitting: at each `true` position, split from the left side neighbor.
+ - `ARRAY_SPLIT([1,2,3,4,5], [false,true,false,true,false])` -> `[[1], [2,
3], [4, 5]]`
+ - `ARRAY_SPLIT(['a','b','c'], [false,false,false])` -> `[['a','b','c']]`
+
+- With `NULL` in `flags`: `NULL` is treated the same as `false` (no split).
+ - `ARRAY_SPLIT([1,NULL,3], [false,null,false])` -> `[[1,[NULL,3]]`
+
+- `lambda= x -> x-1` applied to `arr0=[1, 2, 3]` produces `flags=[0,1,2]`,
equivalent to `flags=[false,true,true]`
+ - `ARRAY_SPLIT(x->x-1, [1, 2, 3])` is equivalent to `ARRAY_SPLIT([1, 2, 3],
[false,true,true])` -> `[[1], [2], [3]]`
+
+- `lambda= (x,y) -> x-y` applied to `arr0=[1, 2, 3]` and `arr1=[0,1,2]`
produces `flags=[true,true,true]`
+ - `ARRAY_SPLIT((x,y) -> x-y, [1, 2, 3], [0, 1, 2])` is equivalent to
`ARRAY_SPLIT([1, 2, 3], [true,true,true])` -> `[[1], [2], [3]]`
+
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/countequal.md
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/countequal.md
index 5d67321e6f8..81ee4d3f269 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/countequal.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/countequal.md
@@ -5,37 +5,41 @@
}
---
-## Description
+## Function
-Determine the number of value elements in the array
+Count the number of elements equal to a given target value within an array.
## Syntax
-```sql
-COUNTEQUAL(<arr>, <value>)
-```
+- `COUNTEQUAL(arr, target)`
## Parameters
-| Parameter | Description |
-|--|--|
-| `<arr>` | Input arrayd |
-| `<value>` | Judging elements |
+- `arr`: `ARRAY<T>`, supported element types include numeric, boolean, string,
datetime, and IP.
+- `target`: same type as elements of `arr`.
-## Return Value
+## Return value
-The returned judgment results are as follows: num: the number of value in
array; 0: value does not exist in array arr; NULL: if the array is NULL.
+- Returns `BIGINT`, representing the count of equal elements.
+
+## Usage notes
+
+- `NULL` equals `NULL` for this function and will be counted.
+
+## Examples
+
+- Basic
+ - `COUNTEQUAL([1,2,3,2], 2)` -> `2`
+ - `COUNTEQUAL(['a','b','a'], 'a')` -> `2`
+ - `COUNTEQUAL([true,false,false], false)` -> `2`
+
+- `NULL` is considered equal and will be counted
+ - `COUNTEQUAL([1,NULL,2,NULL], NULL)` -> `2`
+ - `COUNTEQUAL([1,NULL,1], 1)` -> `2`
+ - `COUNTEQUAL([1, 2], NULL)` -> `0`
+
+- If the array is `NULL`, returns `NULL`
+ - `COUNTEQUAL(NULL, 1)` -> `NULL`
-## Example
-```sql
-SELECT COUNTEQUAL(NULL,1),COUNTEQUAL([1, 2, 3, 'c'],2),COUNTEQUAL([],'b');
-```
-```text
-+---------------------+---------------------------------------------------+------------------------------------------+
-| countequal(NULL, 1) | countequal(['1', '2', '3', 'c'], cast(2 as TEXT)) |
countequal(cast([] as ARRAY<TEXT>), 'b') |
-+---------------------+---------------------------------------------------+------------------------------------------+
-| NULL | 1 |
0 |
-+---------------------+---------------------------------------------------+------------------------------------------+
-```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md
index 03f8349431c..baaed294a17 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md
@@ -1,56 +1,71 @@
---
{
- "title": "ARRAY_RANGE",
+ "title": "ARRAYS_RANGE",
"language": "zh-CN"
}
---
-## 描述
+## 功能
-1. 生成 int 数组
-2. 生成日期时间数组
-
-## 别名
-
-- SEQUENCE
+生成数值或日期时间的等差序列数组。
+- 对于数值类型,默认差值为 1
+- 对于日期时间类型,默认差值为 1 天
## 语法
-```sql
-ARRAY_RANGE(<end>)
-ARRAY_RANGE(<start>, <end>)
-ARRAY_RANGE(<start>, <end>, <step>)
-ARRAY_RANGE(<start_datetime>, <end_datetime>)
-ARRAY_RANGE(<start_datetime>, <end_datetime>, INTERVAL <interval_step> <unit>)
-```
+- `ARRAY_RANGE(end)`
+- `ARRAY_RANGE(start, end)`
+- `ARRAY_RANGE(start, end, step)`
+- `ARRAY_RANGE(start_dt, end_dt)`
+- `ARRAY_RANGE(start_dt, end_dt, interval step unit)`
## 参数
-| 参数 | 说明 |
-|--|--|
-| `<start>` | 起始值,为正整数,默认为 0 |
-| `<end>` | 结束值,为正整数 |
-| `<step>` | 步长,为正整数,默认为 1 |
-| `<start_datetime>` | 起始日期,为 datetimev2 类型 |
-| `<end_datetime>` | 结束日期,为 datetimev2 类型 |
-| `<interval_step>` | 间隔值,默认为 1 |
-| `<unit>` |
间隔单位,支持年(year)/季度(quarter)/月(month)/周(week)/日(day)/小时(hour)/分钟(minute)/秒(second),默认为日(day)
|
+- `start`、`end`:非负整数。`end` 为上界,结果不包含 `end` 本身。
+- `step`:必须是正整数,步长,默认 1。
+- `start_dt`、`end_dt`:DATETIME。两参形式默认步长为 1 DAY。
+- `interval step unit`:日期时间步长,`unit` 取
`YEAR|QUARTER|MONTH|WEEK|DAY|HOUR|MINUTE|SECOND`,`step` 必须为正整数。
## 返回值
-1. 返回一个数组,从 start 到 end - 1, 步长为 step。如果第三个参数 step 为负数或者零,函数结果将为 NULL
-2. 返回 start_datetime 和最接近 end_datetime 之间的 datetimev2 数组(按 Interval_step UNIT
计算)。如果第三个参数 interval_step 为负数或者零,函数结果将为 NULL
+- 返回 `ARRAY<T>`;当参数非法时返回 `NULL`;当范围为空时返回空数组 `[]`。
+- 数组元素类型 `T` 与输入一致:整型返回 `INT`,日期时间返回 `DATETIME`。
+
+## 使用说明
+
+- 数值序列:从 `start` 开始,按 `step` 递增,直到但不包含 `end`(即左闭右开)。
+- 日期时间序列:从 `start_dt` 开始,按给定 `unit` 的 `step` 递增,直到但不包含 `end_dt`;两参形式等价于
`interval 1 day`。
+- 非法参数返回 `NULL`:
+ - 数值:`start < 0`、`end < 0`、`step <= 0`。
+ - 日期时间:`start_dt` 或 `end_dt` 非法,或 `step <= 0`。
+- `ARRAY_RANGE` 和 `SEQUENCE` 函数功能一致。
+
+## 示例
+
+- 数值: `start` 默认从0 开始,`step`默认为 1
+ - `ARRAY_RANGE(5)` -> `[0, 1, 2, 3, 4]`
+ - `ARRAY_RANGE(0, 5)` -> `[0, 1, 2, 3, 4]`
+
+- 数值:`end` 为上界,不在结果之内。
+ - `ARRAY_RANGE(2, 6, 2)` -> `[2, 4]`
+ - `ARRAY_RANGE(3, 3)` -> `[]`
+
+- 数值:`end` 必须大于等于 `start`,否则返回 `[]`
+ - `ARRAY_RANGE(3, 2)` -> `[]`
-## 举例
+- 数值:`start`、`end` 参数必须为非负正数,`step`必须大于 0。
+ - `ARRAY_RANGE(-1, 3)` -> `NULL`
+ - `ARRAY_RANGE(1, 3, 0)` -> `NULL`
-```sql
-SELECT ARRAY_RANGE(0,20,2),ARRAY_RANGE(cast('2019-05-15 12:00:00' as
datetimev2(0)), cast('2022-05-17 12:00:00' as datetimev2(0)), interval 2 year);
-```
+- 日期时间: `step` 默认是 1 day。
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-17 12:00:00')` ->
`['2022-05-15 12:00:00', '2022-05-16 12:00:00']`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-17 12:00:00', interval 1
day)` -> `['2022-05-15 12:00:00', '2022-05-16 12:00:00']`
-```text
-+-------------------------------------+----------------------------------------------------------------------------------------------------------------------+
-| array_range(0, 20, 2) | array_range_year_unit(cast('2019-05-15
12:00:00' as DATETIMEV2(0)), cast('2022-05-17 12:00:00' as DATETIMEV2(0)), 2) |
-+-------------------------------------+----------------------------------------------------------------------------------------------------------------------+
-| [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] | ["2019-05-15 12:00:00", "2021-05-15
12:00:00"]
|
-+-------------------------------------+----------------------------------------------------------------------------------------------------------------------+
-```
+- 日期时间:`unit` 取 `YEAR|QUARTER|MONTH|WEEK|DAY|HOUR|MINUTE|SECOND`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2024-05-17 12:00:00', interval 1
year)` -> `["2022-05-15 12:00:00", "2023-05-15 12:00:00"]`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2023-05-17 12:00:00', interval 1
quarter);` -> `["2022-05-15 12:00:00", "2022-08-15 12:00:00", "2022-11-15
12:00:00", "2023-02-15 12:00:00"] `
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-07-17 12:00:00', interval 1
month);` -> `["2022-05-15 12:00:00", "2022-06-15 12:00:00"]`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-17 12:00:00', interval 1
day)` -> `['2022-05-15 12:00:00', '2022-05-16 12:00:00']`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-15 14:00:00', interval 1
hour)` -> `["2022-05-15 12:00:00", "2022-05-15 13:00:00"]`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-15 12:02:00', interval 1
minute)` -> `["2022-05-15 12:00:00", "2022-05-15 12:01:00"]`
+ - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-15 12:00:02', interval 1
second)` -> `["2022-05-15 12:00:00", "2022-05-15 12:00:01"]`
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-remove.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-remove.md
index 68240e6256f..e42e5c5659a 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-remove.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-remove.md
@@ -5,37 +5,39 @@
}
---
-## 描述
+## 功能
-移除数组中所有的指定元素
+从数组中移除与给定值相等的所有元素,保留其余元素的相对顺序。
## 语法
-```sql
-ARRAY_REMOVE(<arr>, <val>)
-```
+- `ARRAY_REMOVE(arr, target)`
## 参数
-| 参数 | 说明 |
-|--|--|
-| `<arr>` | 对应数组 |
-| `<val>` | 指定元素 |
+- `arr`:`ARRAY<T>`,支持数值、布尔、字符串、日期时间、IP 等。
+- `target`:与数组元素类型一致的值,用于匹配需要移除的元素。
## 返回值
-返回移除所有的指定元素后的数组,如果输入参数为 NULL,则返回 NULL
+- 返回与输入同类型的 `ARRAY<T>`。
+- 若 `arr` 或 `target` 为 `NULL`,返回 `NULL`。
-## 举例
+## 使用说明
+
+- 匹配规则:仅移除与 `target` 值相等的元素;`NULL` 元素不会与任何非 `NULL` 值相等,因此不会被移除。
+
+## 示例
+
+- 基本: 移除后的数组,保留了之前的相对顺序。
+ - `ARRAY_REMOVE([1,2,3], 1)` -> `[2,3]`
+ - `ARRAY_REMOVE([1,2,3,null], 1)` -> `[2,3,null]`
+
+- `arr` 或 `target` 为 `NULL`,返回 `NULL`
+ - `ARRAY_REMOVE(['a','b','c',NULL], NULL)` -> `NULL`
+ - `ARRAY_REMOVE(NULL, 2)` -> `NULL`
+
+- 无匹配情况
+ - `ARRAY_REMOVE([1,2,3], 258)` -> `[1,2,3]`
-```sql
-SELECT ARRAY_REMOVE(['test', NULL, 'value'], 'value');
-```
-```text
-+------------------------------------------------+
-| array_remove(['test', NULL, 'value'], 'value') |
-+------------------------------------------------+
-| ["test", null] |
-+------------------------------------------------+
-```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-repeat.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-repeat.md
index 524700b908d..b83bd830354 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-repeat.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-repeat.md
@@ -5,37 +5,77 @@
}
---
-## 描述
+## 功能
-生成一个包含 n 个重复元素 element 的数组
+`ARRAY_REPEAT` 用于生成一个指定长度的数组,其中所有元素都为给定的值。
## 语法
-```sql
-ARRAY_REPEAT(<element>, <n>)
+```SQL
+ARRAY_REPEAT(element, count)
```
## 参数
-| 参数 | 说明 |
-|--|------|
-| `<n>` | 元数个数 |
-| `<element>` | 指定元素 |
+- `element`: `ARRAY` 类型中支持的所有存储类型。
+
+- `count`:整数类型,指定返回数组的长度。
## 返回值
-返回一个数组,包含 n 个重复的 element 元素。array_with_constant 与 array_repeat 功能相同,用来兼容 hive
语法格式。
+- 返回一个 `ARRAY<T>` 类型的数组,其中 `T` 是 `element` 的类型。
+ - 数组中包含 `count` 个相同的 `element`。
-## 举例
+## 使用说明
-```sql
-SELECT ARRAY_REPEAT("hello", 2),ARRAY_REPEAT(12345, 3);
-```
+- 如果 `count = 0` 或者 `NULL`,返回空数组。
+- 如果 element 为 NULL,数组中所有元素均为 NULL。
+- 函数功能和 `ARRAY_WITH_CONSTANT` 函数相同,参数位置相反。
-```text
-+--------------------------+------------------------+
-| array_repeat('hello', 2) | array_repeat(12345, 3) |
-+--------------------------+------------------------+
-| ["hello", "hello"] | [12345, 12345, 12345] |
-+--------------------------+------------------------+
-```
+## 示例
+
+1. 简单实例
+
+ ```SQL
+ SELECT ARRAY_REPEAT('hello', 3);
+ +---------------------------------+
+ | ARRAY_REPEAT('hello', 3) |
+ +---------------------------------+
+ | ["hello", "hello", "hello"] |
+ +---------------------------------+
+ ```
+
+2. 异常参数
+
+ ```SQL
+ SELECT ARRAY_REPEAT('hello', 0);
+ +---------------------------------+
+ | ARRAY_REPEAT('hello', 0) |
+ +---------------------------------+
+ | [] |
+ +---------------------------------+
+
+ SELECT ARRAY_REPEAT('hello', NULL);
+ +------------------------------------+
+ | ARRAY_REPEAT('hello', NULL) |
+ +------------------------------------+
+ | [] |
+ +------------------------------------+
+
+ SELECT ARRAY_REPEAT(NULL, 2);
+ +------------------------------+
+ | ARRAY_REPEAT(NULL, 2) |
+ +------------------------------+
+ | [null, null] |
+ +------------------------------+
+
+ SELECT ARRAY_REPEAT(NULL, NULL);
+ +---------------------------------+
+ | ARRAY_REPEAT(NULL, NULL) |
+ +---------------------------------+
+ | [] |
+ +---------------------------------+
+
+ -- 返回错误:INVALID_ARGUMENT
+ SELECT ARRAY_REPEAT('hello', -1);
+ ```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-sort.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-sort.md
index 93b62c13ee9..7ea25010776 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-sort.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-sort.md
@@ -5,36 +5,35 @@
}
---
-## 描述
+## 功能
-将数组中的元素降序排列
+对数组元素按降序排序。
## 语法
-```sql
-ARRAY_REVERSE_SORT(<arr>)
-```
+- `ARRAY_REVERSE_SORT(arr)`
## 参数
-| 参数 | 说明 |
-|--|--|
-| `<arr>` | 对应数组 |
+- `arr`:`ARRAY<T>`,`T` 可为数值、布尔、字符串、日期时间、IP 等。
## 返回值
-返回按降序排列后的数组,如果输入数组为 NULL,则返回 NULL。如果数组元素包含 NULL, 则输出的排序数组会将 NULL 放在最后面。
+- 返回与输入同类型的 `ARRAY<T>`。
+- `NULL` 元素放在返回的数组最后面。
-## 举例
+## 使用说明
+
+- 若输入为 `NULL`,返回 `NULL`; 若输入为空数组 `[]`,返回空数组。
+- `ARRAY_REVERSE_SORT` 是降序排序, `ARRAY_SORT` 是升序排序。
+
+## 示例
+
+- 基本: `NULL` 元素放在返回的数组最后面
+ - `ARRAY_REVERSE_SORT([1,2,3,null])` -> `[3,2,1,null]`
+
+- 输入为 `NULL`,返回 `NULL`; 输入为空数组 `[]`,返回空数组。
+ - `ARRAY_REVERSE_SORT(NULL)` -> `NULL`
+ - `ARRAY_REVERSE_SORT([])` -> `[]`
-```sql
-SELECT ARRAY_REVERSE_SORT([1, 2, 3, 6]),ARRAY_REVERSE_SORT([1, 4, 3, 5,
NULL]),ARRAY_REVERSE_SORT([NULL]);
-```
-```text
-+----------------------------------+----------------------------------------+----------------------------+
-| array_reverse_sort([1, 2, 3, 6]) | array_reverse_sort([1, 4, 3, 5, NULL]) |
array_reverse_sort([NULL]) |
-+----------------------------------+----------------------------------------+----------------------------+
-| [6, 3, 2, 1] | [5, 4, 3, 1, null] |
[null] |
-+----------------------------------+----------------------------------------+----------------------------+
-```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-split.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-split.md
index 84c8cc003e5..392a8cb7ecd 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-split.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-reverse-split.md
@@ -5,75 +5,48 @@
}
---
-## 描述
+## 功能
-1. 传入两个长度相等的 `ARRAY` 且第二个为 `Array<Boolean>`,按照 `cond` 中为 `true` 的位置右侧作为分割点,分割
`arr` 数组。
-2. 高阶函数,传入一个 lambda 表达式和至少一个 `arr`,则按照 lambda 表达式运算得到的 `Array<Boolean>` 结果,其中为
`true` 的位置右侧作为分割点,分割 `arg0` 。
+按给定的布尔标记把输入的数组切分为多个子数组。
+
+- 切分规则(从前向后):对 `arr=[a1,a2,...,an]` 与 `flags=[f1,f2,...,fn]`,在每个 `fi==true`
的位置,于 `ai` 与 `a(i+1)` 之间断开。
+ - 例如 `arr=[3, 4, 5]`,`flags=[false, true, false]`, `flags`
第二个为true,在第二个元素和第三元素之间断开,分成两个子数组 `[3, 4]` 和 `[5]`。
## 语法
-```sql
-ARRAY_REVERSE_SPLIT(<arr>, <cond>)
-ARRAY_REVERSE_SPLIT(<lambda>, <arr> [, ...])
-```
+- `ARRAY_REVERSE_SPLIT(arr, flags)`
+- `ARRAY_REVERSE_SPLIT(lamda, arr0, ...)`
+- `ARRAY_REVERSE_SPLIT(lambda, arr0, ...)` 相当于 `ARRAY_REVERSE_SPLIT(arr0,
ARRAY_MAP(lambda, arr0, ...))`
## 参数
-| 参数 | 说明 |
-| --- |---|
-| `<lambda>` | lambda 表达式,表达式中输入的参数为 1 个或多个,必须和后面的输入 array 列数量一致。在 lambda
中可以执行合法的标量函数,不支持聚合函数等。 |
-| `<arr>` | ARRAY 数组 |
+- `arr`:`ARRAY<T>`。
+- `flags`:`ARRAY<BOOLEAN>`,长度需与 `arr` 的长度逐行一致。`true` 表示在当前位置与下一元素之间断开。
+- `arr0, ...` 一个或多个 `ARRAY<T>`。
+- `lambda`: `lambda` 表达式作用于 `arr0, ...` 产生`flags`,利用产生的 `flags` 进行分割。
## 返回值
-返回一个 ARRAY 类型的结果,其中按照对应条件分割后的数组
-
-## 举例
-
-```sql
-select array_reverse_split([1,2,3,4,5], [1,0,1,0,0]);
-```
-
-```text
-+-------------------------------------------------------------------------------+
-| array_reverse_split([1, 2, 3, 4, 5], cast([1, 0, 1, 0, 0] as
ARRAY<BOOLEAN>)) |
-+-------------------------------------------------------------------------------+
-| [[1], [2, 3], [4, 5]]
|
-+-------------------------------------------------------------------------------+
-```
-
-```sql
-select array_reverse_split((x,y)->y, [1,2,3,4,5], [1,0,0,0,0]);
-```
-
-```text
-+------------------------------------------------------------------------------------------------------------------------+
-| array_reverse_split([1, 2, 3, 4, 5], cast(array_map((x, y) -> y, [1, 2, 3,
4, 5], [1, 0, 0, 0, 0]) as ARRAY<BOOLEAN>)) |
-+------------------------------------------------------------------------------------------------------------------------+
-| [[1], [2, 3, 4, 5]]
|
-+------------------------------------------------------------------------------------------------------------------------+
-```
-
-```sql
-select array_reverse_split((x,y)->(y+1), ['a', 'b', 'c', 'd'], [-1, -1, 0,
-1]);
-```
-
-```text
-+----------------------------------------------------------------------------------------------------------------------------------------+
-| array_reverse_split(['a', 'b', 'c', 'd'], cast(array_map((x, y) -> (y + 1),
['a', 'b', 'c', 'd'], [-1, -1, 0, -1]) as ARRAY<BOOLEAN>)) |
-+----------------------------------------------------------------------------------------------------------------------------------------+
-| [["a", "b", "c"], ["d"]]
|
-+----------------------------------------------------------------------------------------------------------------------------------------+
-```
-
-```sql
-select array_reverse_split(x->(year(x)>2013),["2020-12-12", "2013-12-12",
"2015-12-12", null]);
-```
-
-```text
-+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| array_reverse_split(['2020-12-12', '2013-12-12', '2015-12-12', NULL],
array_map(x -> (year(cast(x as DATEV2)) > 2013), ['2020-12-12', '2013-12-12',
'2015-12-12', NULL])) |
-+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| [["2020-12-12"], ["2013-12-12", "2015-12-12"], [null]]
|
-+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-```
+- 返回 `ARRAY<ARRAY<T>>`。内层数组元素与 `arr` 一致。
+- 若`arr` 与 `flags` 的元素个数不一致,将报错。
+
+## 使用说明
+
+- 如果 `flags` 的某位置为 `NULL`,视为不切分(与 `false` 等价)。
+- `ARRAY_REVERSE_SPLIT` 的切分规则是:在每个 `fi==true` 的位置,于 `ai` 与 `a(i+1)` 之间断开。
+- `ARRAY_SPLIT` 的切分规则是:在每个 `fi==true` 的位置,于 `ai` 与 `a(i-1)` 之间断开。
+
+## 示例
+
+- 基本切分: 在每个 `true` 的位置,与右侧元素断开。
+ - `ARRAY_REVERSE_SPLIT([1,2,3,4,5], [false,true,false,true,false])` ->
`[[1,2], [3,4], [5]]`
+ - `ARRAY_REVERSE_SPLIT(['a','b','c'], [false,false,false])` ->
`[['a','b','c']]`
+
+- `flags` 中包含 `NULL`, `NULL` 被认为和 `false` 一样,不切分。
+ - `ARRAY_REVERSE_SPLIT([1,NULL,3], [false,null,false])` -> `[[1,[NULL,3]]`
+
+- `lambda= x -> x-1` 作用于 `arr=[1, 2, 3]` 产生 `flags=[0,1,2]`,相当于
`flags=[false,true,true]`
+ - `ARRAY_REVERSE_SPLIT(x->x-1, [1, 2, 3])` 相当于 `ARRAY_REVERSE_SPLIT([1, 2,
3], [false,true,true])` -> `[[1, 2], [3]]`
+
+- `lambda= (x,y) -> x-y` 作用于 `arr=[1, 2, 3]` 和 `arr1=[0,1,2]`, 产生
`flags=[true,true,true]`
+ - `ARRAY_REVERSE_SPLIT((x,y) -> x-y, [1, 2, 3], [0, 1, 2])` 相当于
`ARRAY_REVERSE_SPLIT([1, 2, 3], [true,true,true])` -> `[[1], [2], [3]]`
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-shuffle.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-shuffle.md
index dcc27a26699..88e57d104c8 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-shuffle.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-shuffle.md
@@ -5,41 +5,36 @@
}
---
-## 描述
+## 功能
-将数组中元素进行随机排列
-
-## 别名
-
-- SHUFFLE
+`ARRAY_SHUFFLE` 用来随机打乱数组内元素的顺序。
## 语法
-```sql
-ARRAY_SHUFFLE(<array>, <seed>)
-```
+- `ARRAY_SHUFFLE(arr)`
+- `ARRAY_SHUFFLE(arr, seed)`
## 参数
-| 参数 | 说明 |
-|--|--|
-| `<array>` | 要进行随机排列的数组 |
-| `<seed>` | 可选参数,是设定伪随机数生成器用于生成伪随机数的初始数值 |
+- `arr`:`ARRAY<T>`。
+- `seed`:可选,表示随机数种子。
## 返回值
-将数组中元素进行随机排列。其中,参数 array1 为要进行随机排列的数组,可选参数 seed
是设定伪随机数生成器用于生成伪随机数的初始数值。shuffle 与 array_shuffle 功能相同。
+- 返回与输入同类型的数组,元素被随机重排,元素数量与类型均保持不变。
+
+## 使用说明
+
+- 输入的 `arr` 是 `NULL` 时,返回 `NULL`。
+- 指定 `seed` 可获得可复现结果;不指定则每次执行结果可能不同。
+- `ARRAY_SHUFFLE`的函数别名是 `SHUFFLE`,两个函数功能一致。
+-
-## 举例
+## 示例
-```sql
-SELECT ARRAY_SHUFFLE([1, 2, 3, 6]),ARRAY_SHUFFLE([1, 4, 3, 5, NULL],1);
-```
+- 基本用法:
+ - `ARRAY_SHUFFLE([1, 2, 3, 4])` -> 例如 `[3, 1, 4, 2]`(顺序随机)
+ - `ARRAY_SHUFFLE(['a', null, 'b'])` -> 例如 `['b', 'a', null]`
-```text
-+-----------------------------+--------------------------------------+
-| array_shuffle([1, 2, 3, 6]) | array_shuffle([1, 4, 3, 5, NULL], 1) |
-+-----------------------------+--------------------------------------+
-| [2, 6, 3, 1] | [4, 1, 3, 5, null] |
-+-----------------------------+--------------------------------------+
-```
+- 指定种子(结果可复现):
+ - `ARRAY_SHUFFLE([1, 2, 3, 4], 0)` -> 每次执行均得到相同顺序(如 `[1, 3, 2, 4]`)
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-size.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-size.md
index f5fdba5f6f8..d6a1d6e51e7 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-size.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-size.md
@@ -5,41 +5,31 @@
}
---
-## 描述
+## 功能
-计算数组中元素的数量
-
-## 别名
-
-- SIZE
-- CARDINALITY
+返回数组的元素个数。
## 语法
-```sql
-ARRAY_SIZE(<arr>)
-```
+- `ARRAY_SIZE(arr)`
## 参数
-| 参数 | 说明 |
-|--|--|
-| `<arr>` | 待计算的数组 |
+- `arr`:`ARRAY<T>`。
## 返回值
-返回数组中元素数量,如果输入数组为 NULL,则返回 NULL
+- 返回 `arr` 有多少个元素。
+
+## 使用说明
+
+- 输入的 `arr` 是 `NULL` 时,返回 `NULL`。
-## 举例
+## 示例
-```sql
-SELECT ARRAY_SIZE(['a', 'b', 'c']),ARRAY_SIZE([NULL]),ARRAY_SIZE([]);
-```
+- 数组:
+ - `ARRAY_SIZE([1, 2, 3])` -> `3`
+ - `ARRAY_SIZE(['a', NULL, 'b'])` -> `3`
-```text
-+------------------------------+---------------------+-----------------+
-| cardinality(['a', 'b', 'c']) | cardinality([NULL]) | cardinality([]) |
-+------------------------------+---------------------+-----------------+
-| 3 | 1 | 0 |
-+------------------------------+---------------------+-----------------+
-```
+- 输入的 `arr` 是 `NULL` 时,返回 `NULL`
+ - `ARRAY_SIZE(NULL)` -> `NULL`
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-slice.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-slice.md
index 51beb005d22..5b9333ff56a 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-slice.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-slice.md
@@ -5,38 +5,50 @@
}
---
-## 描述
+## 功能
-指定起始位置和长度,从一个数组中提取一部分元素,形成一个新的子数组
+返回数组的子片段,支持起始偏移与长度。
## 语法
-```sql
-ARRAY_SLICE(<arr>, <off>, <len>)
-```
+- `ARRAY_SLICE(arr, offset)`
+- `ARRAY_SLICE(arr, offset, length)`
## 参数
-| 参数 | 说明 |
-|--|--|
-| `<arr>` | 对应数组 |
-| `<off>` | 起始位置,如果 off 是正数,则表示从左侧开始的偏移量,如果 off 是负数,则表示从右侧开始的偏移量,当指定的 off
不在数组的实际范围内,返回空数组 |
-| `<len>` | 提前长度,如果 len 是负数,则表示长度为 0 |
+- `arr`:`ARRAY<T>`。
+- `offset`:表示起点。正数从头部计数(`1` 表示第一个元素),负数从尾部计数(`-1` 表示最后一个元素)。
+- `length`:表示长度。为正表示取 `length` 个元素;为负表示长度为 0。
## 返回值
-返回一个子数组,包含所有从指定位置开始的指定长度的元素,如果输入参数为 NULL,则返回 NULL
+- 返回与输入同类型的 `ARRAY<T>`。
-## 举例
+## 使用说明
+
+- 越界安全:起点与终点会被裁剪到数组边界以内,若无重叠则返回空数组。
+
+## 示例
+
+- 指定正数起点:从起点直到左侧末尾
+ - `ARRAY_SLICE([1,2,3,4,5,6], 2)` -> `[2,3,4,5,6]`
+
+- 指定负数起点:从起点直到左侧末尾
+ - `ARRAY_SLICE([1,2,3,4,5,6], -3)` -> `[4,5,6]`
+
+- 指定正数长度,从起点向右取
+ - `ARRAY_SLICE([1,2,3,4,5,6], 2, 3)` -> `[2,3,4]`
+ - `ARRAY_SLICE([1,2,3,4,5,6], -4, 2)` -> `[3,4]`
+
+- 指定负数长度,认为长度为 0
+ - `ARRAY_SLICE([1,2,3,4,5,6], 2, -2)` -> `[]`
+
+- 参数越界,返回空数组
+ - `ARRAY_SLICE([1,2,3,4,5,6], 10, 3)` -> `[]`
+
+- 参数为 `NULL`,返回 `NULL`
+ - `ARRAY_SLICE([1,2,3], NULL, 2)` -> `NULL`
+ - `ARRAY_SLICE([1,2,3], 2, NULL)` -> `NULL`
+ - `ARRAY_SLICE(NULL, 2, 3)` -> `NULL`
-```sql
-SELECT ARRAY_SLICE([1, 2, 3, 6],2,3),ARRAY_SLICE([1, 4, 3, 5,
NULL],-2,1),ARRAY_SLICE([1, 3, 5],0);
-```
-```text
-+---------------------------------+----------------------------------------+---------------------------+
-| array_slice([1, 2, 3, 6], 2, 3) | array_slice([1, 4, 3, 5, NULL], -2, 1) |
array_slice([1, 3, 5], 0) |
-+---------------------------------+----------------------------------------+---------------------------+
-| [2, 3, 6] | [5] |
[] |
-+---------------------------------+----------------------------------------+---------------------------+
-```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-sort.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-sort.md
index 8972cd1c523..60e25884408 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-sort.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-sort.md
@@ -5,36 +5,35 @@
}
---
-## 描述
+## 功能
-将数组中的元素升序排列
+对数组元素按升序排序。
## 语法
-```sql
-ARRAY_SORT(<arr>)
-```
+- `ARRAY_SORT(arr)`
## 参数
-| 参数 | 说明 |
-|--|--|
-| `<arr>` | 对应数组 |
+- `arr`:`ARRAY<T>`,`T` 可为数值、布尔、字符串、日期时间、IP 等。
## 返回值
-返回按升序排列后的数组,如果输入数组为 NULL,则返回 NULL。如果数组元素包含 NULL, 则输出的排序数组会将 NULL 放在最前面。
+- 返回与输入同类型的 `ARRAY<T>`。
+- `NULL` 元素放在返回的数组最前面。
-## 举例
+## 使用说明
+
+- 若输入为 `NULL`,返回 `NULL`; 若输入为空数组 `[]`,返回空数组。
+- `ARRAY_SORT` 是升序排序,`ARRAY_REVERSE_SORT` 是降序排序。
+
+## 示例
+
+- 基本: `NULL` 元素放在返回的数组最后面
+ - `ARRAY_SORT([2,1,3,null])` -> `[null, 1, 2, 3]`
+
+- 输入为 `NULL`,返回 `NULL`; 输入为空数组 `[]`,返回空数组。
+ - `ARRAY_SORT(NULL)` -> `NULL`
+ - `ARRAY_SORT([])` -> `[]`
-```sql
-SELECT ARRAY_SORT([1, 2, 3, 6]),ARRAY_SORT([1, 4, 3, 5,
NULL]),ARRAY_SORT([NULL]);
-```
-```text
-+--------------------------+--------------------------------+--------------------+
-| array_sort([1, 2, 3, 6]) | array_sort([1, 4, 3, 5, NULL]) |
array_sort([NULL]) |
-+--------------------------+--------------------------------+--------------------+
-| [1, 2, 3, 6] | [null, 1, 3, 4, 5] | [null]
|
-+--------------------------+--------------------------------+--------------------+
-```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-sortby.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-sortby.md
index 190905e6540..29cb49eb216 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-sortby.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-sortby.md
@@ -5,87 +5,44 @@
}
---
-## 描述
+## 功能
-首先将 key 列升序排列,然后将 src 列按此顺序排序后的对应列做为结果返回;
-如果输入数组 src 为 NULL,则返回 NULL。
-如果输入数组 key 为 NULL,则直接返回 src 数组。
-如果输入数组 key 元素包含 NULL, 则输出的排序数组会将 NULL 放在最前面。
+依据 `key数组`的顺序对 `value数组`进行排序。
+- 例如 `key数组` 是 `[3, 0, 2]`, `value数组` 是 `[5, 7, 8]`,排序后的 `key数组` 是 `[0, 2,
3]`,对应的 `value数组` 是 `[7, 8, 5]`。
## 语法
-```sql
-ARRAY_SORTBY(<src>, <key>)
-ARRAY_SORTBY(<lambda>, <arr> [, ...])
-```
+- `ARRAY_SORTBY(values, keys)`
+- `ARRAY_SORTBY(lambda, values)`
+- `ARRAY_SORTBY(lambda, values)` 相当于 `ARRAY_SORTBY(values, ARRAY_MAP(lambda,
values))`
## 参数
-| 参数 | 说明 |
-| --- |---|
-| `<lambda>` | lambda 表达式,表达式中输入的参数为 1 个或多个,必须和后面的输入 array 列数量一致。在 lambda
中可以执行合法的标量函数,不支持聚合函数等。 |
-| `<arr>` | ARRAY 数组 |
+- `values`:`ARRAY<T>`,要排序的 value 数组,`T`只支持:数值,布尔,字符串,时间日期,IP 等类型。
+- `keys`:`ARRAY<T>`,与 `arr` 等长的 key 数组,`T`只支持:数值,布尔,字符串,时间日期,IP 等类型。
+- `lambda`: `lambda` 表达式作用于 `values`, 产生 `key 数组`,利用产生的 `key 数组` 进行排序。
## 返回值
-返回一个排序后的 ARRAY 类型的结果
+- 返回与 `values` 同类型的 `ARRAY<T>`。
+- 当某行 `arr` 与 `keys` 的元素个数不等时报错。
-## 举例
+## 使用说明
-```sql
-select array_sortby(['a','b','c'],[3,2,1]);
-```
+- 排序稳定性:以`keys`的升序重排 `values`,`keys`中相等键的相对次序未定义。
+- 高阶调用会先用 `ARRAY_MAP` 计算`keys`,再按`keys`对 `values` 排序。
-```text
-+----------------------------------------------------+
-| array_sortby(ARRAY('a', 'b', 'c'), ARRAY(3, 2, 1)) |
-+----------------------------------------------------+
-| ['c', 'b', 'a'] |
-+----------------------------------------------------+
-```
+## 示例
-```sql
-select array_sortby([1,2,3,4,5],[10,5,1,20,80]);
-```
+- 基本用法: 先对 `keys` 进行升序排序,再对 `values` 按照对应的 `keys` 排序。
+ - `ARRAY_SORTBY([10,20,30], [3,1,2])` -> `[20,30,10]`
+ - `ARRAY_SORTBY(['a','b','c'], [2,2,1])` -> `['c','a','b]`
-```text
-+-------------------------------------------------------------+
-| array_sortby(ARRAY(1, 2, 3, 4, 5), ARRAY(10, 5, 1, 20, 80)) |
-+-------------------------------------------------------------+
-| [3, 2, 1, 4, 5] |
-+-------------------------------------------------------------+
-```
+- 高阶用法:先执行 `lambda` 表达式产生 `keys`,然后再排序。
+ - `ARRAY_SORTBY(x -> x + 1, [3,1,2])` -> `[1,2,3]` ( `key`为 `[4,2,3]`)
+ - `ARRAY_SORTBY(x -> x*2 <= 2, [1,2,3])` -> `[1,2,3]`( `key`为
`[true,false,false]`)
-```sql
-select *,array_sortby(c_array1,c_array2) from test_array_sortby order by id;
-```
+- 当 `keys` 或者 `values` 为 `NULL` 时,返回 `values` 保持不变。
+ - `array_sortby([10,20,30], NULL)` -> `[10, 20, 30]`
+ - `array_sortby(NULL, [2,3])` -> `NULL`
-```text
-+------+-----------------+-------------------------+--------------------------------------+
-| id | c_array1 | c_array2 | array_sortby(`c_array1`,
`c_array2`) |
-+------+-----------------+-------------------------+--------------------------------------+
-| 0 | NULL | [2] | NULL
|
-| 1 | [1, 2, 3, 4, 5] | [10, 20, -40, 80, -100] | [5, 3, 1, 2, 4]
|
-| 2 | [6, 7, 8] | [10, 12, 13] | [6, 7, 8]
|
-| 3 | [1] | [-100] | [1]
|
-| 4 | NULL | NULL | NULL
|
-| 5 | [3] | NULL | [3]
|
-| 6 | [1, 2] | [2, 1] | [2, 1]
|
-| 7 | [NULL] | [NULL] | [NULL]
|
-| 8 | [1, 2, 3] | [3, 2, 1] | [3, 2, 1]
|
-+------+-----------------+-------------------------+--------------------------------------+
-```
-
-```sql
-select *, array_map((x,y)->(y+x),c_array1,c_array2) as
arr_sum,array_sortby((x,y)->(y+x),c_array1,c_array2) as arr_sort from
array_test2;
-```
-
-```text
-+------+-----------------+--------------+----------------+-----------------+
-| id | c_array1 | c_array2 | arr_sum | arr_sort |
-+------+-----------------+--------------+----------------+-----------------+
-| 1 | [1, 2, 3] | [10, 11, 12] | [11, 13, 15] | [1, 2, 3] |
-| 2 | [4, 3, 5] | [10, 20, 30] | [14, 23, 35] | [4, 3, 5] |
-| 3 | [-40, 30, -100] | [30, 10, 20] | [-10, 40, -80] | [-100, -40, 30] |
-+------+-----------------+--------------+----------------+-----------------+
-```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-split.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-split.md
index aca2658b79e..c753c17c2dd 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-split.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-split.md
@@ -5,75 +5,48 @@
}
---
-## 描述
+## 功能
-1. 传入两个长度相等的 `ARRAY` 且第二个为 `Array<Boolean>`,则按照 `cond` 中为 `true` 的位置左侧作为分割点,分割
`arr` 。
-2. 高阶函数,传入一个 lambda 表达式和至少一个 `ARRAY arr`,则按照 lambda 表达式运算得到的 `Array<Boolean>`
结果,其中为 `true` 的位置左侧作为分割点,分割 `arr` 。
+按给定的布尔标记把输入的数组切分为多个子数组。
+
+- 切分规则(从前向后):对 `arr=[a1,a2,...,an]` 与 `flags=[f1,f2,...,fn]`,在每个 `fi==true`
的位置,于 `ai` 与 `a(i-1)` 之间断开。
+ - 例如 `arr=[3, 4, 5]`,`flags=[false, true, false]`, `flags`
第二个为true,在第一个元素和第二元素之间断开,分成两个子数组 `[3]` 和 `[4,5]`。
## 语法
-```sql
-ARRAY_SPLIT(<arr>, <cond>)
-ARRAY_SPLIT(<lambda>, arr [, ...])
-```
+- `ARRAY_SPLIT(arr, flags)`
+- `ARRAY_SPLIT(lambda, arr0, ...)`
+- `ARRAY_SPLIT(lambda, arr0, ...)` 相当于 `ARRAY_SPLIT(arr0, ARRAY_MAP(lambda,
arr0, ...))`
## 参数
-| 参数 | 说明 |
-| --- |---|
-| `<lambda>` | lambda 表达式,表达式中输入的参数为 1 个或多个,必须和后面的输入 array 列数量一致。在 lambda
中可以执行合法的标量函数,不支持聚合函数等。 |
-| `<arr>` | ARRAY 数组 |
+- `arr`:`ARRAY<T>`。
+- `flags`:`ARRAY<BOOLEAN>`,长度需与 `arr` 的长度逐行一致。`true` 表示在当前位置与下一元素之间断开。
+- `arr0, ...` 一个或多个 `ARRAY<T>`。
+- `lambda`: `lambda` 表达式作用于 `arr0, ...` 产生`flags`,利用产生的 `flags` 进行分割。
## 返回值
-返回一个 ARRAY 类型的结果,其中按照对应条件分割后的数组
-
-## 举例
-
-```sql
-select array_split([1,2,3,4,5], [1,0,1,0,0]);
-```
-
-```text
-+-----------------------------------------------------------------------+
-| array_split([1, 2, 3, 4, 5], cast([1, 0, 1, 0, 0] as ARRAY<BOOLEAN>)) |
-+-----------------------------------------------------------------------+
-| [[1, 2], [3, 4, 5]] |
-+-----------------------------------------------------------------------+
-```
-
-```sql
-select array_split((x,y)->y, [1,2,3,4,5], [1,0,0,0,0]);
-```
-
-```text
-+----------------------------------------------------------------------------------------------------------------+
-| array_split([1, 2, 3, 4, 5], cast(array_map((x, y) -> y, [1, 2, 3, 4, 5],
[1, 0, 0, 0, 0]) as ARRAY<BOOLEAN>)) |
-+----------------------------------------------------------------------------------------------------------------+
-| [[1, 2, 3, 4, 5]]
|
-+----------------------------------------------------------------------------------------------------------------+
-```
-
-```sql
-select array_split((x,y)->(y+1), ['a', 'b', 'c', 'd'], [-1, -1, 0, -1]);
-```
-
-```text
-+--------------------------------------------------------------------------------------------------------------------------------+
-| array_split(['a', 'b', 'c', 'd'], cast(array_map((x, y) -> (y + 1), ['a',
'b', 'c', 'd'], [-1, -1, 0, -1]) as ARRAY<BOOLEAN>)) |
-+--------------------------------------------------------------------------------------------------------------------------------+
-| [["a", "b"], ["c", "d"]]
|
-+--------------------------------------------------------------------------------------------------------------------------------+
-```
-
-```sql
-select array_split(x->(year(x)>2013),["2020-12-12", "2013-12-12",
"2015-12-12", null]);
-```
-
-```text
-+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| array_split(['2020-12-12', '2013-12-12', '2015-12-12', NULL], array_map(x ->
(year(cast(x as DATEV2)) > 2013), ['2020-12-12', '2013-12-12', '2015-12-12',
NULL])) |
-+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| [["2020-12-12", "2013-12-12"], ["2015-12-12"], [null]]
|
-+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-```
+- 返回 `ARRAY<ARRAY<T>>`。内层数组元素与 `arr` 一致。
+- 若`arr` 与 `flags` 的元素个数不一致,将报错。
+
+## 使用说明
+
+- 如果 `flags` 的某位置为 `NULL`,视为不切分(与 `false` 等价)。
+- `ARRAY_SPLIT` 的切分规则是:在每个 `fi==true` 的位置,于 `ai` 与 `a(i-1)` 之间断开。
+- `ARRAY_REVERSE_SPLIT` 的切分规则是:在每个 `fi==true` 的位置,于 `ai` 与 `a(i+1)` 之间断开。
+
+## 示例
+
+- 基本切分: 在每个 `true` 的位置,与左侧元素断开。
+ - `ARRAY_SPLIT([1,2,3,4,5], [false,true,false,true,false])` -> `[[1], [2,
3], [4, 5]]`
+ - `ARRAY_SPLIT(['a','b','c'], [false,false,false])` -> `[['a','b','c']]`
+
+- `flags` 中包含 `NULL`, `NULL` 被认为和 `false` 一样,不切分。
+ - `ARRAY_SPLIT([1,NULL,3], [false,null,false])` -> `[[1,[NULL,3]]`
+
+- `lambda= x -> x-1` 作用于 `arr0=[1, 2, 3]` 产生 `flags=[0,1,2]`,相当于
`flags=[false,true,true]`
+ - `ARRAY_SPLIT(x->x-1, [1, 2, 3])` 相当于 `ARRAY_SPLIT([1, 2, 3],
[false,true,true])` -> `[[1], [2], [3]]`
+
+- `lambda= (x,y) -> x-y` 作用于 `arr0=[1, 2, 3]` 和 `arr1=[0,1,2]`, 产生
`flags=[true,true,true]`
+ - `ARRAY_SPLIT((x,y) -> x-y, [1, 2, 3], [0, 1, 2])` 相当于 `ARRAY_SPLIT([1, 2,
3], [true,true,true])` -> `[[1], [2], [3]]`
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/countequal.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/countequal.md
index 29980c63cec..fb7aa39fdf8 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/countequal.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/countequal.md
@@ -5,37 +5,40 @@
}
---
-## 描述
+## 功能
-判断数组中包含 value 元素的个数
+统计数组中与指定目标值相等的元素个数。
## 语法
-```sql
-COUNTEQUAL(<arr>, <value>)
-```
+- `COUNTEQUAL(arr, target)`
## 参数
-| 参数 | 说明 |
-|--|------|
-| `<arr>` | 输入数组 |
-| `<value>` | 判断元素 |
+- `arr`:`ARRAY<T>`,支持的元素类型包括:数值、布尔、字符串、日期时间、IP。
+- `target`:与 `arr` 元素类型一致。
## 返回值
-返回判断的结果如下:num:value 在 array 中的数量;0:value 不存在数组 arr 中;NULL:如果数组为 NULL。
+- 返回 `BIGINT`,表示相等的元素个数。
-## 举例
+## 使用说明
+
+- 两端都是 `NULL` 视为相等,会被计数。
+
+## 示例
+
+- 基本
+ - `COUNTEQUAL([1,2,3,2], 2)` -> `2`
+ - `COUNTEQUAL(['a','b','a'], 'a')` -> `2`
+ - `COUNTEQUAL([true,false,false], false)` -> `2`
+
+- `NULL` 视为相等,会被计数
+ - `COUNTEQUAL([1,NULL,2,NULL], NULL)` -> `2`
+ - `COUNTEQUAL([1,NULL,1], 1)` -> `2`
+ - `COUNTEQUAL([1, 2], NULL)` -> `0`
+
+- 数组是 `NULL`,返回 `NULL`
+ - `COUNTEQUAL(NULL, 1)` -> `NULL`
-```sql
-SELECT COUNTEQUAL(NULL,1),COUNTEQUAL([1, 2, 3, 'c'],2),COUNTEQUAL([],'b');
-```
-```text
-+---------------------+---------------------------------------------------+------------------------------------------+
-| countequal(NULL, 1) | countequal(['1', '2', '3', 'c'], cast(2 as TEXT)) |
countequal(cast([] as ARRAY<TEXT>), 'b') |
-+---------------------+---------------------------------------------------+------------------------------------------+
-| NULL | 1 |
0 |
-+---------------------+---------------------------------------------------+------------------------------------------+
-```
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]