You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/08/17 01:44:22 UTC

[iotdb] branch master updated: [IOTDB-4121] logical optimizations for ImportCsv (#6998)

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

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 23cb64c16e [IOTDB-4121] logical optimizations for ImportCsv (#6998)
23cb64c16e is described below

commit 23cb64c16e77bcc553297c810f14dc4fc97e15bc
Author: Summer <43...@users.noreply.github.com>
AuthorDate: Wed Aug 17 09:44:16 2022 +0800

    [IOTDB-4121] logical optimizations for ImportCsv (#6998)
---
 cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java | 16 ++++++++++------
 docs/UserGuide/Write-And-Delete-Data/CSV-Tool.md       | 12 +++++++-----
 docs/zh/UserGuide/Write-And-Delete-Data/CSV-Tool.md    |  9 ++++++---
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java b/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
index ae0b97f318..dd3ff6a0f1 100644
--- a/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
+++ b/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
@@ -331,10 +331,12 @@ public class ImportCsv extends AbstractCsvTool {
 
     Set<String> devices = deviceAndMeasurementNames.keySet();
     String devicesStr = StringUtils.join(devices, ",");
-    try {
-      queryType(devicesStr, headerTypeMap, "Time");
-    } catch (IoTDBConnectionException e) {
-      e.printStackTrace();
+    if (headerTypeMap.isEmpty()) {
+      try {
+        queryType(devicesStr, headerTypeMap, "Time");
+      } catch (IoTDBConnectionException e) {
+        e.printStackTrace();
+      }
     }
 
     List<String> deviceIds = new ArrayList<>();
@@ -501,7 +503,9 @@ public class ImportCsv extends AbstractCsvTool {
                 // query the data type in iotdb
                 if (!typeQueriedDevice.contains(deviceName.get())) {
                   try {
-                    hasResult = queryType(deviceName.get(), headerTypeMap, "Device");
+                    if (headerTypeMap.isEmpty()) {
+                      hasResult = queryType(deviceName.get(), headerTypeMap, "Device");
+                    }
                     typeQueriedDevice.add(deviceName.get());
                   } catch (IoTDBConnectionException e) {
                     e.printStackTrace();
@@ -829,7 +833,7 @@ public class ImportCsv extends AbstractCsvTool {
           if (value.startsWith("\"") && value.endsWith("\"")) {
             return value.substring(1, value.length() - 1);
           }
-          return null;
+          return value;
         case BOOLEAN:
           if (!"true".equals(value) && !"false".equals(value)) {
             return null;
diff --git a/docs/UserGuide/Write-And-Delete-Data/CSV-Tool.md b/docs/UserGuide/Write-And-Delete-Data/CSV-Tool.md
index c225dbd9cf..a9fc08b931 100644
--- a/docs/UserGuide/Write-And-Delete-Data/CSV-Tool.md
+++ b/docs/UserGuide/Write-And-Delete-Data/CSV-Tool.md
@@ -142,12 +142,14 @@ Time,root.test.t1.str,root.test.t2.str,root.test.t2.int
 1970-01-01T08:00:00.002+08:00,"123",,
 ```
 
-The data aligned by time, and headers with data type.
+The data aligned by time, and headers with data type.(Text type data supports double quotation marks and no double quotation marks)
 
 ```sql
 Time,root.test.t1.str(TEXT),root.test.t2.str(TEXT),root.test.t2.int(INT32)
 1970-01-01T08:00:00.001+08:00,"123hello world","123\,abc",100
-1970-01-01T08:00:00.002+08:00,"123",,
+1970-01-01T08:00:00.002+08:00,123,hello world,123
+1970-01-01T08:00:00.003+08:00,"123",,
+1970-01-01T08:00:00.004+08:00,123,,12
 ```
 
 The data aligned by device, and headers without data type.
@@ -159,13 +161,13 @@ Time,Device,str,int
 1970-01-01T08:00:00.001+08:00,root.test.t2,"123\,abc",100
 ```
 
-The data aligned by device,  and headers with data type.
+The data aligned by device,  and headers with data type.(Text type data supports double quotation marks and no double quotation marks)
 
 ```sql
 Time,Device,str(TEXT),int(INT32)
 1970-01-01T08:00:00.001+08:00,root.test.t1,"123hello world",
-1970-01-01T08:00:00.002+08:00,root.test.t1,"123",
-1970-01-01T08:00:00.001+08:00,root.test.t2,"123\,abc",100
+1970-01-01T08:00:00.002+08:00,root.test.t1,hello world,123
+1970-01-01T08:00:00.003+08:00,root.test.t1,,123
 ```
 
 ### Syntax
diff --git a/docs/zh/UserGuide/Write-And-Delete-Data/CSV-Tool.md b/docs/zh/UserGuide/Write-And-Delete-Data/CSV-Tool.md
index 50b22c4678..6abd676aa6 100644
--- a/docs/zh/UserGuide/Write-And-Delete-Data/CSV-Tool.md
+++ b/docs/zh/UserGuide/Write-And-Delete-Data/CSV-Tool.md
@@ -142,12 +142,14 @@ Time,root.test.t1.str,root.test.t2.str,root.test.t2.int
 1970-01-01T08:00:00.002+08:00,"123",,
 ```
 
-通过时间对齐,并且header中包含数据类型的数据。
+通过时间对齐,并且header中包含数据类型的数据。(Text类型数据支持加双引号和不加双引号)
 
 ```sql
 Time,root.test.t1.str(TEXT),root.test.t2.str(TEXT),root.test.t2.int(INT32)
 1970-01-01T08:00:00.001+08:00,"123hello world","123\,abc",100
-1970-01-01T08:00:00.002+08:00,"123",,
+1970-01-01T08:00:00.002+08:00,123,hello world,123
+1970-01-01T08:00:00.003+08:00,"123",,
+1970-01-01T08:00:00.004+08:00,123,,12
 ```
 
 通过设备对齐,并且header中不包含数据类型的数据。
@@ -159,13 +161,14 @@ Time,Device,str,int
 1970-01-01T08:00:00.001+08:00,root.test.t2,"123\,abc",100
 ```
 
-通过设备对齐,并且header中包含数据类型的数据。
+通过设备对齐,并且header中包含数据类型的数据。(Text类型数据支持加双引号和不加双引号)
 
 ```sql
 Time,Device,str(TEXT),int(INT32)
 1970-01-01T08:00:00.001+08:00,root.test.t1,"123hello world",
 1970-01-01T08:00:00.002+08:00,root.test.t1,"123",
 1970-01-01T08:00:00.001+08:00,root.test.t2,"123\,abc",100
+1970-01-01T08:00:00.002+08:00,root.test.t1,hello world,123
 ```
 
 ### 运行方法