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 6c886a48a2e update json_type (#2630)
6c886a48a2e is described below

commit 6c886a48a2e3964c5d08ec76565f8a480521b148
Author: Jerry Hu <[email protected]>
AuthorDate: Fri Jul 18 11:47:20 2025 +0800

    update json_type (#2630)
    
    ## Versions
    
    - [x] dev
    - [x] 3.0
    - [ ] 2.1
    - [ ] 2.0
    
    ## Languages
    
    - [x] Chinese
    - [x] English
---
 .../scalar-functions/json-functions/json-type.md   | 112 ++++++++++------
 .../scalar-functions/json-functions/json-type.md   | 144 ++++++++++++---------
 .../scalar-functions/json-functions/json-type.md   | 144 ++++++++++++---------
 .../scalar-functions/json-functions/json-type.md   | 122 +++++++++--------
 4 files changed, 303 insertions(+), 219 deletions(-)

diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md 
b/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
index eaf679a923a..52ff4a9f884 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
@@ -26,57 +26,83 @@ JSON_TYPE( <json>, <json_path> )
 ```
 
 ## Alias
+- `JSONB_TYPE`
 
-- JSONB_TYPE
-
-## Required Parameters
-
-
-| Parameter | Description |
-|------|------|
-| `<json>` | The JSON string to check the type of. |
-| `<json_path>` | JSON path, which specifies the location of the field in 
JSON. The path is usually given in $. At the beginning, use. to represent the 
hierarchical structure. |
+## Parameters
 
+- `<json>` The JSON string to check the type of.
+- `<json_path>` String type, which specifies the location of the field in 
JSON. The path is usually given in $. At the beginning, use. to represent the 
hierarchical structure.
 
 ## Return Value
-Returns the type of the JSON string. Possible values include:
-- "NULL": Indicates that the value in the JSON document is null.
-- "BOOLEAN": Indicates that the value in the JSON document is of boolean type 
(true or false).
-- "NUMBER": Indicates that the value in the JSON document is a number.
-- "STRING": Indicates that the value in the JSON document is a string.
-- "OBJECT": Indicates that the value in the JSON document is a JSON object.
-- "ARRAY": Indicates that the value in the JSON document is a JSON array.
 
-## Usage Notes
+`Nullable<String>`: Returns the type of the corresponding field.
 
-JSON_TYPE returns the type of the outermost value in the JSON document. If the 
JSON document contains multiple different types of values, it will return the 
type of the outermost value. For invalid JSON strings, JSON_TYPE returns NULL. 
Refer to [json 
tutorial](../../../basic-element/sql-data-types/semi-structured/JSON)
+## Usage Notes
+- If `<json_object>` or `<json_path>` is NULL, returns NULL.
+- If `<json_path>` is not a valid path, the function reports an error.
+- If the field specified by `<json_path>` does not exist, returns NULL.
 
 ## Examples
 1. JSON is of string type:
-
-```sql
-SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.name');
-```
-
-```sql
-+-------------------------------------------------------------------+
-| jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.name') |
-+-------------------------------------------------------------------+
-| string                                                            |
-+-------------------------------------------------------------------+
-```
+    ```sql
+    SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.name');
+    ```
+    ```text
+    +-------------------------------------------------------------------+
+    | jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.name') |
+    +-------------------------------------------------------------------+
+    | string                                                            |
+    +-------------------------------------------------------------------+
+    ```
 
 2. JSON is of number type:
-
-```sql
-SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.age');
-```
-
-```sql
-+------------------------------------------------------------------+
-| jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.age') |
-+------------------------------------------------------------------+
-| int                                                              |
-+------------------------------------------------------------------+
-```
-
+    ```sql
+    SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.age');
+    ```
+    ```text
+    +------------------------------------------------------------------+
+    | jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.age') |
+    +------------------------------------------------------------------+
+    | int                                                              |
+    +------------------------------------------------------------------+
+    ```
+3. NULL parameters
+    ```sql
+    select json_type(NULL, '$.key1');
+    ```
+    ```text
+    +---------------------------+
+    | json_type(NULL, '$.key1') |
+    +---------------------------+
+    | NULL                      |
+    +---------------------------+
+    ```
+4. NULL parameters 2
+    ```sql
+    select json_type('{"key1": true}', NULL);
+    ```
+    ```text
+    +-----------------------------------+
+    | json_type('{"key1": true}', NULL) |
+    +-----------------------------------+
+    | NULL                              |
+    +-----------------------------------+
+    ```
+5. Field specified by `json_path` parameter does not exist
+    ```sql
+    select json_type('{"key1": true}', '$.key2');
+    ```
+    ```text
+    +---------------------------------------+
+    | json_type('{"key1": true}', '$.key2') |
+    +---------------------------------------+
+    | NULL                                  |
+    +---------------------------------------+
+    ```
+6. Invalid `json_path` parameter
+    ```sql
+    select json_type('{"key1": true}', '$.');
+    ```
+    ```text
+    ERROR 1105 (HY000): errCode = 2, detailMessage = [INVALID_ARGUMENT]Json 
path error: Invalid Json Path for value: $.
+    ```
\ No newline at end of file
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
index 6d05660c8d2..5191d932602 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
@@ -6,77 +6,97 @@
 ---
 
 ## 描述
-
-用来判断 json_path 指定的字段在 JSONB 数据中的类型,如果字段不存在返回 NULL,如果存在返回下面的类型之一
-
-- object
-- array
-- null
-- bool
-- int
-- bigint
-- largeint
-- double
-- string
+用来判断 JSON 对象中 `<json_path>` 指定的字段的类型,如果字段不存在返回 NULL,如果存在返回下面的类型之一:
+* object
+* array
+* null
+* bool
+* int
+* bigint
+* largeint
+* double
+* string
 
 ## 语法
-
 ```sql
-STRING JSON_TYPE( <json> )
+JSON_TYPE(<json_object>, <json_path>)
 ```
 
 ## 别名
+- `JSONB_TYPE`
 
-- JSONB_TYPE
-
-## 必选参数
-
-| 参数 | 描述 |
-|------|------|
-| `<json>` | 需要检查类型的 JSON 字符串。 |
-
+## 参数
+- `<json_object>`: [JSON 
类型](../../../basic-element/sql-data-types/semi-structured/JSON.md) 的表达式。
+- `<json_path>`: String 类型,比如 `"$.key"`。
 
 ## 返回值
-返回 JSON 字符串的类型,可能的值包括:
-- "NULL":表示 JSON 文档的值为 null。
-- "BOOLEAN":表示 JSON 文档的值为布尔类型(true 或 false)。
-- "NUMBER":表示 JSON 文档的值为数字类型。
-- "STRING":表示 JSON 文档的值为字符串类型。
-- "OBJECT":表示 JSON 文档的值为 JSON 对象。
-- "ARRAY":表示 JSON 文档的值为 JSON 数组。
-
-## 注意事项
-
-JSON_TYPE 返回的是 JSON 文档中最外层的值的类型。如果 JSON 文档包含多个不同类型的值,则返回最外层值的类型。
-对于无效的 JSON 字符串,JSON_TYPE 会返回 NULL。
-参考 [json tutorial](../../../basic-element/sql-data-types/semi-structured/JSON) 
中的示例
+`Nullable<String>`: 返回对应字段的类型。
 
+## 使用说明
+- 如果 `<json_object>` 或者 `<json_path>` 是 NULL,返回 NULL。
+- 如果 `<json_path>` 不是一个合法路径,函数报错。
+- 如果 `<json_path>` 指定的字段,返回 NULL。
 
 ## 示例
-1. JSON 为字符串类型
-
-```sql
-SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.name');
-```
-
-```sql
-+-------------------------------------------------------------------+
-| jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.name') |
-+-------------------------------------------------------------------+
-| string                                                            |
-+-------------------------------------------------------------------+
-```
-
-2. JSON 为数字类型
-
-```sql
-SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.age');
-```
-
-```sql
-+------------------------------------------------------------------+
-| jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.age') |
-+------------------------------------------------------------------+
-| int                                                              |
-+------------------------------------------------------------------+
-```
\ No newline at end of file
+1. Double 类型
+    ```sql
+    select json_type('{"key1": 1234.44}', '$.key1');
+    ```
+    ```
+    +------------------------------------------+
+    | json_type('{"key1": 1234.44}', '$.key1') |
+    +------------------------------------------+
+    | double                                   |
+    +------------------------------------------+
+    ```
+2. BOOLEAN 类型
+    ```sql
+    select json_type('{"key1": true}', '$.key1');
+    ```
+    ```
+    +---------------------------------------+
+    | json_type('{"key1": true}', '$.key1') |
+    +---------------------------------------+
+    | bool                                  |
+    +---------------------------------------+
+    ```
+3. NULL 参数
+    ```sql
+    select json_type(NULL, '$.key1');
+    ```
+    ```
+    +---------------------------+
+    | json_type(NULL, '$.key1') |
+    +---------------------------+
+    | NULL                      |
+    +---------------------------+
+    ```
+4. NULL 参数 2
+    ```sql
+    select json_type('{"key1": true}', NULL);
+    ```
+    ```
+    +-----------------------------------+
+    | json_type('{"key1": true}', NULL) |
+    +-----------------------------------+
+    | NULL                              |
+    +-----------------------------------+
+    ```
+5. `json_path` 参数指定的字段不存在
+    ```sql
+    select json_type('{"key1": true}', '$.key2');
+    ```
+    ```
+    +---------------------------------------+
+    | json_type('{"key1": true}', '$.key2') |
+    +---------------------------------------+
+    | NULL                                  |
+    +---------------------------------------+
+    ```
+6. 错误的 `json_path` 参数
+    ```sql
+    select json_type('{"key1": true}', '$.');
+    ```
+    ```
+    ERROR 1105 (HY000): errCode = 2, detailMessage = [INVALID_ARGUMENT]Json 
path error: Invalid Json Path for value: $.
+    ```
\ No newline at end of file
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
index b77eec5674d..5191d932602 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
@@ -6,77 +6,97 @@
 ---
 
 ## 描述
-
-用来判断 json_path 指定的字段在 JSONB 数据中的类型,如果字段不存在返回 NULL,如果存在返回下面的类型之一
-
-- object
-- array
-- null
-- bool
-- int
-- bigint
-- largeint
-- double
-- string
+用来判断 JSON 对象中 `<json_path>` 指定的字段的类型,如果字段不存在返回 NULL,如果存在返回下面的类型之一:
+* object
+* array
+* null
+* bool
+* int
+* bigint
+* largeint
+* double
+* string
 
 ## 语法
-
 ```sql
-STRING JSON_TYPE( <json> )
+JSON_TYPE(<json_object>, <json_path>)
 ```
 
 ## 别名
+- `JSONB_TYPE`
 
-- JSONB_TYPE
-
-## 必选参数
-
-| 参数 | 描述 |
-|------|------|
-| `<json>` | 需要检查类型的 JSON 字符串。 |
-
+## 参数
+- `<json_object>`: [JSON 
类型](../../../basic-element/sql-data-types/semi-structured/JSON.md) 的表达式。
+- `<json_path>`: String 类型,比如 `"$.key"`。
 
 ## 返回值
-返回 JSON 字符串的类型,可能的值包括:
-- "NULL":表示 JSON 文档的值为 null。
-- "BOOLEAN":表示 JSON 文档的值为布尔类型(true 或 false)。
-- "NUMBER":表示 JSON 文档的值为数字类型。
-- "STRING":表示 JSON 文档的值为字符串类型。
-- "OBJECT":表示 JSON 文档的值为 JSON 对象。
-- "ARRAY":表示 JSON 文档的值为 JSON 数组。
-
-## 注意事项
-
-JSON_TYPE 返回的是 JSON 文档中最外层的值的类型。如果 JSON 文档包含多个不同类型的值,则返回最外层值的类型。
-对于无效的 JSON 字符串,JSON_TYPE 会返回 NULL。
-参考 [json tutorial](../../../basic-element/sql-data-types/semi-structured/JSON) 
中的示例
+`Nullable<String>`: 返回对应字段的类型。
 
+## 使用说明
+- 如果 `<json_object>` 或者 `<json_path>` 是 NULL,返回 NULL。
+- 如果 `<json_path>` 不是一个合法路径,函数报错。
+- 如果 `<json_path>` 指定的字段,返回 NULL。
 
 ## 示例
-1. JSON 为字符串类型
-
-```sql
-SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.name');
-```
-
-```sql
-+-------------------------------------------------------------------+
-| jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.name') |
-+-------------------------------------------------------------------+
-| string                                                            |
-+-------------------------------------------------------------------+
-```
-
-2. JSON 为数字类型
-
-```sql
-SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.age');
-```
-
-```sql
-+------------------------------------------------------------------+
-| jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.age') |
-+------------------------------------------------------------------+
-| int                                                              |
-+------------------------------------------------------------------+
-```
+1. Double 类型
+    ```sql
+    select json_type('{"key1": 1234.44}', '$.key1');
+    ```
+    ```
+    +------------------------------------------+
+    | json_type('{"key1": 1234.44}', '$.key1') |
+    +------------------------------------------+
+    | double                                   |
+    +------------------------------------------+
+    ```
+2. BOOLEAN 类型
+    ```sql
+    select json_type('{"key1": true}', '$.key1');
+    ```
+    ```
+    +---------------------------------------+
+    | json_type('{"key1": true}', '$.key1') |
+    +---------------------------------------+
+    | bool                                  |
+    +---------------------------------------+
+    ```
+3. NULL 参数
+    ```sql
+    select json_type(NULL, '$.key1');
+    ```
+    ```
+    +---------------------------+
+    | json_type(NULL, '$.key1') |
+    +---------------------------+
+    | NULL                      |
+    +---------------------------+
+    ```
+4. NULL 参数 2
+    ```sql
+    select json_type('{"key1": true}', NULL);
+    ```
+    ```
+    +-----------------------------------+
+    | json_type('{"key1": true}', NULL) |
+    +-----------------------------------+
+    | NULL                              |
+    +-----------------------------------+
+    ```
+5. `json_path` 参数指定的字段不存在
+    ```sql
+    select json_type('{"key1": true}', '$.key2');
+    ```
+    ```
+    +---------------------------------------+
+    | json_type('{"key1": true}', '$.key2') |
+    +---------------------------------------+
+    | NULL                                  |
+    +---------------------------------------+
+    ```
+6. 错误的 `json_path` 参数
+    ```sql
+    select json_type('{"key1": true}', '$.');
+    ```
+    ```
+    ERROR 1105 (HY000): errCode = 2, detailMessage = [INVALID_ARGUMENT]Json 
path error: Invalid Json Path for value: $.
+    ```
\ No newline at end of file
diff --git 
a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
 
b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
index ab76a82efca..52ff4a9f884 100644
--- 
a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
+++ 
b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-type.md
@@ -22,69 +22,87 @@ Used to determine the type of the field specified by 
`json_path` in the JSONB da
 ## Syntax
 
 ```sql
-STRING JSON_TYPE( <JSON j> )
+JSON_TYPE( <json>, <json_path> )
 ```
 
 ## Alias
+- `JSONB_TYPE`
 
-- JSONB_TYPE
-
-## Required Parameters
-
-
-| Parameter | Description |
-|------|------|
-| `<JSON j>` | The JSON string to check the type of. |
+## Parameters
 
+- `<json>` The JSON string to check the type of.
+- `<json_path>` String type, which specifies the location of the field in 
JSON. The path is usually given in $. At the beginning, use. to represent the 
hierarchical structure.
 
 ## Return Value
-Returns the type of the JSON string. Possible values include:
-- "NULL": Indicates that the value in the JSON document is null.
-- "BOOLEAN": Indicates that the value in the JSON document is of boolean type 
(true or false).
-- "NUMBER": Indicates that the value in the JSON document is a number.
-- "STRING": Indicates that the value in the JSON document is a string.
-- "OBJECT": Indicates that the value in the JSON document is a JSON object.
-- "ARRAY": Indicates that the value in the JSON document is a JSON array.
 
-## Usage Notes
+`Nullable<String>`: Returns the type of the corresponding field.
 
-JSON_TYPE returns the type of the outermost value in the JSON document. If the 
JSON document contains multiple different types of values, it will return the 
type of the outermost value. For invalid JSON strings, JSON_TYPE returns NULL. 
Refer to [json 
tutorial](../../../basic-element/sql-data-types/semi-structured/JSON)
+## Usage Notes
+- If `<json_object>` or `<json_path>` is NULL, returns NULL.
+- If `<json_path>` is not a valid path, the function reports an error.
+- If the field specified by `<json_path>` does not exist, returns NULL.
 
 ## Examples
 1. JSON is of string type:
-
-```sql
-SELECT JSON_TYPE('"Hello, World!"');
-```
-
-```sql
-+------------------------------------------+
-| JSON_TYPE('"Hello, World!"')            |
-+------------------------------------------+
-| STRING                                   |
-+------------------------------------------+
-```
+    ```sql
+    SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.name');
+    ```
+    ```text
+    +-------------------------------------------------------------------+
+    | jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.name') |
+    +-------------------------------------------------------------------+
+    | string                                                            |
+    +-------------------------------------------------------------------+
+    ```
 
 2. JSON is of number type:
-
-```sql
-SELECT JSON_TYPE('123');
-```
-```sql
-+------------------------------------------+
-| JSON_TYPE('123')                        |
-+------------------------------------------+
-| NUMBER                                   |
-+------------------------------------------+
-```
-3. JSON is of null type:
-```sql
-SELECT JSON_TYPE('null');
-```
-```sql
-+------------------------------------------+
-| JSON_TYPE('null')                        |
-+------------------------------------------+
-| NULL                                     |
-+------------------------------------------+
-```
+    ```sql
+    SELECT JSON_TYPE('{"name": "John", "age": 30}', '$.age');
+    ```
+    ```text
+    +------------------------------------------------------------------+
+    | jsonb_type(cast('{"name": "John", "age": 30}' as JSON), '$.age') |
+    +------------------------------------------------------------------+
+    | int                                                              |
+    +------------------------------------------------------------------+
+    ```
+3. NULL parameters
+    ```sql
+    select json_type(NULL, '$.key1');
+    ```
+    ```text
+    +---------------------------+
+    | json_type(NULL, '$.key1') |
+    +---------------------------+
+    | NULL                      |
+    +---------------------------+
+    ```
+4. NULL parameters 2
+    ```sql
+    select json_type('{"key1": true}', NULL);
+    ```
+    ```text
+    +-----------------------------------+
+    | json_type('{"key1": true}', NULL) |
+    +-----------------------------------+
+    | NULL                              |
+    +-----------------------------------+
+    ```
+5. Field specified by `json_path` parameter does not exist
+    ```sql
+    select json_type('{"key1": true}', '$.key2');
+    ```
+    ```text
+    +---------------------------------------+
+    | json_type('{"key1": true}', '$.key2') |
+    +---------------------------------------+
+    | NULL                                  |
+    +---------------------------------------+
+    ```
+6. Invalid `json_path` parameter
+    ```sql
+    select json_type('{"key1": true}', '$.');
+    ```
+    ```text
+    ERROR 1105 (HY000): errCode = 2, detailMessage = [INVALID_ARGUMENT]Json 
path error: Invalid Json Path for value: $.
+    ```
\ No newline at end of file


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

Reply via email to