This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git


The following commit(s) were added to refs/heads/master by this push:
     new f99cf7b448a [doc](map) Improve the documentation for the Map type 
(#2384)
f99cf7b448a is described below

commit f99cf7b448a482042ed6c168216a4843b660cdda
Author: Jerry Hu <[email protected]>
AuthorDate: Sat May 24 09:25:30 2025 +0800

    [doc](map) Improve the documentation for the Map type (#2384)
    
    ## Versions
    
    - [x] dev
    - [ ] 3.0
    - [ ] 2.1
    - [ ] 2.0
    
    ## Languages
    
    - [ ] Chinese
    - [ ] English
    
    ## Docs Checklist
    
    - [ ] Checked by AI
    - [ ] Test Cases Built
---
 .../sql-data-types/semi-structured/MAP.md          | 35 ++++++++++++++--------
 .../map-functions/map-contains-key.md              | 22 ++++++++++----
 .../scalar-functions/map-functions/map.md          | 25 ++++++++++++----
 .../sql-data-types/semi-structured/MAP.md          | 28 +++++++++++++----
 .../map-functions/map-contains-key.md              | 21 +++++++++----
 .../scalar-functions/map-functions/map.md          | 25 ++++++++++++----
 6 files changed, 115 insertions(+), 41 deletions(-)

diff --git 
a/docs/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md 
b/docs/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md
index e8af560078e..101b3b99617 100644
--- a/docs/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md
+++ b/docs/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md
@@ -26,29 +26,38 @@ under the License.
 
 ## MAP
 
-### name
+### Name
 
 MAP
 
-### description
-
+### Syntax
 `MAP<K, V>`
 
+Where:
+
+* `K` is the type of the key for the map. You should must use one of the 
following types for keys:
+  * String Data Type(Char/Varchar/String)
+  * Numeric Data Type(except double and float)
+  * Date Type(Date/Datetime/Time)
+  * IP Address Type(IPV4/IPV6)
+
+  Map keys always be nullable. 
+
+  **Because nullable types are supported as map keys, key comparison in maps 
uses "null-safe equal" (null and null are considered equal), which differs from 
the standard SQL definition.**
+
+* `V` is the type of the value in the map. And it is always nullable.
+
+The Map type does not support duplicate keys; Doris will automatically remove 
duplicates (only one entry is retained for each identical key).
+
+### Description
+
 A Map of K, V items, it cannot be used as a key column. Now MAP can only used 
in Duplicate and Unique Model Tables.
 
 Need to manually enable the support, it is disabled by default.
 ```
 admin set frontend config("enable_map_type" = "true");
 ```
-
-K,V could be any of:
-
-```
-BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, 
DECIMALV3, DATE,
-DATEV2, DATETIME, DATETIMEV2, CHAR, VARCHAR, STRING
-```
-
-### example
+### Example
 
 Create table example:
 
@@ -269,6 +278,6 @@ mysql> SELECT id, map_values(m) FROM simple_map ORDER BY id;
 
 ```
 
-### keywords
+### Keywords
 
     MAP
diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md
 
b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md
index 70bba730c09..999142c4599 100644
--- 
a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md
+++ 
b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md
@@ -52,9 +52,21 @@ select map_contains_key(map(null, 1, 2, null), 
null),map_contains_key(map(1, "10
 ```
 
 ```text
-+-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| map_contains_key(map(NULL, 1, 2, NULL), NULL) | 
map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as 
DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), 
cast(0.11 as DECIMALV3(3, 2))) |
-+-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-|                                             1 |                              
                                                                                
                                                                 0 |
-+-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
++-----------------------------------------------+-----------------------------------------------+
+| map_contains_key(map(null, 1, 2, null), null) | map_contains_key(map(1, 
"100", 0.1, 2), 0.11) |
++-----------------------------------------------+-----------------------------------------------+
+|                                             1 |                              
               0 |
++-----------------------------------------------+-----------------------------------------------+
+```
+* Key comparison in maps uses "null-safe equal" (null and null are considered 
equal), which differs from the standard SQL definition.
+
+```sql
+select map_contains_key(map(null,1), null);
+```
+```text
++-------------------------------------+
+| map_contains_key(map(null,1), null) |
++-------------------------------------+
+|                                   1 |
++-------------------------------------+
 ```
diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md 
b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md
index f19716c0dc1..5788f8c0d8d 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md
@@ -26,7 +26,7 @@ under the License.
 
 ## Description
 
-Constructs a `Map<K, V>` of a specific type using some set of key-value pairs
+Constructs a [`Map<K, 
V>`](../../../basic-element/sql-data-types/semi-structured/MAP.md) of a 
specific type using some set of key-value pairs
 
 ## Syntax
 
@@ -52,9 +52,22 @@ select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1];
 ```
 
 ```text
-+---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
-| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 
as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as 
DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) |
-+---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
-| {1.0:"100", 0.1:"2"}                                                         
         | 100                                                                  
                                                         |
