This is an automated email from the ASF dual-hosted git repository.
zclllyybb 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 4edc3c3301d [doc] Add map aggregate function docs (#3952)
4edc3c3301d is described below
commit 4edc3c3301d8ddb8137b7ca47255da381d1303da
Author: HappenLee <[email protected]>
AuthorDate: Fri Jun 26 14:42:51 2026 +0800
[doc] Add map aggregate function docs (#3952)
## Summary
- Add SQL function docs for sum_map, avg_map, min_map, max_map, and
count_map.
- Add matching English and Chinese docs for current and 4.x.
- Add sidebar entries for current and 4.x aggregate function navigation.
---
.../sql-functions/aggregate-functions/avg-map.md | 111 ++++++++++++++++++++
.../sql-functions/aggregate-functions/count-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/max-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/min-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/sum-map.md | 111 ++++++++++++++++++++
.../sql-functions/aggregate-functions/avg-map.md | 111 ++++++++++++++++++++
.../sql-functions/aggregate-functions/count-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/max-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/min-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/sum-map.md | 111 ++++++++++++++++++++
.../sql-functions/aggregate-functions/avg-map.md | 111 ++++++++++++++++++++
.../sql-functions/aggregate-functions/count-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/max-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/min-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/sum-map.md | 111 ++++++++++++++++++++
sidebars.ts | 5 +
.../sql-functions/aggregate-functions/avg-map.md | 111 ++++++++++++++++++++
.../sql-functions/aggregate-functions/count-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/max-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/min-map.md | 115 +++++++++++++++++++++
.../sql-functions/aggregate-functions/sum-map.md | 111 ++++++++++++++++++++
versioned_sidebars/version-4.x-sidebars.json | 10 ++
22 files changed, 2283 insertions(+)
diff --git a/docs/sql-manual/sql-functions/aggregate-functions/avg-map.md
b/docs/sql-manual/sql-functions/aggregate-functions/avg-map.md
new file mode 100644
index 00000000000..ebed1a3b5d6
--- /dev/null
+++ b/docs/sql-manual/sql-functions/aggregate-functions/avg-map.md
@@ -0,0 +1,111 @@
+---
+{
+ "title": "AVG_MAP",
+ "language": "en",
+ "description": "The AVG_MAP function aggregates MAP values by key and
returns the average value for each key."
+}
+---
+
+## Description
+
+The AVG_MAP function aggregates MAP values by key and returns a MAP that
contains the average of non-NULL values for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+AVG_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. The MAP value type must be numeric. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>`. For numeric value types
other than Decimal, the returned value type is DOUBLE. For Decimal value types,
the returned value type is a Decimal type with the maximum supported precision
and a scale adjusted for AVG.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is NULL.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ md MAP<STRING, DECIMAL(10, 2)>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP('a', 1.20, 'b', 2.30)),
+ (1, MAP(2, 5, 3, 30), MAP('b', 3.70, 'c', 4.00)),
+ (2, MAP(1, 7, 4, NULL), MAP('a', NULL, 'c', 5.50)),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<STRING, DECIMAL(10,
2)>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, AVG_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | [10, 12.5, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT AVG_MAP(md) AS result
+ FROM map_agg_example
+) t;
+```
+
+```text
++-----------------+------------------------+
+| keys | values |
++-----------------+------------------------+
+| ["a", "b", "c"] | [1.2000, 3.0000, 4.7500] |
++-----------------+------------------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT AVG_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git a/docs/sql-manual/sql-functions/aggregate-functions/count-map.md
b/docs/sql-manual/sql-functions/aggregate-functions/count-map.md
new file mode 100644
index 00000000000..0b4fa4e0321
--- /dev/null
+++ b/docs/sql-manual/sql-functions/aggregate-functions/count-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "COUNT_MAP",
+ "language": "en",
+ "description": "The COUNT_MAP function aggregates MAP values by key and
returns the count of non-NULL values for each key."
+}
+---
+
+## Description
+
+The COUNT_MAP function aggregates MAP values by key and returns a MAP that
contains the count of non-NULL values for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+COUNT_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>` and BIGINT values.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is 0.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, COUNT_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-----------+
+| id | keys | values |
++------+-----------+-----------+
+| 1 | [1, 2, 3] | [1, 2, 1] |
+| 2 | [1, 4] | [1, 0] |
++------+-----------+-----------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, COUNT_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-----------+
+| id | keys | values |
++------+-----------+-----------+
+| 1 | [1, 2, 3] | [2, 1, 0] |
+| 2 | [2] | [1] |
++------+-----------+-----------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT COUNT_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git a/docs/sql-manual/sql-functions/aggregate-functions/max-map.md
b/docs/sql-manual/sql-functions/aggregate-functions/max-map.md
new file mode 100644
index 00000000000..00e9291268a
--- /dev/null
+++ b/docs/sql-manual/sql-functions/aggregate-functions/max-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "MAX_MAP",
+ "language": "en",
+ "description": "The MAX_MAP function aggregates MAP values by key and
returns the maximum value for each key."
+}
+---
+
+## Description
+
+The MAX_MAP function aggregates MAP values by key and returns a MAP that
contains the maximum non-NULL value for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+MAX_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. The MAP value type must be comparable by
the MAX aggregate function. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>`. For DecimalV2 value
types, the returned value type is the corresponding DecimalV3 type. For other
value types, the returned value type is the same as the input MAP value type.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is NULL.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MAX_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+--------------+
+| id | keys | values |
++------+-----------+--------------+
+| 1 | [1, 2, 3] | [10, 20, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+--------------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MAX_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | ["b", "x", null] |
+| 2 | [2] | ["z"] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT MAX_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git a/docs/sql-manual/sql-functions/aggregate-functions/min-map.md
b/docs/sql-manual/sql-functions/aggregate-functions/min-map.md
new file mode 100644
index 00000000000..f29b311bf67
--- /dev/null
+++ b/docs/sql-manual/sql-functions/aggregate-functions/min-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "MIN_MAP",
+ "language": "en",
+ "description": "The MIN_MAP function aggregates MAP values by key and
returns the minimum value for each key."
+}
+---
+
+## Description
+
+The MIN_MAP function aggregates MAP values by key and returns a MAP that
contains the minimum non-NULL value for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+MIN_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. The MAP value type must be comparable by
the MIN aggregate function. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>`. For DecimalV2 value
types, the returned value type is the corresponding DecimalV3 type. For other
value types, the returned value type is the same as the input MAP value type.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is NULL.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MIN_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-------------+
+| id | keys | values |
++------+-----------+-------------+
+| 1 | [1, 2, 3] | [10, 5, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+-------------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MIN_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | ["a", "x", null] |
+| 2 | [2] | ["z"] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT MIN_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git a/docs/sql-manual/sql-functions/aggregate-functions/sum-map.md
b/docs/sql-manual/sql-functions/aggregate-functions/sum-map.md
new file mode 100644
index 00000000000..b0b904ba4d0
--- /dev/null
+++ b/docs/sql-manual/sql-functions/aggregate-functions/sum-map.md
@@ -0,0 +1,111 @@
+---
+{
+ "title": "SUM_MAP",
+ "language": "en",
+ "description": "The SUM_MAP function aggregates MAP values by key and
returns the sum of values for each key."
+}
+---
+
+## Description
+
+The SUM_MAP function aggregates MAP values by key and returns a MAP that
contains the sum of non-NULL values for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+SUM_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. The MAP value type must be numeric. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>`. For integer-like,
Boolean, and NULL value types, the returned value type is BIGINT. For Float and
Double value types, the returned value type is DOUBLE. For Decimal value types,
the returned value type is a Decimal type with the maximum supported precision
and the same scale. For LargeInt value types, the returned value type is
LargeInt.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is NULL.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ md MAP<STRING, DECIMAL(10, 2)>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP('a', 1.20, 'b', 2.30)),
+ (1, MAP(2, 5, 3, 30), MAP('b', 3.70, 'c', 4.00)),
+ (2, MAP(1, 7, 4, NULL), MAP('a', NULL, 'c', 5.50)),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<STRING, DECIMAL(10,
2)>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, SUM_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+--------------+
+| id | keys | values |
++------+-----------+--------------+
+| 1 | [1, 2, 3] | [10, 25, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+--------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT SUM_MAP(md) AS result
+ FROM map_agg_example
+) t;
+```
+
+```text
++-----------------+--------------------+
+| keys | values |
++-----------------+--------------------+
+| ["a", "b", "c"] | [1.20, 6.00, 9.50] |
++-----------------+--------------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT SUM_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/avg-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/avg-map.md
new file mode 100644
index 00000000000..67836cf6296
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/avg-map.md
@@ -0,0 +1,111 @@
+---
+{
+ "title": "AVG_MAP",
+ "language": "zh-CN",
+ "description": "AVG_MAP 函数按键聚合 MAP 值,并返回每个键对应值的平均值。"
+}
+---
+
+## 描述
+
+AVG_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下所有非 NULL 值的平均值。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+AVG_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。MAP 的 value 类型必须为数值类型。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同。对于 Decimal 以外的数值 value 类型,返回的 value 类型为
DOUBLE;对于 Decimal value 类型,返回的 value 类型为最大支持精度并按 AVG 规则调整 scale 后的 Decimal。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 NULL。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ md MAP<STRING, DECIMAL(10, 2)>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP('a', 1.20, 'b', 2.30)),
+ (1, MAP(2, 5, 3, 30), MAP('b', 3.70, 'c', 4.00)),
+ (2, MAP(1, 7, 4, NULL), MAP('a', NULL, 'c', 5.50)),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<STRING, DECIMAL(10,
2)>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, AVG_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | [10, 12.5, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT AVG_MAP(md) AS result
+ FROM map_agg_example
+) t;
+```
+
+```text
++-----------------+------------------------+
+| keys | values |
++-----------------+------------------------+
+| ["a", "b", "c"] | [1.2000, 3.0000, 4.7500] |
++-----------------+------------------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT AVG_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/count-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/count-map.md
new file mode 100644
index 00000000000..46f7e1de647
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/count-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "COUNT_MAP",
+ "language": "zh-CN",
+ "description": "COUNT_MAP 函数按键聚合 MAP 值,并返回每个键对应的非 NULL 值数量。"
+}
+---
+
+## 描述
+
+COUNT_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下非 NULL 值的数量。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+COUNT_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同,value 类型为 BIGINT。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 0。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, COUNT_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-----------+
+| id | keys | values |
++------+-----------+-----------+
+| 1 | [1, 2, 3] | [1, 2, 1] |
+| 2 | [1, 4] | [1, 0] |
++------+-----------+-----------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, COUNT_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-----------+
+| id | keys | values |
++------+-----------+-----------+
+| 1 | [1, 2, 3] | [2, 1, 0] |
+| 2 | [2] | [1] |
++------+-----------+-----------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT COUNT_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-map.md
new file mode 100644
index 00000000000..fa5a4ac2eb8
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "MAX_MAP",
+ "language": "zh-CN",
+ "description": "MAX_MAP 函数按键聚合 MAP 值,并返回每个键对应的最大值。"
+}
+---
+
+## 描述
+
+MAX_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下的最大非 NULL 值。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+MAX_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。MAP 的 value 类型必须是 MAX 聚合函数可比较的类型。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同。对于 DecimalV2 value 类型,返回的 value 类型为对应的
DecimalV3 类型;对于其他 value 类型,返回的 value 类型与输入 MAP 的 value 类型相同。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 NULL。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MAX_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+--------------+
+| id | keys | values |
++------+-----------+--------------+
+| 1 | [1, 2, 3] | [10, 20, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+--------------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MAX_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | ["b", "x", null] |
+| 2 | [2] | ["z"] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT MAX_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-map.md
new file mode 100644
index 00000000000..4fad67e027b
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "MIN_MAP",
+ "language": "zh-CN",
+ "description": "MIN_MAP 函数按键聚合 MAP 值,并返回每个键对应的最小值。"
+}
+---
+
+## 描述
+
+MIN_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下的最小非 NULL 值。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+MIN_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。MAP 的 value 类型必须是 MIN 聚合函数可比较的类型。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同。对于 DecimalV2 value 类型,返回的 value 类型为对应的
DecimalV3 类型;对于其他 value 类型,返回的 value 类型与输入 MAP 的 value 类型相同。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 NULL。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MIN_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-------------+
+| id | keys | values |
++------+-----------+-------------+
+| 1 | [1, 2, 3] | [10, 5, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+-------------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MIN_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | ["a", "x", null] |
+| 2 | [2] | ["z"] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT MIN_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum-map.md
new file mode 100644
index 00000000000..290dcb63d2f
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum-map.md
@@ -0,0 +1,111 @@
+---
+{
+ "title": "SUM_MAP",
+ "language": "zh-CN",
+ "description": "SUM_MAP 函数按键聚合 MAP 值,并返回每个键对应值的总和。"
+}
+---
+
+## 描述
+
+SUM_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下所有非 NULL 值的总和。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+SUM_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。MAP 的 value 类型必须为数值类型。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同。对于整数类、Boolean 和 NULL value 类型,返回的 value 类型为
BIGINT;对于 Float 和 Double value 类型,返回的 value 类型为 DOUBLE;对于 Decimal value 类型,返回的
value 类型为最大支持精度且 scale 不变的 Decimal;对于 LargeInt value 类型,返回的 value 类型为 LargeInt。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 NULL。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ md MAP<STRING, DECIMAL(10, 2)>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP('a', 1.20, 'b', 2.30)),
+ (1, MAP(2, 5, 3, 30), MAP('b', 3.70, 'c', 4.00)),
+ (2, MAP(1, 7, 4, NULL), MAP('a', NULL, 'c', 5.50)),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<STRING, DECIMAL(10,
2)>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, SUM_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+--------------+
+| id | keys | values |
++------+-----------+--------------+
+| 1 | [1, 2, 3] | [10, 25, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+--------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT SUM_MAP(md) AS result
+ FROM map_agg_example
+) t;
+```
+
+```text
++-----------------+--------------------+
+| keys | values |
++-----------------+--------------------+
+| ["a", "b", "c"] | [1.20, 6.00, 9.50] |
++-----------------+--------------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT SUM_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/avg-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/avg-map.md
new file mode 100644
index 00000000000..67836cf6296
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/avg-map.md
@@ -0,0 +1,111 @@
+---
+{
+ "title": "AVG_MAP",
+ "language": "zh-CN",
+ "description": "AVG_MAP 函数按键聚合 MAP 值,并返回每个键对应值的平均值。"
+}
+---
+
+## 描述
+
+AVG_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下所有非 NULL 值的平均值。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+AVG_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。MAP 的 value 类型必须为数值类型。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同。对于 Decimal 以外的数值 value 类型,返回的 value 类型为
DOUBLE;对于 Decimal value 类型,返回的 value 类型为最大支持精度并按 AVG 规则调整 scale 后的 Decimal。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 NULL。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ md MAP<STRING, DECIMAL(10, 2)>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP('a', 1.20, 'b', 2.30)),
+ (1, MAP(2, 5, 3, 30), MAP('b', 3.70, 'c', 4.00)),
+ (2, MAP(1, 7, 4, NULL), MAP('a', NULL, 'c', 5.50)),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<STRING, DECIMAL(10,
2)>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, AVG_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | [10, 12.5, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT AVG_MAP(md) AS result
+ FROM map_agg_example
+) t;
+```
+
+```text
++-----------------+------------------------+
+| keys | values |
++-----------------+------------------------+
+| ["a", "b", "c"] | [1.2000, 3.0000, 4.7500] |
++-----------------+------------------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT AVG_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/count-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/count-map.md
new file mode 100644
index 00000000000..46f7e1de647
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/count-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "COUNT_MAP",
+ "language": "zh-CN",
+ "description": "COUNT_MAP 函数按键聚合 MAP 值,并返回每个键对应的非 NULL 值数量。"
+}
+---
+
+## 描述
+
+COUNT_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下非 NULL 值的数量。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+COUNT_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同,value 类型为 BIGINT。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 0。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, COUNT_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-----------+
+| id | keys | values |
++------+-----------+-----------+
+| 1 | [1, 2, 3] | [1, 2, 1] |
+| 2 | [1, 4] | [1, 0] |
++------+-----------+-----------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, COUNT_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-----------+
+| id | keys | values |
++------+-----------+-----------+
+| 1 | [1, 2, 3] | [2, 1, 0] |
+| 2 | [2] | [1] |
++------+-----------+-----------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT COUNT_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-map.md
new file mode 100644
index 00000000000..fa5a4ac2eb8
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "MAX_MAP",
+ "language": "zh-CN",
+ "description": "MAX_MAP 函数按键聚合 MAP 值,并返回每个键对应的最大值。"
+}
+---
+
+## 描述
+
+MAX_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下的最大非 NULL 值。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+MAX_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。MAP 的 value 类型必须是 MAX 聚合函数可比较的类型。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同。对于 DecimalV2 value 类型,返回的 value 类型为对应的
DecimalV3 类型;对于其他 value 类型,返回的 value 类型与输入 MAP 的 value 类型相同。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 NULL。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MAX_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+--------------+
+| id | keys | values |
++------+-----------+--------------+
+| 1 | [1, 2, 3] | [10, 20, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+--------------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MAX_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | ["b", "x", null] |
+| 2 | [2] | ["z"] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT MAX_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-map.md
new file mode 100644
index 00000000000..4fad67e027b
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "MIN_MAP",
+ "language": "zh-CN",
+ "description": "MIN_MAP 函数按键聚合 MAP 值,并返回每个键对应的最小值。"
+}
+---
+
+## 描述
+
+MIN_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下的最小非 NULL 值。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+MIN_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。MAP 的 value 类型必须是 MIN 聚合函数可比较的类型。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同。对于 DecimalV2 value 类型,返回的 value 类型为对应的
DecimalV3 类型;对于其他 value 类型,返回的 value 类型与输入 MAP 的 value 类型相同。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 NULL。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MIN_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-------------+
+| id | keys | values |
++------+-----------+-------------+
+| 1 | [1, 2, 3] | [10, 5, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+-------------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MIN_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | ["a", "x", null] |
+| 2 | [2] | ["z"] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT MIN_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/sum-map.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/sum-map.md
new file mode 100644
index 00000000000..290dcb63d2f
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/sum-map.md
@@ -0,0 +1,111 @@
+---
+{
+ "title": "SUM_MAP",
+ "language": "zh-CN",
+ "description": "SUM_MAP 函数按键聚合 MAP 值,并返回每个键对应值的总和。"
+}
+---
+
+## 描述
+
+SUM_MAP 函数按键聚合 MAP 值,返回一个 MAP,其中每个键对应的值为该键下所有非 NULL 值的总和。
+
+## 使用说明
+
+返回 MAP 中条目的顺序不保证稳定。如果需要稳定的输出顺序,请使用 `map_keys`、`map_values`、`array_sort` 和
`array_sortby` 对结果进行排序。NULL key 会作为普通 key 参与聚合;所有 NULL key 会归并到同一个结果条目中。
+
+## 语法
+
+```sql
+SUM_MAP(<map_expr>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<map_expr>` | MAP 表达式。MAP 的 value 类型必须为数值类型。 |
+
+## 返回值
+
+返回一个 MAP,key 类型与 `<map_expr>` 相同。对于整数类、Boolean 和 NULL value 类型,返回的 value 类型为
BIGINT;对于 Float 和 Double value 类型,返回的 value 类型为 DOUBLE;对于 Decimal value 类型,返回的
value 类型为最大支持精度且 scale 不变的 Decimal;对于 LargeInt value 类型,返回的 value 类型为 LargeInt。
+
+如果组内没有有效输入行,返回空 MAP。如果某个 key 存在但该 key 下所有 value 均为 NULL,则该 key 对应的返回值为 NULL。
+
+## 示例
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ md MAP<STRING, DECIMAL(10, 2)>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP('a', 1.20, 'b', 2.30)),
+ (1, MAP(2, 5, 3, 30), MAP('b', 3.70, 'c', 4.00)),
+ (2, MAP(1, 7, 4, NULL), MAP('a', NULL, 'c', 5.50)),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<STRING, DECIMAL(10,
2)>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, SUM_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+--------------+
+| id | keys | values |
++------+-----------+--------------+
+| 1 | [1, 2, 3] | [10, 25, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+--------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT SUM_MAP(md) AS result
+ FROM map_agg_example
+) t;
+```
+
+```text
++-----------------+--------------------+
+| keys | values |
++-----------------+--------------------+
+| ["a", "b", "c"] | [1.20, 6.00, 9.50] |
++-----------------+--------------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT SUM_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git a/sidebars.ts b/sidebars.ts
index c0ceecc7602..80034d7c609 100644
--- a/sidebars.ts
+++ b/sidebars.ts
@@ -2013,6 +2013,7 @@ const sidebars: SidebarsConfig = {
'sql-manual/sql-functions/aggregate-functions/approx-count-distinct',
'sql-manual/sql-functions/aggregate-functions/array-agg',
'sql-manual/sql-functions/aggregate-functions/avg',
+
'sql-manual/sql-functions/aggregate-functions/avg-map',
'sql-manual/sql-functions/aggregate-functions/avg-weighted',
'sql-manual/sql-functions/aggregate-functions/bitmap-agg',
'sql-manual/sql-functions/aggregate-functions/bitmap-intersect',
@@ -2028,6 +2029,7 @@ const sidebars: SidebarsConfig = {
'sql-manual/sql-functions/aggregate-functions/corr',
'sql-manual/sql-functions/aggregate-functions/count',
'sql-manual/sql-functions/aggregate-functions/count-by-enum',
+
'sql-manual/sql-functions/aggregate-functions/count-map',
'sql-manual/sql-functions/aggregate-functions/covar',
'sql-manual/sql-functions/aggregate-functions/covar-samp',
'sql-manual/sql-functions/aggregate-functions/datasketches_hll_union_agg',
@@ -2048,9 +2050,11 @@ const sidebars: SidebarsConfig = {
'sql-manual/sql-functions/aggregate-functions/map-agg',
'sql-manual/sql-functions/aggregate-functions/max',
'sql-manual/sql-functions/aggregate-functions/max-by',
+
'sql-manual/sql-functions/aggregate-functions/max-map',
'sql-manual/sql-functions/aggregate-functions/median',
'sql-manual/sql-functions/aggregate-functions/min',
'sql-manual/sql-functions/aggregate-functions/min-by',
+
'sql-manual/sql-functions/aggregate-functions/min-map',
'sql-manual/sql-functions/aggregate-functions/percentile',
'sql-manual/sql-functions/aggregate-functions/percentile-approx',
'sql-manual/sql-functions/aggregate-functions/percentile-array',
@@ -2075,6 +2079,7 @@ const sidebars: SidebarsConfig = {
'sql-manual/sql-functions/aggregate-functions/stddev-samp',
'sql-manual/sql-functions/aggregate-functions/sum',
'sql-manual/sql-functions/aggregate-functions/sum0',
+
'sql-manual/sql-functions/aggregate-functions/sum-map',
'sql-manual/sql-functions/aggregate-functions/topn',
'sql-manual/sql-functions/aggregate-functions/topn-array',
'sql-manual/sql-functions/aggregate-functions/topn-weighted',
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/avg-map.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/avg-map.md
new file mode 100644
index 00000000000..ebed1a3b5d6
--- /dev/null
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/avg-map.md
@@ -0,0 +1,111 @@
+---
+{
+ "title": "AVG_MAP",
+ "language": "en",
+ "description": "The AVG_MAP function aggregates MAP values by key and
returns the average value for each key."
+}
+---
+
+## Description
+
+The AVG_MAP function aggregates MAP values by key and returns a MAP that
contains the average of non-NULL values for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+AVG_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. The MAP value type must be numeric. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>`. For numeric value types
other than Decimal, the returned value type is DOUBLE. For Decimal value types,
the returned value type is a Decimal type with the maximum supported precision
and a scale adjusted for AVG.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is NULL.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ md MAP<STRING, DECIMAL(10, 2)>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP('a', 1.20, 'b', 2.30)),
+ (1, MAP(2, 5, 3, 30), MAP('b', 3.70, 'c', 4.00)),
+ (2, MAP(1, 7, 4, NULL), MAP('a', NULL, 'c', 5.50)),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<STRING, DECIMAL(10,
2)>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, AVG_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | [10, 12.5, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT AVG_MAP(md) AS result
+ FROM map_agg_example
+) t;
+```
+
+```text
++-----------------+------------------------+
+| keys | values |
++-----------------+------------------------+
+| ["a", "b", "c"] | [1.2000, 3.0000, 4.7500] |
++-----------------+------------------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT AVG_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/count-map.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/count-map.md
new file mode 100644
index 00000000000..0b4fa4e0321
--- /dev/null
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/count-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "COUNT_MAP",
+ "language": "en",
+ "description": "The COUNT_MAP function aggregates MAP values by key and
returns the count of non-NULL values for each key."
+}
+---
+
+## Description
+
+The COUNT_MAP function aggregates MAP values by key and returns a MAP that
contains the count of non-NULL values for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+COUNT_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>` and BIGINT values.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is 0.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, COUNT_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-----------+
+| id | keys | values |
++------+-----------+-----------+
+| 1 | [1, 2, 3] | [1, 2, 1] |
+| 2 | [1, 4] | [1, 0] |
++------+-----------+-----------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, COUNT_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-----------+
+| id | keys | values |
++------+-----------+-----------+
+| 1 | [1, 2, 3] | [2, 1, 0] |
+| 2 | [2] | [1] |
++------+-----------+-----------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT COUNT_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-map.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-map.md
new file mode 100644
index 00000000000..00e9291268a
--- /dev/null
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/max-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "MAX_MAP",
+ "language": "en",
+ "description": "The MAX_MAP function aggregates MAP values by key and
returns the maximum value for each key."
+}
+---
+
+## Description
+
+The MAX_MAP function aggregates MAP values by key and returns a MAP that
contains the maximum non-NULL value for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+MAX_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. The MAP value type must be comparable by
the MAX aggregate function. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>`. For DecimalV2 value
types, the returned value type is the corresponding DecimalV3 type. For other
value types, the returned value type is the same as the input MAP value type.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is NULL.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MAX_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+--------------+
+| id | keys | values |
++------+-----------+--------------+
+| 1 | [1, 2, 3] | [10, 20, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+--------------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MAX_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | ["b", "x", null] |
+| 2 | [2] | ["z"] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT MAX_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-map.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-map.md
new file mode 100644
index 00000000000..f29b311bf67
--- /dev/null
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/min-map.md
@@ -0,0 +1,115 @@
+---
+{
+ "title": "MIN_MAP",
+ "language": "en",
+ "description": "The MIN_MAP function aggregates MAP values by key and
returns the minimum value for each key."
+}
+---
+
+## Description
+
+The MIN_MAP function aggregates MAP values by key and returns a MAP that
contains the minimum non-NULL value for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+MIN_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. The MAP value type must be comparable by
the MIN aggregate function. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>`. For DecimalV2 value
types, the returned value type is the corresponding DecimalV3 type. For other
value types, the returned value type is the same as the input MAP value type.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is NULL.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ ms MAP<INT, STRING>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP(1, 'b', 2, 'x')),
+ (1, MAP(2, 5, 3, 30), MAP(1, 'a', 3, NULL)),
+ (2, MAP(1, 7, 4, NULL), MAP(2, 'z')),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<INT, STRING>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MIN_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+-------------+
+| id | keys | values |
++------+-----------+-------------+
+| 1 | [1, 2, 3] | [10, 5, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+-------------+
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, MIN_MAP(ms) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+----------------+
+| id | keys | values |
++------+-----------+----------------+
+| 1 | [1, 2, 3] | ["a", "x", null] |
+| 2 | [2] | ["z"] |
++------+-----------+----------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT MIN_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/sum-map.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/sum-map.md
new file mode 100644
index 00000000000..b0b904ba4d0
--- /dev/null
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/sum-map.md
@@ -0,0 +1,111 @@
+---
+{
+ "title": "SUM_MAP",
+ "language": "en",
+ "description": "The SUM_MAP function aggregates MAP values by key and
returns the sum of values for each key."
+}
+---
+
+## Description
+
+The SUM_MAP function aggregates MAP values by key and returns a MAP that
contains the sum of non-NULL values for each key.
+
+## Usage Notes
+
+The order of entries in the returned MAP is not guaranteed. Use `map_keys`,
`map_values`, `array_sort`, and `array_sortby` when stable output order is
required. A NULL key is aggregated as a regular key; all NULL keys belong to
the same result entry.
+
+## Syntax
+
+```sql
+SUM_MAP(<map_expr>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<map_expr>` | A MAP expression. The MAP value type must be numeric. |
+
+## Return Value
+
+Returns a MAP with the same key type as `<map_expr>`. For integer-like,
Boolean, and NULL value types, the returned value type is BIGINT. For Float and
Double value types, the returned value type is DOUBLE. For Decimal value types,
the returned value type is a Decimal type with the maximum supported precision
and the same scale. For LargeInt value types, the returned value type is
LargeInt.
+
+If there is no valid input row in the group, returns an empty MAP. If a key
appears but all values for that key are NULL, the value for that key is NULL.
+
+## Example
+
+```sql
+-- setup
+CREATE TABLE map_agg_example (
+ id INT,
+ m MAP<INT, INT>,
+ md MAP<STRING, DECIMAL(10, 2)>
+) DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO map_agg_example VALUES
+ (1, MAP(1, 10, 2, 20), MAP('a', 1.20, 'b', 2.30)),
+ (1, MAP(2, 5, 3, 30), MAP('b', 3.70, 'c', 4.00)),
+ (2, MAP(1, 7, 4, NULL), MAP('a', NULL, 'c', 5.50)),
+ (2, CAST(MAP() AS MAP<INT, INT>), CAST(MAP() AS MAP<STRING, DECIMAL(10,
2)>));
+```
+
+```text
+Query OK
+```
+
+```sql
+SELECT id,
+ array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT id, SUM_MAP(m) AS result
+ FROM map_agg_example
+ GROUP BY id
+) t
+ORDER BY id;
+```
+
+```text
++------+-----------+--------------+
+| id | keys | values |
++------+-----------+--------------+
+| 1 | [1, 2, 3] | [10, 25, 30] |
+| 2 | [1, 4] | [7, null] |
++------+-----------+--------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT SUM_MAP(md) AS result
+ FROM map_agg_example
+) t;
+```
+
+```text
++-----------------+--------------------+
+| keys | values |
++-----------------+--------------------+
+| ["a", "b", "c"] | [1.20, 6.00, 9.50] |
++-----------------+--------------------+
+```
+
+```sql
+SELECT array_sort(map_keys(result)) AS keys,
+ array_sortby(map_values(result), map_keys(result)) AS values
+FROM (
+ SELECT SUM_MAP(m) AS result
+ FROM map_agg_example
+ WHERE id = 100
+) t;
+```
+
+```text
++------+--------+
+| keys | values |
++------+--------+
+| [] | [] |
++------+--------+
+```
diff --git a/versioned_sidebars/version-4.x-sidebars.json
b/versioned_sidebars/version-4.x-sidebars.json
index 79122e9962f..99b2ca4935b 100644
--- a/versioned_sidebars/version-4.x-sidebars.json
+++ b/versioned_sidebars/version-4.x-sidebars.json
@@ -2193,6 +2193,7 @@
"sql-manual/sql-functions/aggregate-functions/approx-count-distinct",
"sql-manual/sql-functions/aggregate-functions/array-agg",
"sql-manual/sql-functions/aggregate-functions/avg",
+ "sql-manual/sql-functions/aggregate-functions/avg-map",
"sql-manual/sql-functions/aggregate-functions/avg-weighted",
"sql-manual/sql-functions/aggregate-functions/bitmap-agg",
"sql-manual/sql-functions/aggregate-functions/bitmap-intersect",
@@ -2208,6 +2209,7 @@
"sql-manual/sql-functions/aggregate-functions/corr",
"sql-manual/sql-functions/aggregate-functions/count",
"sql-manual/sql-functions/aggregate-functions/count-by-enum",
+ "sql-manual/sql-functions/aggregate-functions/count-map",
"sql-manual/sql-functions/aggregate-functions/covar",
"sql-manual/sql-functions/aggregate-functions/covar-samp",
"sql-manual/sql-functions/aggregate-functions/datasketches_hll_union_agg",
@@ -2227,9 +2229,11 @@
"sql-manual/sql-functions/aggregate-functions/map-agg",
"sql-manual/sql-functions/aggregate-functions/max",
"sql-manual/sql-functions/aggregate-functions/max-by",
+ "sql-manual/sql-functions/aggregate-functions/max-map",
"sql-manual/sql-functions/aggregate-functions/median",
"sql-manual/sql-functions/aggregate-functions/min",
"sql-manual/sql-functions/aggregate-functions/min-by",
+ "sql-manual/sql-functions/aggregate-functions/min-map",
"sql-manual/sql-functions/aggregate-functions/percentile",
"sql-manual/sql-functions/aggregate-functions/percentile-approx",
"sql-manual/sql-functions/aggregate-functions/percentile-array",
@@ -2254,6 +2258,7 @@
"sql-manual/sql-functions/aggregate-functions/stddev-samp",
"sql-manual/sql-functions/aggregate-functions/sum",
"sql-manual/sql-functions/aggregate-functions/sum0",
+ "sql-manual/sql-functions/aggregate-functions/sum-map",
"sql-manual/sql-functions/aggregate-functions/topn",
"sql-manual/sql-functions/aggregate-functions/topn-array",
"sql-manual/sql-functions/aggregate-functions/topn-weighted",
@@ -2291,6 +2296,7 @@
"sql-manual/sql-functions/aggregate-functions/approx-count-distinct",
"sql-manual/sql-functions/aggregate-functions/array-agg",
"sql-manual/sql-functions/aggregate-functions/avg",
+ "sql-manual/sql-functions/aggregate-functions/avg-map",
"sql-manual/sql-functions/aggregate-functions/avg-weighted",
"sql-manual/sql-functions/aggregate-functions/bitmap-agg",
"sql-manual/sql-functions/aggregate-functions/bitmap-intersect",
@@ -2306,6 +2312,7 @@
"sql-manual/sql-functions/aggregate-functions/corr",
"sql-manual/sql-functions/aggregate-functions/count",
"sql-manual/sql-functions/aggregate-functions/count-by-enum",
+ "sql-manual/sql-functions/aggregate-functions/count-map",
"sql-manual/sql-functions/aggregate-functions/covar",
"sql-manual/sql-functions/aggregate-functions/covar-samp",
"sql-manual/sql-functions/aggregate-functions/group-array-intersect",
@@ -2323,9 +2330,11 @@
"sql-manual/sql-functions/aggregate-functions/map-agg",
"sql-manual/sql-functions/aggregate-functions/max",
"sql-manual/sql-functions/aggregate-functions/max-by",
+ "sql-manual/sql-functions/aggregate-functions/max-map",
"sql-manual/sql-functions/aggregate-functions/median",
"sql-manual/sql-functions/aggregate-functions/min",
"sql-manual/sql-functions/aggregate-functions/min-by",
+ "sql-manual/sql-functions/aggregate-functions/min-map",
"sql-manual/sql-functions/aggregate-functions/percentile",
"sql-manual/sql-functions/aggregate-functions/percentile-approx",
"sql-manual/sql-functions/aggregate-functions/percentile-array",
@@ -2348,6 +2357,7 @@
"sql-manual/sql-functions/aggregate-functions/stddev-samp",
"sql-manual/sql-functions/aggregate-functions/sum",
"sql-manual/sql-functions/aggregate-functions/sum0",
+ "sql-manual/sql-functions/aggregate-functions/sum-map",
"sql-manual/sql-functions/aggregate-functions/topn",
"sql-manual/sql-functions/aggregate-functions/topn-array",
"sql-manual/sql-functions/aggregate-functions/topn-weighted",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]