From 4325fdc99d2dc4b694bff56a53f9256ea96fac75 Mon Sep 17 00:00:00 2001 From: Mryange Date: Wed, 26 Aug 2026 10:55:13 +0800 Subject: [PATCH 1/2] [doc](function) Add array_except_all documentation --- .../array-functions/array-except-all.md | 122 ++++++++++++++++++ .../array-functions/array-except-all.md | 122 ++++++++++++++++++ .../array-functions/array-except-all.md | 122 ++++++++++++++++++ sidebars.ts | 1 + .../array-functions/array-except-all.md | 122 ++++++++++++++++++ versioned_sidebars/version-4.x-sidebars.json | 1 + 6 files changed, 490 insertions(+) create mode 100644 docs/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md create mode 100644 i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md create mode 100644 i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md create mode 100644 versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md new file mode 100644 index 0000000000000..d4158c8cb5d25 --- /dev/null +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md @@ -0,0 +1,122 @@ +--- +{ + "title": "ARRAY_EXCEPT_ALL", + "language": "en", + "description": "Returns the multiset difference of two arrays, preserving unmatched duplicates and the order of the first array." +} +--- + +## array_except_all + + + + + +## Description + +Returns the multiset difference of `arr1` and `arr2`. Each occurrence in `arr2` removes at most one equal occurrence from `arr1`; remaining elements, including duplicates, keep their original order. `NULL` elements are compared and removed by occurrence, while a `NULL` input array produces a `NULL` result. + +## Syntax + +```sql +ARRAY_EXCEPT_ALL(, ) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The first array. Its element type must be a supported scalar type and must be compatible with the element type of ``. | +| `` | The second array. Each occurrence removes one matching occurrence from ``. Its element type must be a supported scalar type and must be compatible with ``. | + +Supported scalar element types include numeric, boolean, string, date/time, and IPv4/IPv6 types. Complex element types such as `ARRAY`, `MAP`, `STRUCT`, `JSON`, and `VARIANT` are not supported. + +## Return Value + +Returns an `ARRAY` containing the remaining elements from `` in their original order. If either input array is `NULL`, returns `NULL`. If no elements remain, returns an empty array. + +## Example + +Basic multiset difference: + +```sql +SELECT array_except_all([1, 1, 2, 3], [1, 3]); +``` + +```text +[1, 2] +``` + +Occurrences are removed one at a time, so unmatched duplicates are preserved: + +```sql +SELECT array_except_all(['a', 'a', 'b'], ['a']); +``` + +```text +["a", "b"] +``` + +The result keeps the order of the first array: + +```sql +SELECT array_except_all([3, 1, 3, 2], [3]); +``` + +```text +[1, 3, 2] +``` + +`NULL` elements participate in multiset subtraction: + +```sql +SELECT array_except_all(['a', NULL, 'a', NULL], [NULL]); +``` + +```text +["a", "a", null] +``` + +If either input array is `NULL`, the result is `NULL`: + +```sql +SELECT array_except_all(CAST(NULL AS ARRAY), [1]); +``` + +```text +NULL +``` + +An empty second array leaves the first array unchanged: + +```sql +SELECT array_except_all([1, 1, 2], CAST([] AS ARRAY)); +``` + +```text +[1, 1, 2] +``` + +Unlike `array_except`, this function preserves remaining duplicates: + +```sql +SELECT array_except([1, 1, 2], [1]), array_except_all([1, 1, 2], [1]); +``` + +```text +[2] [1, 2] +``` + +Complex element types are not supported: + +```sql +SELECT array_except_all([[1], [2]], [[1]]); +``` + +```text +ERROR 1105 (HY000): array_except_all does not support types +``` + +### Keywords + +ARRAY, EXCEPT, MULTISET, ARRAY_EXCEPT_ALL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md new file mode 100644 index 0000000000000..b8bb61f7317c9 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md @@ -0,0 +1,122 @@ +--- +{ + "title": "ARRAY_EXCEPT_ALL", + "language": "zh-CN", + "description": "返回两个数组的多重集差集,保留未匹配的重复元素及第一个数组的原始顺序。" +} +--- + +## array_except_all + + + + + +## 描述 + +返回 `arr1` 和 `arr2` 的多重集差集。`arr2` 中的每个元素最多抵消 `arr1` 中一个相同的元素;未被抵消的元素(包括重复元素)按照 `arr1` 的原始顺序保留。数组元素中的 `NULL` 也按出现次数进行比较和抵消;如果任一输入数组为 `NULL`,则返回 `NULL`。 + +## 语法 + +```sql +ARRAY_EXCEPT_ALL(, ) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 第一个数组。元素必须为支持的标量类型,且必须与 `` 的元素类型兼容。 | +| `` | 第二个数组。其中每次出现的元素会抵消 `` 中一个相同的元素;元素必须为支持的标量类型,且必须与 `` 兼容。 | + +支持的标量元素类型包括数值、布尔、字符串、日期时间以及 IPv4/IPv6 类型。不支持 `ARRAY`、`MAP`、`STRUCT`、`JSON` 和 `VARIANT` 等复杂元素类型。 + +## 返回值 + +返回 `ARRAY`,包含 `` 中剩余的元素,并保持其原始顺序。如果任一输入数组为 `NULL`,返回 `NULL`;如果没有剩余元素,返回空数组。 + +## 示例 + +基本多重集差集: + +```sql +SELECT array_except_all([1, 1, 2, 3], [1, 3]); +``` + +```text +[1, 2] +``` + +元素按出现次数逐个抵消,未匹配的重复元素会保留: + +```sql +SELECT array_except_all(['a', 'a', 'b'], ['a']); +``` + +```text +["a", "b"] +``` + +结果保持第一个数组的顺序: + +```sql +SELECT array_except_all([3, 1, 3, 2], [3]); +``` + +```text +[1, 3, 2] +``` + +数组中的 `NULL` 参与多重集差集运算: + +```sql +SELECT array_except_all(['a', NULL, 'a', NULL], [NULL]); +``` + +```text +["a", "a", null] +``` + +任一输入数组为 `NULL` 时返回 `NULL`: + +```sql +SELECT array_except_all(CAST(NULL AS ARRAY), [1]); +``` + +```text +NULL +``` + +第二个数组为空时,第一个数组保持不变: + +```sql +SELECT array_except_all([1, 1, 2], CAST([] AS ARRAY)); +``` + +```text +[1, 1, 2] +``` + +与 `array_except` 不同,本函数会保留剩余的重复元素: + +```sql +SELECT array_except([1, 1, 2], [1]), array_except_all([1, 1, 2], [1]); +``` + +```text +[2] [1, 2] +``` + +不支持复杂元素类型: + +```sql +SELECT array_except_all([[1], [2]], [[1]]); +``` + +```text +ERROR 1105 (HY000): array_except_all does not support types +``` + +### 关键词 + +ARRAY、EXCEPT、MULTISET、ARRAY_EXCEPT_ALL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md new file mode 100644 index 0000000000000..0d2ec391dc32b --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md @@ -0,0 +1,122 @@ +--- +{ + "title": "ARRAY_EXCEPT_ALL", + "language": "zh-CN", + "description": "返回两个数组的多重集差集,保留未匹配的重复元素及第一个数组的原始顺序。" +} +--- + +## array_except_all + + + + + +## 描述 + +返回 `arr1` 和 `arr2` 的多重集差集。`arr2` 中的每个元素最多抵消 `arr1` 中一个相同的元素;未被抵消的元素(包括重复元素)按照 `arr1` 的原始顺序保留。数组元素中的 `NULL` 也按出现次数进行比较和抵消;如果任一输入数组为 `NULL`,则返回 `NULL`。 + +## 语法 + +```sql +ARRAY_EXCEPT_ALL(, ) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 第一个数组。元素必须为支持的标量类型,且必须与 `` 的元素类型兼容。 | +| `` | 第二个数组。其中每次出现的元素会抵消 `` 中一个相同的元素;元素必须为支持的标量类型,且必须与 `` 兼容。 | + +支持的标量元素类型包括数值、布尔、字符串、日期时间以及 IPv4/IPv6 类型。不支持 `ARRAY`、`MAP`、`STRUCT`、`JSON` 和 `VARIANT` 等复杂元素类型。 + +## 返回值 + +返回 `ARRAY`,包含 `` 中剩余的元素,并保持其原始顺序。如果任一输入数组为 `NULL`,返回 `NULL`;如果没有剩余元素,返回空数组。 + +## 示例 + +基本多重集差集: + +```sql +SELECT array_except_all([1, 1, 2, 3], [1, 3]); +``` + +```text +[1, 2] +``` + +元素按出现次数逐个抵消,未匹配的重复元素会保留: + +```sql +SELECT array_except_all(['a', 'a', 'b'], ['a']); +``` + +```text +["a", "b"] +``` + +结果保持第一个数组的顺序: + +```sql +SELECT array_except_all([3, 1, 3, 2], [3]); +``` + +```text +[1, 3, 2] +``` + +数组中的 `NULL` 参与多重集差集运算: + +```sql +SELECT array_except_all(['a', NULL, 'a', NULL], [NULL]); +``` + +```text +["a", "a", null] +``` + +任一输入数组为 `NULL` 时返回 `NULL`: + +```sql +SELECT array_except_all(CAST(NULL AS ARRAY), [1]); +``` + +```text +NULL +``` + +第二个数组为空时,第一个数组保持不变: + +```sql +SELECT array_except_all([1, 1, 2], CAST([] AS ARRAY)); +``` + +```text +[1, 1, 2] +``` + +与 `array_except` 不同,本函数会保留剩余的重复元素: + +```sql +SELECT array_except([1, 1, 2], [1]), array_except_all([1, 1, 2], [1]); +``` + +```text +[2] [1, 2] +``` + +不支持复杂元素类型: + +```sql +SELECT array_except_all([[1], [2]], [[1]]); +``` + +```text +ERROR 1105 (HY000): array_except_all does not support types +``` + +### 关键词 + +ARRAY、EXCEPT、MULTISET、ARRAY_EXCEPT_ALL diff --git a/sidebars.ts b/sidebars.ts index 6f3361440dd29..437392d815f4c 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -1755,6 +1755,7 @@ const sidebars: SidebarsConfig = { 'sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate', 'sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate-uniq', 'sql-manual/sql-functions/scalar-functions/array-functions/array-except', + 'sql-manual/sql-functions/scalar-functions/array-functions/array-except-all', 'sql-manual/sql-functions/scalar-functions/array-functions/array-exists', 'sql-manual/sql-functions/scalar-functions/array-functions/array-filter', 'sql-manual/sql-functions/scalar-functions/array-functions/array-first', diff --git a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md new file mode 100644 index 0000000000000..4f6fa43438f5b --- /dev/null +++ b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-except-all.md @@ -0,0 +1,122 @@ +--- +{ + "title": "ARRAY_EXCEPT_ALL", + "language": "en", + "description": "Returns the multiset difference of two arrays, preserving unmatched duplicates and the order of the first array." +} +--- + +## array_except_all + + + + + +## Description + +Returns the multiset difference of `arr1` and `arr2`. Each occurrence in `arr2` removes at most one equal occurrence from `arr1`; remaining elements, including duplicates, keep their original order. `NULL` elements are compared and removed by occurrence, while a `NULL` input array produces a `NULL` result. + +## Syntax + +```sql +ARRAY_EXCEPT_ALL(, ) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The first array. Its element type must be a supported scalar type and must be compatible with the element type of ``. | +| `` | The second array. Each occurrence removes one matching occurrence from ``. Its element type must be a supported scalar type and must be compatible with ``. | + +Supported scalar element types include numeric, boolean, string, date/time, and IPv4/IPv6 types. Complex element types such as `ARRAY`, `MAP`, `STRUCT`, `JSON`, and `VARIANT` are not supported. + +## Return Value + +Returns an `ARRAY` containing the remaining elements from `` in their original order. If either input array is `NULL`, returns `NULL`. If no elements remain, returns an empty array. + +## Example + +Basic multiset difference: + +```sql +SELECT array_except_all([1, 1, 2, 3], [1, 3]); +``` + +```text +[1, 2] +``` + +Occurrences are removed one at a time, so unmatched duplicates are preserved: + +```sql +SELECT array_except_all(['a', 'a', 'b'], ['a']); +``` + +```text +["a", "b"] +``` + +The result keeps the order of the first array: + +```sql +SELECT array_except_all([3, 1, 3, 2], [3]); +``` + +```text +[1, 3, 2] +``` + +`NULL` elements participate in multiset subtraction: + +```sql +SELECT array_except_all(['a', NULL, 'a', NULL], [NULL]); +``` + +```text +["a", "a", null] +``` + +If either input array is `NULL`, the result is `NULL`: + +```sql +SELECT array_except_all(CAST(NULL AS ARRAY), [1]); +``` + +```text +NULL +``` + +An empty second array leaves the first array unchanged: + +```sql +SELECT array_except_all([1, 1, 2], CAST([] AS ARRAY)); +``` + +```text +[1, 1, 2] +``` + +Unlike `array_except`, this function preserves remaining duplicates: + +```sql +SELECT array_except([1, 1, 2], [1]), array_except_all([1, 1, 2], [1]); +``` + +```text +[2] [1, 2] +``` + +Complex element types are not supported: + +```sql +SELECT array_except_all([[1], [2]], [[1]]); +``` + +```text +ERROR 1105 (HY000): array_except_all does not support types +``` + +### Keywords + +ARRAY, EXCEPT, MULTISET, ARRAY_EXCEPT_ALL diff --git a/versioned_sidebars/version-4.x-sidebars.json b/versioned_sidebars/version-4.x-sidebars.json index b7cdb92dbaed0..f4306a6a91d27 100644 --- a/versioned_sidebars/version-4.x-sidebars.json +++ b/versioned_sidebars/version-4.x-sidebars.json @@ -1930,6 +1930,7 @@ "sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate", "sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate-uniq", "sql-manual/sql-functions/scalar-functions/array-functions/array-except", + "sql-manual/sql-functions/scalar-functions/array-functions/array-except-all", "sql-manual/sql-functions/scalar-functions/array-functions/array-exists", "sql-manual/sql-functions/scalar-functions/array-functions/array-filter", "sql-manual/sql-functions/scalar-functions/array-functions/array-first", From 3597e109d28ab1e68c40c683909602d5ffd1d52d Mon Sep 17 00:00:00 2001 From: Mryange Date: Mon, 7 Sep 2026 18:26:20 +0800 Subject: [PATCH 2/2] [doc](function) Document ARRAY NULL ordering for min max --- docs/sql-manual/sql-functions/aggregate-functions/max-by.md | 2 ++ docs/sql-manual/sql-functions/aggregate-functions/max.md | 2 +- docs/sql-manual/sql-functions/aggregate-functions/min-by.md | 2 ++ docs/sql-manual/sql-functions/aggregate-functions/min.md | 2 +- .../sql-manual/sql-functions/aggregate-functions/max-by.md | 2 ++ .../current/sql-manual/sql-functions/aggregate-functions/max.md | 2 +- .../sql-manual/sql-functions/aggregate-functions/min-by.md | 2 ++ .../current/sql-manual/sql-functions/aggregate-functions/min.md | 2 +- .../sql-manual/sql-functions/aggregate-functions/max-by.md | 2 ++ .../sql-manual/sql-functions/aggregate-functions/max.md | 2 +- .../sql-manual/sql-functions/aggregate-functions/min-by.md | 2 ++ .../sql-manual/sql-functions/aggregate-functions/min.md | 2 +- .../sql-manual/sql-functions/aggregate-functions/max-by.md | 2 ++ .../sql-manual/sql-functions/aggregate-functions/max.md | 2 +- .../sql-manual/sql-functions/aggregate-functions/min-by.md | 2 ++ .../sql-manual/sql-functions/aggregate-functions/min.md | 2 +- 16 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/sql-manual/sql-functions/aggregate-functions/max-by.md b/docs/sql-manual/sql-functions/aggregate-functions/max-by.md index f909435a89867..b6ad7114e3c56 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -10,6 +10,8 @@ The MAX_BY function returns the associated value based on the maximum value of the specified column. +When `` is an Array, arrays are compared lexicographically, element by element; a NULL element is greater than any non-NULL element. A NULL array value is ignored. + ## Syntax ```sql diff --git a/docs/sql-manual/sql-functions/aggregate-functions/max.md b/docs/sql-manual/sql-functions/aggregate-functions/max.md index 1584a4bdf5682..5f7b38ce4af77 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/max.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/max.md @@ -83,7 +83,7 @@ For Decimal type: Returns the maximum high-precision decimal value. select k1, max(k_array) from t1 group by k1; ``` -For Array type: Returns the maximum array value for each group(Compare elements one by one; null is the smallest element.). +For Array type: Returns the maximum array value for each group. Arrays are compared lexicographically, element by element; a NULL element is greater than any non-NULL element. A NULL array value is ignored like other NULL input values. ```text +------+--------------+ diff --git a/docs/sql-manual/sql-functions/aggregate-functions/min-by.md b/docs/sql-manual/sql-functions/aggregate-functions/min-by.md index c1a4a7d1b5c47..926f75a8e5807 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -10,6 +10,8 @@ The MIN_BY function returns the associated value based on the minimum value of the specified column. +When `` is an Array, arrays are compared lexicographically, element by element; a NULL element is greater than any non-NULL element. A NULL array value is ignored. + ## Syntax ```sql diff --git a/docs/sql-manual/sql-functions/aggregate-functions/min.md b/docs/sql-manual/sql-functions/aggregate-functions/min.md index 836a00ebb27e1..4bece30b07652 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/min.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/min.md @@ -82,7 +82,7 @@ Decimal type: Returns the minimum high-precision decimal value. select k1, min(k_array) from t1 group by k1; ``` -For Array type: Returns the minimum array value for each group(Compare elements one by one; null is the smallest element.). +For Array type: Returns the minimum array value for each group. Arrays are compared lexicographically, element by element; a NULL element is greater than any non-NULL element. A NULL array value is ignored like other NULL input values. ```text +------+----------------+ diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-by.md index f5d531ef8358d..6dbd3282e135f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -10,6 +10,8 @@ MAX_BY 函数用于根据指定列的最大值,返回对应的的关联值。 +当 `` 为 Array 时,数组按字典序逐元素比较;数组元素中的 NULL 大于任何非 NULL 元素。整个数组为 NULL 时会被忽略。 + ## 语法 ```sql diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max.md index 890a73ab8e9e1..e2ab3a96af1ca 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max.md @@ -82,7 +82,7 @@ Decimal 类型:返回最大的高精度小数值。 select k1, max(k_array) from t1 group by k1; ``` -Array 类型: 返回最大的数组值(逐元素比较大小,null为最小元素)。 +Array 类型:返回每组最大的数组值。数组按字典序逐元素比较;数组元素中的 NULL 大于任何非 NULL 元素。整个数组为 NULL 时,与其他 NULL 输入值一样会被忽略。 ```text +------+--------------+ diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-by.md index 43eaa10dd09e2..78410b6efeeb6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -10,6 +10,8 @@ MIN_BY 函数用于根据指定列的最小值,返回对应的的关联值。 +当 `` 为 Array 时,数组按字典序逐元素比较;数组元素中的 NULL 大于任何非 NULL 元素。整个数组为 NULL 时会被忽略。 + ## 语法 ```sql diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min.md index 2b56f50390f4c..bba92c1543e00 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min.md @@ -82,7 +82,7 @@ Decimal 类型:返回最小的高精度小数值。 select k1, min(k_array) from t1 group by k1; ``` -Array 类型: 返回最小的数组值(逐元素比较大小,null为最小元素)。 +Array 类型:返回每组最小的数组值。数组按字典序逐元素比较;数组元素中的 NULL 大于任何非 NULL 元素。整个数组为 NULL 时,与其他 NULL 输入值一样会被忽略。 ```text +------+----------------+ diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-by.md index f5d531ef8358d..6dbd3282e135f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -10,6 +10,8 @@ MAX_BY 函数用于根据指定列的最大值,返回对应的的关联值。 +当 `` 为 Array 时,数组按字典序逐元素比较;数组元素中的 NULL 大于任何非 NULL 元素。整个数组为 NULL 时会被忽略。 + ## 语法 ```sql diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max.md index 890a73ab8e9e1..e2ab3a96af1ca 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max.md @@ -82,7 +82,7 @@ Decimal 类型:返回最大的高精度小数值。 select k1, max(k_array) from t1 group by k1; ``` -Array 类型: 返回最大的数组值(逐元素比较大小,null为最小元素)。 +Array 类型:返回每组最大的数组值。数组按字典序逐元素比较;数组元素中的 NULL 大于任何非 NULL 元素。整个数组为 NULL 时,与其他 NULL 输入值一样会被忽略。 ```text +------+--------------+ diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-by.md index 43eaa10dd09e2..78410b6efeeb6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -10,6 +10,8 @@ MIN_BY 函数用于根据指定列的最小值,返回对应的的关联值。 +当 `` 为 Array 时,数组按字典序逐元素比较;数组元素中的 NULL 大于任何非 NULL 元素。整个数组为 NULL 时会被忽略。 + ## 语法 ```sql diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min.md index 2b56f50390f4c..bba92c1543e00 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min.md @@ -82,7 +82,7 @@ Decimal 类型:返回最小的高精度小数值。 select k1, min(k_array) from t1 group by k1; ``` -Array 类型: 返回最小的数组值(逐元素比较大小,null为最小元素)。 +Array 类型:返回每组最小的数组值。数组按字典序逐元素比较;数组元素中的 NULL 大于任何非 NULL 元素。整个数组为 NULL 时,与其他 NULL 输入值一样会被忽略。 ```text +------+----------------+ diff --git a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-by.md b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-by.md index f909435a89867..b6ad7114e3c56 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -10,6 +10,8 @@ The MAX_BY function returns the associated value based on the maximum value of the specified column. +When `` is an Array, arrays are compared lexicographically, element by element; a NULL element is greater than any non-NULL element. A NULL array value is ignored. + ## Syntax ```sql diff --git a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max.md b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max.md index 1584a4bdf5682..5f7b38ce4af77 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max.md +++ b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max.md @@ -83,7 +83,7 @@ For Decimal type: Returns the maximum high-precision decimal value. select k1, max(k_array) from t1 group by k1; ``` -For Array type: Returns the maximum array value for each group(Compare elements one by one; null is the smallest element.). +For Array type: Returns the maximum array value for each group. Arrays are compared lexicographically, element by element; a NULL element is greater than any non-NULL element. A NULL array value is ignored like other NULL input values. ```text +------+--------------+ diff --git a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-by.md b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-by.md index c1a4a7d1b5c47..926f75a8e5807 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -10,6 +10,8 @@ The MIN_BY function returns the associated value based on the minimum value of the specified column. +When `` is an Array, arrays are compared lexicographically, element by element; a NULL element is greater than any non-NULL element. A NULL array value is ignored. + ## Syntax ```sql diff --git a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min.md b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min.md index 836a00ebb27e1..4bece30b07652 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min.md +++ b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min.md @@ -82,7 +82,7 @@ Decimal type: Returns the minimum high-precision decimal value. select k1, min(k_array) from t1 group by k1; ``` -For Array type: Returns the minimum array value for each group(Compare elements one by one; null is the smallest element.). +For Array type: Returns the minimum array value for each group. Arrays are compared lexicographically, element by element; a NULL element is greater than any non-NULL element. A NULL array value is ignored like other NULL input values. ```text +------+----------------+