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/04/15 16:08:45 UTC
[iotdb] branch rel/0.13 updated: [To rel/0.13] [IOTDB-2852] the import-csv tool can not import the data to nonaligned device (#5421)
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch rel/0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.13 by this push:
new 56e1251a48 [To rel/0.13] [IOTDB-2852] the import-csv tool can not import the data to nonaligned device (#5421)
56e1251a48 is described below
commit 56e1251a48f40b6635090e33dc95e70824cf99b6
Author: Xuan Ronaldo <xu...@qq.com>
AuthorDate: Sat Apr 16 00:08:41 2022 +0800
[To rel/0.13] [IOTDB-2852] the import-csv tool can not import the data to nonaligned device (#5421)
---
.../main/java/org/apache/iotdb/tool/ImportCsv.java | 6 ++++-
.../tests/tools/importCsv/ImportCsvTestIT.java | 31 ++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
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 02e4c7ca51..1437460317 100644
--- a/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
+++ b/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
@@ -607,7 +607,11 @@ public class ImportCsv extends AbstractCsvTool {
List<List<String>> measurementsList,
int retryTime) {
try {
- session.insertAlignedRecords(deviceIds, times, measurementsList, typesList, valuesList);
+ if (!aligned) {
+ session.insertRecords(deviceIds, times, measurementsList, typesList, valuesList);
+ } else {
+ session.insertAlignedRecords(deviceIds, times, measurementsList, typesList, valuesList);
+ }
} catch (IoTDBConnectionException e) {
if (retryTime > 0) {
try {
diff --git a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ImportCsvTestIT.java b/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ImportCsvTestIT.java
index 749ff8c949..4dad730477 100644
--- a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ImportCsvTestIT.java
+++ b/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ImportCsvTestIT.java
@@ -190,6 +190,37 @@ public class ImportCsvTestIT extends AbstractScript {
}
}
+ /**
+ * test the situation that the schema has been created and CSV file has no problem
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testAligned() throws IOException, ClassNotFoundException {
+ assertTrue(generateTestCSV(false, false, false, false, false));
+ String[] params = {"-f", CSV_FILE, "-aligned", "true"};
+ testMethod(params, null);
+ File file = new File(CSV_FILE);
+ Class.forName(Config.JDBC_DRIVER_NAME);
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ if (statement.execute("show devices")) {
+ ResultSet resultSet = statement.getResultSet();
+ while (resultSet.next()) {
+ assertTrue("true".equals(resultSet.getString(2)));
+ }
+ resultSet.close();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (file.exists()) {
+ file.delete();
+ }
+ }
+
/**
* test the situation that the schema has not been created and CSV file has no problem
*