You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/10/17 04:43:31 UTC

[doris] branch master updated: [optimization](array-type) update the docs for import data to array column (#13345)

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

morningman 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 4caa1e8041 [optimization](array-type) update the docs for import data to array column (#13345)
4caa1e8041 is described below

commit 4caa1e8041b38b4d11e048d43663d6adcb9c1e0e
Author: carlvinhust2012 <hu...@126.com>
AuthorDate: Mon Oct 17 12:43:22 2022 +0800

    [optimization](array-type) update the docs for import data to array column (#13345)
    
    1. this pr is used to update the json load docs for  import data to array column.
    when we use json to import data to array column,  the Rapidjson will cause precision problems.
    so we update the json-load docs to specify how to avoid these problems.
    
    Issue Number: #7570
    Co-authored-by: hucheng01 <hu...@baidu.com>
---
 .../import/import-way/load-json-format.md          | 42 ++++++++++++++++++++++
 .../import/import-way/load-json-format.md          | 41 +++++++++++++++++++++
 2 files changed, 83 insertions(+)

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 d612a3faf3..7fdb02dea3 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
@@ -507,6 +507,48 @@ Import result:
 105 {"order1":["guangzhou"]} 7
 ````
 
+6. Import Array by json
+Since the Rapidjson handles decimal and largeint numbers which will cause precision problems, 
+we suggest you to use json string to import data to `array<decimal>` or `array<largeint>` column.
+
+```json
+{"k1": 39, "k2": ["-818.2173181"]}
+```
+
+```json
+{"k1": 40, "k2": ["10000000000000000000.1111111222222222"]}
+```
+
+```bash
+curl --location-trusted -u root:  -H "max_filter_ration:0.01" -H "format:json" -H "timeout:300" -T test_decimal.json http://localhost:8035/api/example_db/array_test_decimal/_stream_load
+```
+
+Import result:
+MySQL > select * from array_test_decimal;
++------+----------------------------------+
+| k1   | k2                               |
++------+----------------------------------+
+|   39 | [-818.2173181]                   |
+|   40 | [100000000000000000.001111111]   |
++------+----------------------------------+
+
+
+```json
+{"k1": 999, "k2": ["76959836937749932879763573681792701709", "26017042825937891692910431521038521227"]}
+```
+
+```bash
+curl --location-trusted -u root:  -H "max_filter_ration:0.01" -H "format:json" -H "timeout:300" -T test_largeint.json http://localhost:8035/api/example_db/array_test_largeint/_stream_load
+```
+
+Import result:
+MySQL > select * from array_test_largeint;
++------+------------------------------------------------------------------------------------+
+| k1   | k2                                                                                 |
++------+------------------------------------------------------------------------------------+
+|  999 | [76959836937749932879763573681792701709, 26017042825937891692910431521038521227]   |
++------+------------------------------------------------------------------------------------+
+
 ### Routine Load
 
 The processing principle of Routine Load for Json data is the same as that of Stream Load. It is not repeated here.
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 f28d591f22..fd7a91953b 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
@@ -510,6 +510,47 @@ curl --location-trusted -u user:passwd -H "format: json" -H "jsonpaths: [\"$.id\
 105     {"order1":["guangzhou"]}    7
 ```
 
+6. 使用json导入Array类型
+由于Rapidjson处理decimal和largeint数值会导致精度问题,所以我们建议使用json字符串来导入数据到`array<decimal>` 或 `array<largeint>`列。
+
+```json
+{"k1": 39, "k2": ["-818.2173181"]}
+```
+
+```json
+{"k1": 40, "k2": ["10000000000000000000.1111111222222222"]}
+```
+
+```bash
+curl --location-trusted -u root:  -H "max_filter_ration:0.01" -H "format:json" -H "timeout:300" -T test_decimal.json http://localhost:8035/api/example_db/array_test_decimal/_stream_load
+```
+
+导入结果:
+MySQL > select * from array_test_decimal;
++------+----------------------------------+
+| k1   | k2                               |
++------+----------------------------------+
+|   39 | [-818.2173181]                   |
+|   40 | [100000000000000000.001111111]   |
++------+----------------------------------+
+
+
+```json
+{"k1": 999, "k2": ["76959836937749932879763573681792701709", "26017042825937891692910431521038521227"]}
+```
+
+```bash
+curl --location-trusted -u root:  -H "max_filter_ration:0.01" -H "format:json" -H "timeout:300" -T test_largeint.json http://localhost:8035/api/example_db/array_test_largeint/_stream_load
+```
+
+导入结果:
+MySQL > select * from array_test_largeint;
++------+------------------------------------------------------------------------------------+
+| k1   | k2                                                                                 |
++------+------------------------------------------------------------------------------------+
+|  999 | [76959836937749932879763573681792701709, 26017042825937891692910431521038521227]   |
++------+------------------------------------------------------------------------------------+
+
 ### Routine Load
 
 Routine Load 对 Json 数据的处理原理和 Stream Load 相同。在此不再赘述。


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org