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.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e56adee151 [improvement](docs) add Json load case doc (#29001)
4e56adee151 is described below

commit 4e56adee1518098f42ff2ca928ed9cfa636590df
Author: Petrichor <[email protected]>
AuthorDate: Sat Dec 30 00:02:43 2023 +0800

    [improvement](docs) add Json load case doc (#29001)
---
 .../import/import-way/load-json-format.md          | 84 ++++++++++++++++++----
 .../import/import-way/load-json-format.md          | 55 ++++++++++++++
 2 files changed, 125 insertions(+), 14 deletions(-)

diff --git a/docs/en/docs/data-operate/import/import-way/load-json-format.md 
b/docs/en/docs/data-operate/import/import-way/load-json-format.md
index d66845cb592..15968f26436 100644
--- a/docs/en/docs/data-operate/import/import-way/load-json-format.md
+++ b/docs/en/docs/data-operate/import/import-way/load-json-format.md
@@ -243,9 +243,9 @@ In import statement 1, only JSON Path is specified, and 
Columns is not specified
 
 ````text
 +------+------+
-| k1 | k2 |
+| k1   | k2   |
 +------+------+
-| 2 | 1 |
+| 2    | 1    |
 +------+------+
 ````
 
@@ -261,9 +261,9 @@ Compared with the import statement 1, the Columns field is 
added here to describ
 
 ````text
 +------+------+
-| k1 | k2 |
+| k1   |  k2  |
 +------+------+
-| 1 | 2 |
+| 1    | 2    |
 +------+------+
 ````
 
@@ -277,12 +277,68 @@ The above example will import the value of k1 multiplied 
by 100. The final impor
 
 ````text
 +------+------+
-| k1 | k2 |
+| k1   | k2   |
 +------+------+
-| 100 | 2 |
+| 100  | 2    |
 +------+------+
 ````
 
+Import statement 3:
+
+Compared with the  import statement 1 and import statement 2, the columns 
field `k1_copy` is added here.
+Table Structure:
+
+```
+k2 int, k1 int, k1_copy int
+```
+
+If you want to assign a column field in JSON to several column fields in the 
table multiple times, you can specify the column multiple times in jsonPaths 
and specify the mapping order in sequence. An example is as follows:
+
+```bash
+curl -v --location-trusted -u root: -H "format: json" -H "jsonpaths: 
[\"$.k2\", \"$.k1\", \"$.k1\"]" -H "columns: k2,k1,k1_copy" -T example.json 
http://127.0.0.1:8030/api/db1/tbl1/_stream_load
+```
+
+The above example will extract the fields in the order specified by the JSON 
Path. It designates the first column as the value for the `k2` column in the 
table, the second column as the value for the `k1` column, and the third column 
as the value for the `k1_copy` column. The final imported data result is as 
follows:
+
+```text
++------+------+---------+
+| k2   | k1   | k2_copy |
++------+------+---------+
+|    2 |    1 |       2 |
++------+------+---------+
+```
+
+Import statement 4:
+
+Data content:
+
+```json
+{"k1" : 1, "k2": 2, "k3": {"k1" : 31, "k1_nested" : {"k1" : 32} } }
+```
+
+Compared with the  import statement 1 and import statement 2, the columns 
field `k1_nested1` and `k1_nested2` are added here.
+
+Table Structure:
+
+```
+k2 int, k1 int, k1_nested1 int, k1_nested2 int
+```
+If you want to assign multi-level fields with the same name nested in json to 
different columns in the table, you can specify the column in jsonPaths and 
specify the mapping order in turn. An example are as follows:
+
+```bash
+curl -v --location-trusted -u root: -H "format: json" -H "jsonpaths: 
[\"$.k2\", \"$.k1\",\"$.k3.k1\",\"$.k3.k1_nested.k1\" -H "columns: 
k2,k1,k1_nested1,k1_nested2" -T example.json 
http://127.0.0.1:8030/api/db1/tbl1/_stream_load
+```
+
+The above example will extract the fields in the order of the JSON Path, 
specifying that the first column is the value of the `k2` column in the table, 
the second column is the value of the `k1` column in the table, and the third 
column is the `k1` column in the nested type. The value of the `k1_nested1` 
column, from which we know that the `k3.k1_nested.k1` column is the value of 
the `k1_nested2` column in the table. The final imported data results are as 
follows:
+
+```text
++------+------+------------+------------+
+| k2   | k1   | k1_nested1 | k1_nested2 |
++------+------+------------+------------+
+|    2 |    1 |         31 |         32 |
++------+------+------------+------------+
+```
+
 ## JSON root
 
 Doris supports extracting data specified in JSON through JSON root.
@@ -340,13 +396,13 @@ The import results that users may expect are as follows, 
that is, for missing co
 
 ````text
 +------+------+
-| k1 | k2 |
+| k1 | k2     |
 +------+------+
-| 1 | a |
+| 1    | a    |
 +------+------+
-| 2 | x |
+| 2    | x    |
 +------+------+
-|3|c|
+|3     |c     |
 +------+------+
 ````
 
@@ -354,13 +410,13 @@ But the actual import result is as follows, that is, for 
the missing column, NUL
 
 ````text
 +------+------+
-| k1 | k2 |
+| k1 | k2     |
 +------+------+
-| 1 | a |
+| 1    | a    |
 +------+------+
-| 2 | NULL |
+| 2    | NULL |
 +------+------+
-|3|c|
+|3     |c     |
 +------+------+
 ````
 
diff --git a/docs/zh-CN/docs/data-operate/import/import-way/load-json-format.md 
b/docs/zh-CN/docs/data-operate/import/import-way/load-json-format.md
index f0e35f7340a..82bb9a895b9 100644
--- a/docs/zh-CN/docs/data-operate/import/import-way/load-json-format.md
+++ b/docs/zh-CN/docs/data-operate/import/import-way/load-json-format.md
@@ -284,6 +284,61 @@ curl -v --location-trusted -u root: -H "format: json" -H 
"jsonpaths: [\"$.k2\",
 +------+------+
 ```
 
+导入语句3:
+
+相比于导入语句1和导入语句2的表结构,这里增加`k1_copy`列。
+表结构:
+
+```
+k2 int, k1 int, k1_copy int
+```
+如果你想将json中的某一字段多次赋予给表中几列,那么可以在jsonPaths中多次指定该列,并且依次指定映射顺序。示例如下:
+
+```bash
+curl -v --location-trusted -u root: -H "format: json" -H "jsonpaths: 
[\"$.k2\", \"$.k1\", \"$.k1\"]" -H "columns: k2,k1,k1_copy" -T example.json 
http://127.0.0.1:8030/api/db1/tbl1/_stream_load
+```
+
+上述示例会按 JSON Path 中字段的顺序抽取后,指定第一列为表中 k2 列的值,而第二列为表中 k1 列的值,第二列为表中 k1_copy 
列的值。最终导入的数据结果如下:
+
+```text
++------+------+---------+
+| k2   | k1   | k2_copy |
++------+------+---------+
+|    2 |    1 |       2 |
++------+------+---------+
+```
+
+导入语句4:
+
+数据内容:
+
+```json
+{"k1" : 1, "k2": 2, "k3": {"k1" : 31, "k1_nested" : {"k1" : 32} } }
+```
+
+相比于导入语句1和导入语句2的表结构,这里增加`k1_nested1`,`k1_nested2`列。
+表结构:
+
+```
+k2 int, k1 int, k1_nested1 int, k1_nested2 int
+```
+如果你想将json中嵌套的多级同名字段赋予给表中不同的列,那么可以在jsonPaths中指定该列,并且依次指定映射顺序。示例如下:
+
+```bash
+curl -v --location-trusted -u root: -H "format: json" -H "jsonpaths: 
[\"$.k2\", \"$.k1\",\"$.k3.k1\",\"$.k3.k1_nested.k1\" -H "columns: 
k2,k1,k1_nested1,k1_nested2" -T example.json 
http://127.0.0.1:8030/api/db1/tbl1/_stream_load
+```
+
+上述示例会按 JSON Path 中字段的顺序抽取后,指定第一列为表中 k2 列的值,而第二列为表中 k1 列的值,第三列嵌套类型中的 k1 列为表中 
k1_nested1 列的值,由此可知 k3.k1_nested.k1 列为表中 k1_nested2列的值。 最终导入的数据结果如下:
+
+```text
++------+------+------------+------------+
+| k2   | k1   | k1_nested1 | k1_nested2 |
++------+------+------------+------------+
+|    2 |    1 |         31 |         32 |
++------+------+------------+------------+
+```
+
+
 ## JSON root
 
 Doris 支持通过 JSON root 抽取 JSON 中指定的数据。


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

Reply via email to