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 374e4901be3 update json path ** (#2786)
374e4901be3 is described below
commit 374e4901be3e81d5bc93dde9fe2760eef29236cf
Author: Jerry Hu <[email protected]>
AuthorDate: Fri Aug 29 14:43:09 2025 +0800
update json path ** (#2786)
## Versions
- [*] dev
- [ ] 3.0
- [ ] 2.1
- [ ] 2.0
## Languages
- [*] Chinese
- [*] English
## Docs Checklist
- [ ] Checked by AI
- [ ] Test Cases Built
---
.../scalar-functions/json-functions/json-extract.md | 15 ++++++++++++++-
.../scalar-functions/json-functions/json-extract.md | 15 ++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-extract.md
b/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-extract.md
index 89caa880fc5..ea865969016 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-extract.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-extract.md
@@ -35,6 +35,7 @@ JSON_EXTRACT (<json_object>, <path>[, <path2>, ...])
* `[i]` represents the element at index i in the json array
* To get the last element of json_array, you can use `$[last]`, the
second to last element can use `$[last-1]`, and so on.
* `*` represents a wildcard, where `$.*` represents all members of the
root object, and `$[*]` represents all elements of the array.
+ * `**` is used in combination with '$', '$**' represents all paths
(including multi-level subpaths).
- If `<path>` contains wildcards (`*`), the matching results will be returned
in array form.
## Examples
@@ -160,7 +161,19 @@ JSON_EXTRACT (<json_object>, <path>[, <path2>, ...])
| [[1,2,3,4,5],"abc",{"k4":"v4"},"v4"]
|
+---------------------------------------------------------------------------------------+
```
-9. Value is NULL case
+9. '**' in path
+ ```sql
+ select json_extract('{"k": 123, "b": {"k": ["ab", "cd"]}}', '$**.k');
+ ```
+ ```text
+ +---------------------------------------------------------------+
+ | json_extract('{"k": 123, "b": {"k": ["ab", "cd"]}}', '$**.k') |
+ +---------------------------------------------------------------+
+ | [123,["ab","cd"]] |
+ +---------------------------------------------------------------+
+ ```
+
+10. Value is NULL case
```sql
select JSON_EXTRACT('{"id": 123, "name": null}', '$.name') v,
JSON_EXTRACT('{"id": 123, "name": null}', '$.name') is null v2;
```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-extract.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-extract.md
index a377961e52a..bc69a0d77fc 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-extract.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-extract.md
@@ -35,6 +35,8 @@ JSON_EXTRACT (<json_object>, <path>[, <path2>, ...])
* `[i]` 代表 json array 中下标为 i 的元素
* 获取 json_array 的最后一个元素可以用`$[last]`,倒数第二个元素可以用`$[last-1]`,以此类推。
* `*` 代表通配符,即 `$.*` 代表根对象的所有成员,`$[*]` 代表数组的所有元素。
+ * `**` 代表通配符,通常和 '$' 一起使用: '$**' 代表所有的路径(以及多层的子路径,见下面的示例 9)。
+
- 如果 `<path>` 存在通配符(`*`),匹配的结果会以数组形式返回。
## 示例
@@ -160,7 +162,18 @@ JSON_EXTRACT (<json_object>, <path>[, <path2>, ...])
| [[1,2,3,4,5],"abc",{"k4":"v4"},"v4"]
|
+---------------------------------------------------------------------------------------+
```
-9. Value 是 NULL 的情况
+9. '**' 作为通配符
+ ```sql
+ select json_extract('{"k": 123, "b": {"k": ["ab", "cd"]}}', '$**.k');
+ ```
+ ```text
+ +---------------------------------------------------------------+
+ | json_extract('{"k": 123, "b": {"k": ["ab", "cd"]}}', '$**.k') |
+ +---------------------------------------------------------------+
+ | [123,["ab","cd"]] |
+ +---------------------------------------------------------------+
+ ```
+10. Value 是 NULL 的情况
```sql
select JSON_EXTRACT('{"id": 123, "name": null}', '$.name') v,
JSON_EXTRACT('{"id": 123, "name": null}', '$.name') is null v2;
```
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]