-+---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
++-----------------------+--------------------------+
+| map(1, "100", 0.1, 2) | map(1, "100", 0.1, 2)[1] |
++-----------------------+--------------------------+
+| {1.0:"100", 0.1:"2"}  | 100                      |
++-----------------------+--------------------------+
 ```
+
+* If there are duplicate keys, they will be deduplicated:
+```sql
+select map(1, 2, 2, 11, 1, 3);
+```
+```text
++------------------------+
+| map(1, 2, 2, 11, 1, 3) |
++------------------------+
+| {2:11, 1:3}            |
++------------------------+
+```
+> There are two sets of parameters with the key 1 (1, 2 and 1, 3), only 1, 3 
is retained.
\ No newline at end of file
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md
index 3012121b439..0998e167338 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md
@@ -26,21 +26,37 @@ under the License.
 
 ## MAP
 
-### name
+### Name
 
 MAP
 
-## 描述
-
+### 语法
 `MAP<K, V>`
 
+其中:
+
+* K 是 Map 的键类型。键必须使用以下类型之一:
+       *       字符串类型(Char/Varchar/String)
+       *       数值类型(不包括浮点数类型:double 和 float)1
+  * 日期类型
+  * IP 地址类型(IPV4/IPV6)
+
+  Map 的 Key 类型 始终为 nullable。
+  
+  **因为支持 nullable 类型作为 map 的 key,map 中的 key 比较使用的是 “null-safe equal”(即 null 和 
null 被认为是相等的),这与标准 SQL 的定义不同。**
+
+*      V 是 Map 中值的类型,始终为 nullable。
+
+Map 类型不支持重复的键;Doris 会自动删除重复的项。
+
+### 描述
+
 由 K, V 类型元素组成的 map,不能作为 key 列使用。目前支持在 Duplicate,Unique 模型的表中使用。
 
-K,V 支持的类型有:
 
+Map 类型支持默认情况下是没有开启的,需要设置参数:
 ```
-BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, 
DECIMALV3, DATE,
-DATEV2, DATETIME, DATETIMEV2, CHAR, VARCHAR, STRING
+admin set frontend config("enable_map_type" = "true");
 ```
 
 ## 举例
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md
index dba5ce90c7a..5e927f77759 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md
@@ -52,9 +52,20 @@ select map_contains_key(map(null, 1, 2, null), 
null),map_contains_key(map(1, "10
 ```
 
 ```text
-+-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| map_contains_key(map(NULL, 1, 2, NULL), NULL) | 
map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as 
DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), 
cast(0.11 as DECIMALV3(3, 2))) |
-+-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-|                                             1 |                              
                                                                                
                                                                 0 |
-+-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
++-----------------------------------------------+-----------------------------------------------+
+| map_contains_key(map(null, 1, 2, null), null) | map_contains_key(map(1, 
"100", 0.1, 2), 0.11) |
++-----------------------------------------------+-----------------------------------------------+
+|                                             1 |                              
               0 |
++-----------------------------------------------+-----------------------------------------------+
 ```
+* Map 中的 key 比较使用的是 “null-safe equal”(null 和 null 被认为是相等的),这与标准 SQL 的定义不同。
+
+```sql
+select map_contains_key(map(null,1), null);
+```
+```text
++-------------------------------------+
+| map_contains_key(map(null,1), null) |
++-------------------------------------+
+|                                   1 |
++-------------------------------------+
\ No newline at end of file
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md
index 95896922640..c26ae316e93 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md
@@ -26,7 +26,7 @@ under the License.
 
 ## 描述
 
-使用若干组键值对构造一个特定类型的 `Map<K, V>`
+使用若干组键值对构造一个特定类型的 [`Map<K, 
V>`](../../../basic-element/sql-data-types/semi-structured/MAP.md)
 
 ## 语法
 
@@ -52,9 +52,22 @@ select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1];
 ```
 
 ```text
-+---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
-| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 
as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as 
DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) |
-+---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
-| {1.0:"100", 0.1:"2"}                                                         
         | 100                                                                  
                                                         |
-+---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
++-----------------------+--------------------------+
+| map(1, "100", 0.1, 2) | map(1, "100", 0.1, 2)[1] |
++-----------------------+--------------------------+
+| {1.0:"100", 0.1:"2"}  | 100                      |
++-----------------------+--------------------------+
 ```
+
+* 如果有重复的 key,会去重:
+```sql
+select map(1, 2, 2, 11, 1, 3);
+```
+```text
++------------------------+
+| map(1, 2, 2, 11, 1, 3) |
++------------------------+
+| {2:11, 1:3}            |
++------------------------+
+```
+> 上面有两组参数都是以 1 为 key(1, 2 和 1, 3),最后保留 1, 3。
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to