Caideyipi commented on code in PR #19150:
URL: https://github.com/apache/iotdb/pull/19150#discussion_r4510689115


##########
iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTree.java:
##########
@@ -131,18 +133,65 @@ protected void importSchemaFromCsvFile(File file) {
     }
   }
 
-  private static CSVParser readCsvFile(String path) throws IOException {
-    return CSVFormat.Builder.create(CSVFormat.DEFAULT)
-        .setHeader()
-        .setSkipHeaderRecord(true)
-        .setQuote('`')
-        .setEscape('\\')
-        .setIgnoreEmptyLines(true)
-        .build()
-        .parse(new InputStreamReader(new FileInputStream(path)));
+  static CSVParser readCsvFile(String path) throws IOException {
+    CSVFormat.Builder builder =
+        CSVFormat.Builder.create(CSVFormat.DEFAULT)
+            .setHeader()
+            .setSkipHeaderRecord(true)
+            .setIgnoreEmptyLines(true);
+    if (isV2Format(readHeaderNames(path))) {
+      builder.setQuote('"');
+    } else {
+      builder.setQuote('`').setEscape('\\');
+    }
+    return builder.build().parse(new InputStreamReader(new 
FileInputStream(path)));

Review Comment:
   [P1] Use an explicit UTF-8 charset for schema CSV I/O. The V2 format carries 
arbitrary tag and attribute text, but this reader uses the platform default 
charset. The exporter also opens `new PrintWriter(filePath)` with the platform 
default. On supported JDK 17 Windows, values such as `δΈ­ζ–‡πŸ˜€` may be replaced 
during export; files exchanged across platforms can also be decoded incorrectly 
on import. The new round-trip test reads the file as UTF-8, so this can fail 
there too. Please use UTF-8 consistently for writing, parsing, and header 
detection.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to